From 703a99f846545353a1a9c60067d96c58bf725ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 2 Oct 2022 06:31:02 -1000 Subject: [PATCH 1/2] Specify a limit in HTMLOptionsCollection.length setter. This aligns with WebKit's behavior, but bumps the limit with 100k, as per the discussion in https://github.com/whatwg/html/issues/8337. Co-authored-by: Domenic Denicola --- source | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/source b/source index e218b740b49..f246535cea1 100644 --- a/source +++ b/source @@ -8374,8 +8374,9 @@ interface HTMLOptionsCollection : HTMLCollectionWhen set to a smaller number than the existing length, truncates the number of option elements in the container corresponding to collection.

-

When set to a greater number than the existing length, adds new blank option - elements to the container corresponding to collection.

+

When set to a greater number than the existing length, if that number is less than or equal + to 100000, adds new blank option elements to the container corresponding to + collection.

element = collection.item(index)
@@ -8435,17 +8436,41 @@ interface HTMLOptionsCollection : HTMLCollectionThe object's supported property indices are as defined for HTMLCollection objects.

-

On getting, the length attribute must return the number of - nodes represented by the collection.

- -

On setting, the behavior depends on whether the new value is equal to, greater than, or less - than the number of nodes represented by the collection at that time. If the number is - the same, then setting the attribute must do nothing. If the new value is greater, then n new option elements with no attributes and no child nodes must be - appended to the select element on which the HTMLOptionsCollection is - rooted, where n is the difference between the two numbers (new value minus old - value). Mutation events must be fired as if a DocumentFragment containing the new - option elements had been inserted. If the new value is lower, then the last n nodes in the collection must be removed from their parent nodes, where n is the difference between the two numbers (old value minus new value).

+

The length getter steps are to return the + number of nodes represented by the collection.

+ +

The length setter steps are:

+ +
    +
  1. Let current be the number of nodes represented by the + collection.

  2. + +
  3. +

    If the given value is greater than current, then:

    + +
      +
    1. If the given value is greater than 100000, then return.

    2. + +
    3. Let n be valuecurrent.

    4. + +
    5. Append n new option elements with no attributes and no child + nodes to the select element on which this is rooted. Mutation events + must be fired as if a DocumentFragment containing the new option + elements had been inserted.

    6. +
    +
  4. + +
  5. +

    If the given value is less than current, then:

    + +
      +
    1. Let n be currentvalue.

    2. + +
    3. Remove the last n nodes in the collection from their parent nodes.

    4. +
    +
  6. +

Setting length never removes or adds any optgroup elements, and never adds new children to existing From 036bb73233e641f3f8832e506ef368ac4effe293 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 19 Oct 2022 13:25:25 +0900 Subject: [PATCH 2/2] It seems we use commas in large numbers --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index f246535cea1..f3778195cb9 100644 --- a/source +++ b/source @@ -8450,7 +8450,7 @@ interface HTMLOptionsCollection : HTMLCollectionIf the given value is greater than current, then:

    -
  1. If the given value is greater than 100000, then return.

  2. +
  3. If the given value is greater than 100,000, then return.

  4. Let n be valuecurrent.