-
Notifications
You must be signed in to change notification settings - Fork 13k
Add numeric indexer to HTMLElementCollection #609
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
Conversation
👍 |
* Retrieves a select object or an object from an options collection. | ||
*/ | ||
namedItem(name: string): Element; | ||
// [name: string]: Element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mohamed explained it in the PR message, but I'm still a little confused, and I think it warrants a code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the question.. the indexer is to allow collection[0] ==> Element, instead of an implicit any.
the change in order is about the script I use to generate the file, if I override any thing in the interface it process it firs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a string indexer that is commented out. That is what I am asking about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cause we can not enable it. yet the definition says it has a string indexer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it is more of a guide to know what to expect if you index with a string and get any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we then remove it? Is there a reason why we comment out instead of delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) yes..
cause we can not enable it. yet the definition says it has a string indexer.
so it is more of a guide to know what to expect if you index with a string and get any.
so it is included intentionally, as it reflects the spec, yet it is not a valid TypeScript definition.
Add numeric indexer to HTMLElementCollection
The change is adding
[index: number]: Element;
to HTMLCollection .The definition of HTMLCollection has a string indexer, but we can not use it as it has a length property that is of type number; so we comment that out.
there is no reason however to not include the numeric indexer.
the generation script moved it up, so this is why the change looks weird.