Skip to content

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

Merged
merged 1 commit into from
Sep 6, 2014
Merged

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Sep 5, 2014

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.

@vladima
Copy link
Contributor

vladima commented Sep 5, 2014

👍

* Retrieves a select object or an object from an options collection.
*/
namedItem(name: string): Element;
// [name: string]: Element;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

mhegazy added a commit that referenced this pull request Sep 6, 2014
Add numeric indexer to HTMLElementCollection
@mhegazy mhegazy merged commit 90ecf81 into master Sep 6, 2014
@mhegazy mhegazy deleted the HTMLElementIndexer branch January 11, 2015 22:17
nahuel added a commit to nahuel/typed-promisify that referenced this pull request Jan 26, 2017
nahuel added a commit to nahuel/typed-promisify that referenced this pull request Jan 26, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants