-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Added entries
, foreach
, values
and keys
to NodeListOf
#14641
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
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
Thanks for your PR. these files are not manually edited, they are auto-generatd from a script in . You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TSJS-lib-generator. Changes should be done in src/lib instead. As for this change specifically, it should be done in https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.iterable.d.ts |
@mhegazy I'm confused, should I add it to |
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
@cedvdb, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
src/lib/dom.iterable.d.ts
Outdated
@@ -9,5 +9,9 @@ interface NodeList { | |||
} | |||
|
|||
interface NodeListOf<TNode extends Node> { | |||
keys(): IterableIterator<number>; |
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 would add it also to NodeList
.
src/lib/dom.iterable.d.ts
Outdated
@@ -5,9 +5,17 @@ interface DOMTokenList { | |||
} | |||
|
|||
interface NodeList { | |||
keys(): IterableIterator<number>; | |||
values(): IterableIterator<[number, Node]>; |
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.
Sorry for not catching this erlier, but i think these are reversed:
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[number, Node]>;
/**
* Returns an list of keys in the list
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the list
*/
values(): IterableIterator<Node>;
}
src/lib/dom.iterable.d.ts
Outdated
keys(): IterableIterator<number>; | ||
values(): IterableIterator<[number, Node]>; | ||
entries(): IterableIterator<Node>; | ||
forEach(): void; |
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.
From https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach, this should be:
/**
* Performs the specified action for each node in an list.
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void;
src/lib/dom.iterable.d.ts
Outdated
keys(): IterableIterator<number>; | ||
values(): IterableIterator<[number, Node]>; | ||
entries(): IterableIterator<Node>; | ||
forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; |
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.
would also appreciate it if you added the comments i sugested. this way users get nice help message to read instead of going to MDN.
@mhegazy Sorry but I think that the "request changes" are wrongfully blocking this. The return values for entries and values are swapped. https://developer.mozilla.org/en-US/docs/Web/API/NodeList/entries |
thanks! |
The methods forEach of NodeList is node defined. https://www.w3.org/TR/dom/#interface-nodelist Therefore where comes this requirement from ? It works for V8 but not for all browsers. |
Added
entries
,foreach
,values
andkeys
to NodeListOf