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

HTMLSelectElement.options should be an HTMLOptionsCollection, not HTMLCollection #8220

Closed
evmar opened this issue Apr 20, 2016 · 1 comment
Closed
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@evmar
Copy link
Contributor

evmar commented Apr 20, 2016

According to
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement
the options property should be an HTMLOptionsCollection
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionsCollection

Which is just like an HTMLCollection but all the options are HTMLOptionElement.
This allows code like

let select: HTMLSelectElement = ...;
console.log(select.options[0].value);

to work without needing to coerce select.options[0] to a HTMLOptionElement.

See also this (closed) issue for some background -- I think the type of this got a bit funky at one point due to a bug in Edge that was fixed: #1558

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Apr 20, 2016
@evmar
Copy link
Contributor Author

evmar commented Apr 20, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants