Skip to content

Honor all <option> descendants of <select> #249

@ayg

Description

@ayg

The spec says:

The list of options for a select element consists of all the option element children of the select element, and all the option element children of all the optgroup element children of the select element, in tree order.
https://html.spec.whatwg.org/#concept-select-option-list

Test-case:

data:text/html,<!doctype html>
<script>
var select = document.createElement("select");
select.appendChild(document.createElement("optgroup"));
select.firstChild.appendChild(document.createElement("optgroup"));
select.firstChild.firstChild.appendChild(document.createElement("option"));
document.documentElement.textContent = select.options.length;
</script>

IE11 outputs 0, per spec. Gecko and Chrome output 1. Assuming WebKit behaves the same as Blink, 3/4 of UAs will have to switch to match the spec. If the spec switched to match majority behavior, only 1/4 would have to switch. The behavior in this case is totally inconsequential, because the DOM in question cannot (AFAIK) be produced by the parser, so it's almost certainly not going to come up on real-world web pages. So I suggest we standardize on the majority behavior to ease interop.

Existing test for this behavior that would need to be changed: http://w3c-test.org/html/infrastructure/common-dom-interfaces/collections/htmloptionscollection.html (the test with "" in it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIdeal for someone new to a WHATWG standard or software project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions