Added entries, foreach, values and keys to NodeListOf#14641
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. |
| } | ||
|
|
||
| interface NodeListOf<TNode extends Node> { | ||
| keys(): IterableIterator<number>; |
There was a problem hiding this comment.
i would add it also to NodeList.
|
|
||
| interface NodeList { | ||
| keys(): IterableIterator<number>; | ||
| values(): IterableIterator<[number, Node]>; |
There was a problem hiding this comment.
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>;
}| keys(): IterableIterator<number>; | ||
| values(): IterableIterator<[number, Node]>; | ||
| entries(): IterableIterator<Node>; | ||
| forEach(): void; |
There was a problem hiding this comment.
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;| 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.
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,valuesandkeysto NodeListOf