Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ayg opened this issue Oct 12, 2015 · 5 comments

Comments

3 participants
@ayg
Copy link
Contributor

commented Oct 12, 2015

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)

@annevk

This comment has been minimized.

Copy link
Member

commented Oct 13, 2015

It's not just any descendant though. option needs to be a child of optgroup or select. And optgroup needs to be a child of optgroup or select.

@tkent-google

This comment has been minimized.

Copy link
Collaborator

commented Oct 13, 2015

We fixed this for Blink recently. Google Chrome 46 or 47 will have the conforming behavior.

@annevk

This comment has been minimized.

Copy link
Member

commented Oct 13, 2015

Inclined to close this then. What do you think, @ayg?

@ayg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 13, 2015

Okay, then it's easiest to leave the spec as-is IMO.

@ayg ayg closed this Oct 13, 2015

@ayg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.