@markuplint/selector 4.0.0 → 4.1.0
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/lib/is.d.ts +9 -0
- package/lib/is.js +9 -0
- package/lib/selector.js +2 -2
- package/package.json +3 -3
package/lib/is.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare function isElement(node: Node): node is Element;
|
|
2
2
|
export declare function isNonDocumentTypeChildNode(node: Node): node is Element | CharacterData;
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the given element is a pure HTML element.
|
|
5
|
+
*
|
|
6
|
+
* If a pure HTML element, `localName` returns lowercase,
|
|
7
|
+
* `nodeName` returns uppercase.
|
|
8
|
+
*
|
|
9
|
+
* @param el The element to check.
|
|
10
|
+
* @returns Returns true if the element is a pure HTML element, otherwise returns false.
|
|
11
|
+
*/
|
|
3
12
|
export declare function isPureHTMLElement(el: Element): boolean;
|
package/lib/is.js
CHANGED
|
@@ -8,6 +8,15 @@ export function isNonDocumentTypeChildNode(
|
|
|
8
8
|
node) {
|
|
9
9
|
return 'previousElementSibling' in node && 'nextElementSibling' in node;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the given element is a pure HTML element.
|
|
13
|
+
*
|
|
14
|
+
* If a pure HTML element, `localName` returns lowercase,
|
|
15
|
+
* `nodeName` returns uppercase.
|
|
16
|
+
*
|
|
17
|
+
* @param el The element to check.
|
|
18
|
+
* @returns Returns true if the element is a pure HTML element, otherwise returns false.
|
|
19
|
+
*/
|
|
11
20
|
export function isPureHTMLElement(
|
|
12
21
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
22
|
el) {
|
package/lib/selector.js
CHANGED
|
@@ -28,7 +28,7 @@ export class Selector {
|
|
|
28
28
|
el,
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
30
30
|
scope) {
|
|
31
|
-
scope = isElement(el) ? el : null;
|
|
31
|
+
scope = scope ?? (isElement(el) ? el : null);
|
|
32
32
|
const results = this.search(el, scope);
|
|
33
33
|
for (const result of results) {
|
|
34
34
|
if (result.matched) {
|
|
@@ -42,7 +42,7 @@ export class Selector {
|
|
|
42
42
|
el,
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
44
44
|
scope) {
|
|
45
|
-
scope = isElement(el) ? el : null;
|
|
45
|
+
scope = scope ?? (isElement(el) ? el : null);
|
|
46
46
|
return __classPrivateFieldGet(this, _Selector_ruleset, "f").match(el, scope);
|
|
47
47
|
}
|
|
48
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/selector",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Extended W3C Selectors matcher",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"clean": "tsc --build --clean"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@markuplint/ml-spec": "4.0.
|
|
28
|
+
"@markuplint/ml-spec": "4.0.1",
|
|
29
29
|
"@types/debug": "^4.1.12",
|
|
30
30
|
"debug": "^4.3.4",
|
|
31
31
|
"postcss-selector-parser": "^6.0.15",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"@types/jsdom": "21.1.6",
|
|
36
36
|
"jsdom": "24.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b9817c30c2df71faa866e3b3fe286afa499deede"
|
|
39
39
|
}
|