From 088b919966bf86e347ff6d86eca440d8f2c1b0fd Mon Sep 17 00:00:00 2001
From: Joey Arhar
Date: Tue, 16 Jul 2024 16:12:42 -0700
Subject: [PATCH 1/7] Update content model for customizable select
This PR updated the content model for the
+ cell", "in template", "after body", "in frameset", "after
+ frameset", "after after body", and
+ "after after frameset" during the
+ course of the parsing, as described in the tree construction stage. The insertion
+ mode affects how tokens are processed and whether CDATA sections are supported.
Several of these modes, namely "in head", "in body", "in
- table", and "in select", are special, in
- that the other modes defer to them at various times. When the algorithm below says that the user
- agent is to do something "using the rules for the m insertion
- mode", where m is one of these modes, the user agent must use the rules
- described under the minsertion mode's section, but must leave
- the insertion mode unchanged unless the rules in m themselves
- switch the insertion mode to a new value.
+ data-x="insertion mode: in body">in body", and "in
+ table", are special, in that the other modes defer to them at various times. When the
+ algorithm below says that the user agent is to do something "using the rules for the
+ m insertion mode", where m is one of these modes, the user agent must use
+ the rules described under the minsertion mode's section, but must leave
+ the insertion mode unchanged unless the rules in m themselves switch the
+ insertion mode to a new value.
When the insertion mode is switched to "text" or
"in table text", the original insertion
@@ -124402,37 +124417,6 @@ dictionary StorageEventInit : EventInit {
parsing algorithm (fragment case), set node to the context element passed to that algorithm.
-
-
If node is a select element, run these substeps:
-
-
-
If last is true, jump to the step below labeled
- done.
-
-
Let ancestor be node.
-
-
Loop: If ancestor is the first node in the stack of
- open elements, jump to the step below labeled done.
-
-
Let ancestor be the node before ancestor in the
- stack of open elements.
-
-
If ancestor is a template node, jump to the step below
- labeled done.
-
-
If ancestor is a table node, switch the insertion
- mode to "in select in table"
- and return.
-
-
Jump back to the step labeled loop.
-
-
Done: Switch the insertion mode to "in select" and return.
-
-
-
If node is a td or th element and last is
false, then switch the insertion mode to "in
cell" and return.
The stack of open elements is said to have a particular element in select scope when it has that element in the specific scope consisting of all element types
- except the following:
-
-
-
-
optgroup in the HTML namespace
-
option in the HTML namespace
-
-
Nothing happens if at any time any of the elements in the stack of open elements
are moved to a new location in, or removed from, the Document tree. In particular,
the stack is not changed in this situation. This can cause, amongst other strange effects, content
@@ -129324,6 +129298,24 @@ document.body.appendChild(text);
p element in button scope, then close a p
element.
+
If the stack of open elementshas a
+ select element in scope and has either an option element in scope or an optgroup element in scope, then:
+
+
+
Generate implied end tags except for option and
+ optgroup elements.
+
+
If the current node is not now an option or
+ optgroup element, this is a parse error.
+
+
While the stack of open elementshas
+ an option element in scope or has an
+ optgroup element in scope, pop an element from the stack of open
+ elements.
+
+
Insert an HTML element for the token. Immediately pop the current
node off the stack of open elements.
If the stack of open elementshas a
+ select element in scope, then:
+
+
+
Parse error.
+
+
Pop elements from the stack of open elements until a select
+ element has been popped from the stack.
+
+
Reconstruct the active formatting elements, if any.
Insert an HTML element for the token.
Set the frameset-ok flag to "not ok".
+
+
+
A start tag whose tag name is "option"
+
+
If the stack of open elementshas a
+ select element in scope and has a has
+ an option element in scope, then:
+
+
+
Generate implied end tags except for option elements.
+
+
If the current node is not now an option element, this is a
+ parse error.
+
+
While the stack of open elementshas
+ an option element in scope, pop an element from the stack of open
+ elements.
+
+
+
Reconstruct the active formatting elements, if any.
-
If the insertion mode is one of "in
- table", "in caption", "in table body", "in row", or "in cell", then switch the
- insertion mode to "in select in
- table". Otherwise, switch the insertion mode to "in select".
+
Insert an HTML element for the token.
-
A start tag whose tag name is one of: "optgroup", "option"
+
A start tag whose tag name is "optgroup"
-
If the current node is an option element, then pop the
- current node off the stack of open elements.
+
If the stack of open elementshas a
+ select element in scope and has either an option element in scope or an optgroup element in scope, then:
+
+
+
Generate implied end tags except for option and
+ optgroup elements.
+
+
If the current node is not now an option or
+ optgroup element, this is a parse error.
+
+
Generate implied end tags except for optgroup
+ elements.
+
+
If the current node is not now an optgroup element, this is a
+ parse error.
+
+
While the stack of open elementshas
+ an option element in scope or has an
+ optgroup element in scope, pop an element from the stack of open
+ elements.
+
Reconstruct the active formatting elements, if any.
@@ -130539,231 +130576,6 @@ document.body.appendChild(text);
same time, nor can it have neither when the close the cell algorithm is invoked.
-
The "in select" insertion mode
-
-
When the user agent is to apply the rules for the "in
- select" insertion mode, the user agent must handle the token as follows:
-
-
-
-
A character token that is U+0000 NULL
-
-
Parse error. Ignore the token.
-
-
-
Any other character token
-
-
Insert the token's character.
-
-
-
A comment token
-
-
Insert a comment.
-
-
-
A DOCTYPE token
-
-
Parse error. Ignore the token.
-
-
-
A start tag whose tag name is "html"
-
-
Process the token using the rules for the "in body" insertion mode.
-
-
-
A start tag whose tag name is "option"
-
-
-
If the current node is an option element, pop that node from the
- stack of open elements.
-
-
-
Insert an HTML element for the token.
-
-
-
A start tag whose tag name is "optgroup"
-
-
-
If the current node is an option element, pop that node from the
- stack of open elements.
-
-
-
-
If the current node is an optgroup element, pop that node from the
- stack of open elements.
-
-
-
Insert an HTML element for the token.
-
-
-
A start tag whose tag name is "hr"
-
-
-
If the current node is an option element, pop that node from the
- stack of open elements.
-
-
-
-
If the current node is an optgroup element, pop that node from the
- stack of open elements.
-
-
-
Insert an HTML element for the token. Immediately pop the current
- node off the stack of open elements.
-
-
Acknowledge the token's self-closing flag, if it is set.
-
-
-
An end tag whose tag name is "optgroup"
-
-
-
First, if the current node is an option element, and the node
- immediately before it in the stack of open elements is an optgroup
- element, then pop the current node from the stack of open
- elements.
-
-
-
If the current node is an optgroup element, then pop that node from
- the stack of open elements. Otherwise, this is a parse error; ignore
- the token.
-
-
-
An end tag whose tag name is "option"
-
-
If the current node is an option element, then pop that node from
- the stack of open elements. Otherwise, this is a parse error; ignore
- the token.
-
-
-
An end tag whose tag name is "select"
-
-
If the stack of open elements does not have a select element in select scope, this is a parse
- error; ignore the token. (fragment case)
-
-
Otherwise:
-
-
Pop elements from the stack of open elements until a select element
- has been popped from the stack.
-
-
Reset the insertion mode appropriately.
-
-
-
A start tag whose tag name is "select"
-
-
Parse error.
-
-
-
If the stack of open elements does not have a select element in select scope, ignore the token.
- (fragment case)
-
-
Otherwise:
-
-
Pop elements from the stack of open elements until a select element
- has been popped from the stack.
-
-
Reset the insertion mode appropriately.
-
-
-
It just gets treated like an end tag.
-
-
-
A start tag whose tag name is one of: "input", "keygen", "textarea"
-
-
Parse error.
-
-
-
If the stack of open elements does not have a select element in select scope, ignore the token.
- (fragment case)
-
-
Otherwise:
-
-
Pop elements from the stack of open elements until a select element
- has been popped from the stack.
-
-
Reset the insertion mode appropriately.
-
-
-
Reprocess the token.
-
-
-
A start tag whose tag name is one of: "script", "template"
-
An end tag whose tag name is "template"
-
-
Process the token using the rules for the "in head" insertion mode.
-
-
-
An end-of-file token
-
-
Process the token using the rules for the "in body" insertion mode.
-
-
-
Anything else
-
-
Parse error. Ignore the token.
-
-
-
-
-
The "in select in table" insertion mode
-
-
When the user agent is to apply the rules for the "in select in table" insertion mode, the user agent must handle the
- token as follows:
-
-
-
-
A start tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr",
- "td", "th"
-
-
Parse error.
-
-
-
Pop elements from the stack of open elements until a select element
- has been popped from the stack.
-
-
Reset the insertion mode appropriately.
-
-
-
Reprocess the token.
-
-
-
An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr",
- "td", "th"
-
-
Parse error.
-
-
If the stack of open elements does not have an element in table scope that is an HTML
- element with the same tag name as that of the token, then ignore the token.
-
-
Otherwise:
-
-
-
Pop elements from the stack of open elements until a select element
- has been popped from the stack.
-
-
Reset the insertion mode appropriately.
-
-
-
Reprocess the token.
-
-
-
Anything else
-
-
Process the token using the rules for the "in select" insertion mode.
-
-
-
-
-
The "in template" insertion mode
When the user agent is to apply the rules for the "in
From 09cd1682308f7abf882df7d91ecd0306211ed240 Mon Sep 17 00:00:00 2001
From: Joey Arhar
Date: Wed, 17 Jul 2024 18:16:05 -0700
Subject: [PATCH 4/7] Define base appearance for
The activation behavior of an optionoption is to run the
+ following steps:
+
+
+
Let select be the option element ancestor select given
+ option.
+
+
If select is null, then return.
+
+
Set option's selectedness to
+ true.
+
+
Set option's dirtiness to
+ true.
+
+
Send select update notifications given
+ select.
+
+
+
If select is being rendered as a drop-down box with base
+ appearance:
+
+
+
Run the hide popover algorithm given the first item in select's
+ select popover slot's assigned nodes.
+
+
+
+
option.selected
@@ -135518,12 +135622,98 @@ progress { appearance: auto; }
with the element's optgroup element children
providing headers for groups of options where applicable.
+
+
+
select elements which render as a drop-down box support a base
+ appearance in addition to native appearance and primitive
+ appearance.
+
+
When a select is being rendered as a drop-down box with a base
+ appearance, it is expected to render as if it has the following shadow
+ root:
Since base appearance is determined by computing style, it isn't
+ possible to swap this DOM structure when switching appearance. Implementations can always include
+ the DOM structure for base appearance when the select is rendered as a
+ drop-down box and then choose to include or exclude it from the layout tree in order
+ to control whether it gets rendered or not.
+
+
select elements rendered as a drop-down box with base
+ appearance each contain the following elements as shown with ID attributes in the above
+ HTML:
+
+
+
+
A select button slot, which is a slot.
+
+
Select fallback button text, which is a div.
+
+
A select popover, which is a div.
+
+
A select popover slot, which is a slot.
+
+
+
The implicit anchor element of the select popover element is the
+ select element shadow host of the shadow host in which select popover
+ resides.
+
+
The shadow root used for select's drop-down box
+ base appearance must have its slot assignment set to "manual". The shadow root must also have delegates focus
+ set to true if select button slot has an assigned node.
+
+
Without delegates focus set to true, the select itself
+ would receive focus instead of the button which is slotted into the select
+ button slot.
+
+
select elements rendered as a drop-down box with base
+ appearance must render as if they are using manual slot assignment with the
+ following base select slotting algorithm to assign
+ their child nodes to slots. To perform the base select slotting algorithm, given a
+ select element select:
+
+
+
Let firstButton be null.
+
+
Let otherChildren be « ».
+
+
+
For eachNodechild in
+ select's children:
+
+
+
If child is a button and firstButton is null, then set
+ firstButton to child.
+
+
Otherwise, appendchild to
+ otherChildren.
+
+
+
+
Set select's select button slot's manually assigned
+ nodes to firstButton.
+
+
Set select's select popover slot's manually assigned
+ nodes to otherChildren.
+
+
An optgroup element is expected to be rendered by displaying the element's label attribute.
An option element is expected to be rendered by displaying the element's label, indented under its optgroup element if it
- has one.
+ has one. If the option is being rendered in a select which is being
+ rendered as a drop-down box with base appearance, then the
+ option is expected to render all of its children rather than by displaying its label.
Each sequence of one or more child hr element siblings may be rendered as a single
separator.