This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use single node XPath where appropriate
- Loading branch information
1 parent
e480bfe
commit 671d5c6
Showing
9 changed files
with
147 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @package */ | ||
export interface NamespaceResolver { | ||
lookupNamespaceURI(prefix: string): string | null; | ||
} | ||
|
||
/** @package */ | ||
export class XPathResult { | ||
static FIRST_ORDERED_NODE_TYPE: number; | ||
static ORDERED_NODE_SNAPSHOT_TYPE: number; | ||
readonly singleNodeValue: Node | null; | ||
snapshotItem(index: number): Node | null; | ||
readonly snapshotLength: number; | ||
} | ||
|
||
export type XPathResultType = number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { DOM } from '../abstract'; | ||
|
||
/** @package */ | ||
export class XPathResult implements DOM.XPathResult { | ||
static ORDERED_NODE_SNAPSHOT_TYPE = 6 as const; | ||
|
||
static FIRST_ORDERED_NODE_TYPE = 9 as const; | ||
|
||
get singleNodeValue() { | ||
return this.results[0] ?? null; | ||
} | ||
|
||
get snapshotLength() { | ||
return this.results.length; | ||
} | ||
|
||
constructor(private results: Node[]) {} | ||
|
||
snapshotItem(index: number) { | ||
return this.results[index]; | ||
} | ||
} | ||
|
||
type XPathResultTypeKeys = { | ||
[K in keyof XPathResult]: K extends `${string}_TYPE` ? K : never; | ||
}[keyof XPathResult]; | ||
|
||
/** @package */ | ||
export type XPathResultType = XPathResult[XPathResultTypeKeys]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { DOM } from '../abstract'; | ||
|
||
/** @package */ | ||
export const XPathResult = | ||
globalThis.XPathResult satisfies new () => DOM.XPathResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './DOMParser'; | ||
export * from './XPathResult'; | ||
export * from './XSLTProcessor'; |
Oops, something went wrong.