PureHTML. TreeBuilder. SelectedContent
(PureHTML v0.5.0)
View Source
The customizable select's selectedcontent mirroring, replayed after
parsing.
This is not a rule of the tree construction algorithm. The forms chapter of the standard runs "update a select's selectedcontent" from the DOM insertion steps as the parser inserts nodes, so the tree a browser ends up with shows the clone. This module produces that tree once the parse is complete, with the forms chapter's definitions as fetched on 2026-09-15:
- a select's enabled selectedcontent is its first selectedcontent
descendant in tree order, unless the select has
multipleor that selectedcontent is disabled (it sits under a nested select, an option, or another selectedcontent); - the list of options is the option descendants of the select in tree order, not descending into select, hr, option, datalist, or a nested optgroup;
- selectedness starts from the
selectedattribute, then the selectedness setting algorithm: withoutmultiple, all but the last selected option lose selectedness, and with display size 1 and nothing selected the first non-disabled option is selected; - the first selected option's children are cloned into the selectedcontent, or it is cleared when none is selected.
See: https://html.spec.whatwg.org/multipage/form-elements.html#update-a-select's-selectedcontent
Summary
Functions
Replays "update a select's selectedcontent" over the finished tree.