From 94e89014f8aff0856fe3d431068200d2c5f8e2cf Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 9 Aug 2024 01:48:02 +0200 Subject: [PATCH 1/2] initial commit --- src/dom/node-list.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dom/node-list.ts b/src/dom/node-list.ts index c703329..c767e04 100644 --- a/src/dom/node-list.ts +++ b/src/dom/node-list.ts @@ -194,13 +194,13 @@ for ( export interface NodeList { new (): NodeList; - readonly [index: number]: Node; + readonly [index: number]: T; readonly length: number; - [Symbol.iterator](): Generator; + [Symbol.iterator](): Generator; - item(index: number): Node; + item(index: number): T; forEach( - cb: (node: Node, index: number, nodeList: Node[]) => void, + cb: (node: T, index: number, nodeList: T[]) => void, thisArg?: NodeList | undefined, ): void; [nodeListMutatorSym](): NodeListMutator; From cf88528a5e8fccf5650360d4cb50933a6be7e0e4 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 12 Aug 2024 20:00:43 +0200 Subject: [PATCH 2/2] update --- src/dom/document.ts | 6 ++++-- src/dom/element.ts | 6 ++++-- src/dom/node-list.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dom/document.ts b/src/dom/document.ts index 4df33e4..8903962 100644 --- a/src/dom/document.ts +++ b/src/dom/document.ts @@ -311,7 +311,9 @@ export class Document extends Node { return this._nwapi.first(selectors, this) as T; } - querySelectorAll(selectors: string): NodeList { + querySelectorAll( + selectors: string, + ): NodeList { const nodeList = new NodeList(); const mutator = nodeList[nodeListMutatorSym](); @@ -319,7 +321,7 @@ export class Document extends Node { mutator.push(match); } - return nodeList; + return nodeList as NodeList; } // TODO: DRY!!! diff --git a/src/dom/element.ts b/src/dom/element.ts index b24f57b..6a0e186 100644 --- a/src/dom/element.ts +++ b/src/dom/element.ts @@ -904,7 +904,9 @@ export class Element extends Node { return this.ownerDocument!._nwapi.first(selectors, this) as T; } - querySelectorAll(selectors: string): NodeList { + querySelectorAll( + selectors: string, + ): NodeList { if (!this.ownerDocument) { throw new Error("Element must have an owner document"); } @@ -916,7 +918,7 @@ export class Element extends Node { mutator.push(match); } - return nodeList; + return nodeList as NodeList; } matches(selectorString: string): boolean { diff --git a/src/dom/node-list.ts b/src/dom/node-list.ts index c767e04..e6ddd32 100644 --- a/src/dom/node-list.ts +++ b/src/dom/node-list.ts @@ -192,7 +192,7 @@ for ( NodeListClass.prototype[instanceMethod] = undefined; } -export interface NodeList { +export interface NodeList { new (): NodeList; readonly [index: number]: T; readonly length: number;