@asamuzakjp/dom-selector 8.0.1 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -155
- package/package.json +18 -11
- package/src/index.js +132 -66
- package/src/js/constant.js +106 -4
- package/src/js/finder.js +1149 -1049
- package/src/js/matcher.js +59 -24
- package/src/js/nwsapi.js +29 -11
- package/src/js/parser.js +16 -7
- package/src/js/selector.js +325 -0
- package/src/js/utility.js +155 -349
- package/types/index.d.ts +2 -1
- package/types/js/constant.d.ts +6 -0
- package/types/js/finder.d.ts +4 -1
- package/types/js/matcher.d.ts +2 -2
- package/types/js/parser.d.ts +1 -1
- package/types/js/selector.d.ts +12 -0
- package/types/js/utility.d.ts +5 -12
package/types/js/constant.d.ts
CHANGED
|
@@ -54,12 +54,15 @@ export const DESCEND: "\\s?[\\s>]\\s?";
|
|
|
54
54
|
export const SIBLING: "\\s?[+~]\\s?";
|
|
55
55
|
export const LOGIC_IS: ":is\\(\\s*[^)]+\\s*\\)";
|
|
56
56
|
export const N_TH: "nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*))\\s*\\)";
|
|
57
|
+
export const ATTR_TYPE: "\\[[^|\\]]+\\]";
|
|
57
58
|
export const SUB_TYPE: "\\[[^|\\]]+\\]|[#.:][\\w-]+";
|
|
58
59
|
export const SUB_TYPE_WO_PSEUDO: "\\[[^|\\]]+\\]|[#.][\\w-]+";
|
|
60
|
+
export const TAG_TYPE_WO_UNIVERSAL: "[A-Za-z][\\w-]*";
|
|
59
61
|
export const TAG_TYPE: "\\*|[A-Za-z][\\w-]*";
|
|
60
62
|
export const TAG_TYPE_I: "\\*|[A-Z][\\w-]*";
|
|
61
63
|
export const COMPOUND: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)";
|
|
62
64
|
export const COMPOUND_L: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*[^)]+\\s*\\))+)";
|
|
65
|
+
export const COMPOUND_L_I: "(?:(?:\\*|[A-Z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*[^)]+\\s*\\))+)";
|
|
63
66
|
export const COMPOUND_I: "(?:\\*|[A-Z][\\w-]*|(?:\\*|[A-Z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)";
|
|
64
67
|
export const COMPOUND_WO_PSEUDO: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.][\\w-]+)+)";
|
|
65
68
|
export const COMPLEX: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*";
|
|
@@ -75,3 +78,6 @@ export const INPUT_TEXT: readonly string[];
|
|
|
75
78
|
export const INPUT_EDIT: readonly string[];
|
|
76
79
|
export const INPUT_LTR: readonly string[];
|
|
77
80
|
export const KEYS_LOGICAL: Set<string>;
|
|
81
|
+
export const KEYS_PS_CLASS_SUPPORTED: Set<string>;
|
|
82
|
+
export const KEYS_PS_CLASS_UNSUPPORTED: Set<string>;
|
|
83
|
+
export const KEYS_PS_ELEMENT_UNSUPPORTED: Set<string>;
|
package/types/js/finder.d.ts
CHANGED
|
@@ -22,12 +22,15 @@ export class Finder {
|
|
|
22
22
|
private _collectNthOfType;
|
|
23
23
|
private _matchAnPlusB;
|
|
24
24
|
private _matchHasPseudoFunc;
|
|
25
|
+
private _buildHasAllowlist;
|
|
25
26
|
private _evaluateHasPseudo;
|
|
26
27
|
private _matchLogicalPseudoFunc;
|
|
28
|
+
private _evaluateLogicalPseudo;
|
|
29
|
+
private _evaluatePseudoClassFunc;
|
|
27
30
|
private _matchPseudoClassSelector;
|
|
28
31
|
private _evaluateHostPseudo;
|
|
29
32
|
private _evaluateHostContextPseudo;
|
|
30
|
-
private
|
|
33
|
+
private _evaluateShadowHost;
|
|
31
34
|
private _matchSelectorForElement;
|
|
32
35
|
private _matchSelectorForShadowRoot;
|
|
33
36
|
private _matchSelector;
|
package/types/js/matcher.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export function matchPseudoElementSelector(astName: string, astType: string, { f
|
|
|
3
3
|
globalObject?: object | undefined;
|
|
4
4
|
warn?: boolean | undefined;
|
|
5
5
|
}): void;
|
|
6
|
-
export function matchDirectionPseudoClass(ast: object, node: object): boolean;
|
|
7
|
-
export function matchLanguagePseudoClass(ast: object, node: object): boolean;
|
|
6
|
+
export function matchDirectionPseudoClass(ast: object, node: object, dirCache?: WeakMap<any, any>): boolean;
|
|
7
|
+
export function matchLanguagePseudoClass(ast: object, node: object, langCache?: WeakMap<any, any>): boolean;
|
|
8
8
|
export function matchDisabledPseudoClass(astName: string, node: object): boolean;
|
|
9
9
|
export function matchReadOnlyPseudoClass(astName: string, node: object): boolean;
|
|
10
10
|
export function matchAttributeSelector(ast: object, node: object, { check, forgive, globalObject }?: {
|
package/types/js/parser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function unescapeSelector(selector?: string): string;
|
|
2
2
|
export function preprocess(value: string): string;
|
|
3
3
|
export function parseSelector(sel: string): object;
|
|
4
|
-
export function walkAST(ast?: object, toObject?: boolean): {
|
|
4
|
+
export function walkAST(ast?: object, toObject?: boolean, callback?: (arg0: object) => void): {
|
|
5
5
|
branches: Array<object>;
|
|
6
6
|
info: object;
|
|
7
7
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function findNestedHas(leaf: object): object | null;
|
|
2
|
+
export function findLogicalWithNestedHas(leaf: object): object | null;
|
|
3
|
+
export function validateHasNesting(astChildren: Array<object>): boolean;
|
|
4
|
+
export function createHasValidator(globalObj: object): (arg0: object) => void;
|
|
5
|
+
export function isInvalidCombinator(type: string, prevType: string | null, isLast: boolean): boolean;
|
|
6
|
+
export function isSupportedAST(ast: object): boolean;
|
|
7
|
+
export function extractSubjectsRegExp(selector: string, caseSensitive: boolean): Array<{
|
|
8
|
+
id: string | null;
|
|
9
|
+
className: string | null;
|
|
10
|
+
tag: string | null;
|
|
11
|
+
}>;
|
|
12
|
+
export function filterSelector(selector: string, target: string): boolean;
|
package/types/js/utility.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export function getType(o: object): string;
|
|
2
2
|
export function verifyArray(arr: any[], type: string): any[];
|
|
3
3
|
export function generateException(msg: string, name: string, globalObject?: object): DOMException;
|
|
4
|
-
export function findNestedHas(leaf: object): object | null;
|
|
5
|
-
export function findLogicalWithNestedHas(leaf: object): object | null;
|
|
6
4
|
export function filterNodesByAnB(nodes: Array<object>, anb: {
|
|
7
5
|
a: number;
|
|
8
6
|
b: number;
|
|
@@ -14,8 +12,8 @@ export function isCustomElement(node: object, { formAssociated }?: {
|
|
|
14
12
|
formAssociated?: boolean | undefined;
|
|
15
13
|
}): boolean;
|
|
16
14
|
export function getSlottedTextContent(node: object): string | null;
|
|
17
|
-
export function getDirectionality(node: object): string | null;
|
|
18
|
-
export function getLanguageAttribute(node: object): string | null;
|
|
15
|
+
export function getDirectionality(node: object, dirCache?: WeakMap<any, any>): string | null;
|
|
16
|
+
export function getLanguageAttribute(node: object, langCache?: WeakMap<any, any>): string | null;
|
|
19
17
|
export function isContentEditable(node: object): boolean;
|
|
20
18
|
export function isVisible(node: object): boolean;
|
|
21
19
|
export function isFocusVisible(node: object): boolean;
|
|
@@ -26,11 +24,6 @@ export function isNamespaceDeclared(ns?: string, node?: object): boolean;
|
|
|
26
24
|
export function isPreceding(nodeA: object, nodeB: object): boolean;
|
|
27
25
|
export function compareNodes(a: object, b: object): number;
|
|
28
26
|
export function sortNodes(nodes?: Array<object> | Set<object>): Array<object>;
|
|
29
|
-
export function
|
|
30
|
-
export function
|
|
31
|
-
export function
|
|
32
|
-
id: string | null;
|
|
33
|
-
className: string | null;
|
|
34
|
-
tag: string | null;
|
|
35
|
-
}>;
|
|
36
|
-
export function filterSelector(selector: string, target: string): boolean;
|
|
27
|
+
export function findBestSeed(nodes: any[], state?: object): object;
|
|
28
|
+
export function populateHasAllowlist(current: object, list: WeakSet<any>, visitedAncestors: Set<any>): void;
|
|
29
|
+
export function collectAllDescendants(node: Document | DocumentFragment | Element, document: Document): Array<Element>;
|