mount-observer 0.0.99 → 0.0.100
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/package.json +1 -1
- package/refid/genIds.js +16 -4
- package/refid/genIds.ts +13 -5
package/package.json
CHANGED
package/refid/genIds.js
CHANGED
|
@@ -20,7 +20,10 @@ export function genIds(enhancedElement) {
|
|
|
20
20
|
// if(parentElement === null) throw 404;
|
|
21
21
|
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode());
|
|
22
22
|
//first find all elements with attribute #
|
|
23
|
-
const
|
|
23
|
+
const hashTest = '[\\#]';
|
|
24
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll(hashTest)).filter(x => inScope(scopeFragment, x));
|
|
25
|
+
if (scopeFragment instanceof Element && scopeFragment.matches(hashTest))
|
|
26
|
+
hashIds.push(scopeFragment);
|
|
24
27
|
const uniqueCheck = new Set();
|
|
25
28
|
for (const hi of hashIds) {
|
|
26
29
|
if (!(hi instanceof HTMLElement))
|
|
@@ -38,7 +41,10 @@ export function genIds(enhancedElement) {
|
|
|
38
41
|
hi.removeAttribute('#');
|
|
39
42
|
}
|
|
40
43
|
//now find all elements with attribute @
|
|
41
|
-
const
|
|
44
|
+
const nameTest = '[name]:not([name=""])[\\@]';
|
|
45
|
+
const names = Array.from(scopeFragment.querySelectorAll(nameTest)).filter(x => inScope(scopeFragment, x));
|
|
46
|
+
if (scopeFragment instanceof Element && scopeFragment.matches(nameTest))
|
|
47
|
+
names.push(scopeFragment);
|
|
42
48
|
for (const nameEl of names) {
|
|
43
49
|
if (!(nameEl instanceof HTMLElement))
|
|
44
50
|
continue;
|
|
@@ -55,7 +61,10 @@ export function genIds(enhancedElement) {
|
|
|
55
61
|
nameEl.removeAttribute('@');
|
|
56
62
|
}
|
|
57
63
|
//now find all elements with attribute |
|
|
58
|
-
const
|
|
64
|
+
const itemScopeTest = '[itemprop]:not([itemprop=""])[\\|]';
|
|
65
|
+
const itemprops = Array.from(scopeFragment.querySelectorAll(itemScopeTest)).filter(x => inScope(scopeFragment, x));
|
|
66
|
+
if (scopeFragment instanceof Element && scopeFragment.matches(itemScopeTest))
|
|
67
|
+
itemprops.push(scopeFragment);
|
|
59
68
|
for (const itempropEl of itemprops) {
|
|
60
69
|
if (!(itempropEl instanceof HTMLElement))
|
|
61
70
|
continue;
|
|
@@ -71,7 +80,10 @@ export function genIds(enhancedElement) {
|
|
|
71
80
|
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
72
81
|
itempropEl.removeAttribute('|');
|
|
73
82
|
}
|
|
74
|
-
const
|
|
83
|
+
const dataIdTest = '[data-id^="{{"][data-id$="}}"]';
|
|
84
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll(dataIdTest)).filter(x => inScope(scopeFragment, x));
|
|
85
|
+
if (scopeFragment instanceof Element && scopeFragment.matches(dataIdTest))
|
|
86
|
+
dataIds.push(scopeFragment);
|
|
75
87
|
const ids = [];
|
|
76
88
|
for (const di of dataIds) {
|
|
77
89
|
if (!(di instanceof HTMLElement))
|
package/refid/genIds.ts
CHANGED
|
@@ -22,7 +22,9 @@ export function genIds(enhancedElement: Element){
|
|
|
22
22
|
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode()) as DocumentFragment | Element;
|
|
23
23
|
|
|
24
24
|
//first find all elements with attribute #
|
|
25
|
-
const
|
|
25
|
+
const hashTest = '[\\#]';
|
|
26
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll(hashTest)).filter(x => inScope(scopeFragment, x));
|
|
27
|
+
if(scopeFragment instanceof Element && scopeFragment.matches(hashTest)) hashIds.push(scopeFragment);
|
|
26
28
|
const uniqueCheck = new Set();
|
|
27
29
|
for(const hi of hashIds){
|
|
28
30
|
if(!(hi instanceof HTMLElement)) continue;
|
|
@@ -39,7 +41,9 @@ export function genIds(enhancedElement: Element){
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
//now find all elements with attribute @
|
|
42
|
-
const
|
|
44
|
+
const nameTest = '[name]:not([name=""])[\\@]';
|
|
45
|
+
const names = Array.from(scopeFragment.querySelectorAll(nameTest)).filter(x => inScope(scopeFragment, x));
|
|
46
|
+
if(scopeFragment instanceof Element && scopeFragment.matches(nameTest)) names.push(scopeFragment);
|
|
43
47
|
for(const nameEl of names){
|
|
44
48
|
if(!(nameEl instanceof HTMLElement)) continue;
|
|
45
49
|
const val = nameEl.getAttribute('name');
|
|
@@ -55,7 +59,9 @@ export function genIds(enhancedElement: Element){
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
//now find all elements with attribute |
|
|
58
|
-
const
|
|
62
|
+
const itemScopeTest = '[itemprop]:not([itemprop=""])[\\|]';
|
|
63
|
+
const itemprops = Array.from(scopeFragment.querySelectorAll(itemScopeTest)).filter(x => inScope(scopeFragment, x));
|
|
64
|
+
if(scopeFragment instanceof Element && scopeFragment.matches(itemScopeTest)) itemprops.push(scopeFragment);
|
|
59
65
|
for(const itempropEl of itemprops){
|
|
60
66
|
if(!(itempropEl instanceof HTMLElement)) continue;
|
|
61
67
|
const val = itempropEl.getAttribute('itemprop');
|
|
@@ -69,8 +75,9 @@ export function genIds(enhancedElement: Element){
|
|
|
69
75
|
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
70
76
|
itempropEl.removeAttribute('|');
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
const dataIds = Array.from(scopeFragment.querySelectorAll(
|
|
78
|
+
const dataIdTest = '[data-id^="{{"][data-id$="}}"]';
|
|
79
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll(dataIdTest)).filter(x => inScope(scopeFragment, x));
|
|
80
|
+
if(scopeFragment instanceof Element && scopeFragment.matches(dataIdTest)) dataIds.push(scopeFragment);
|
|
74
81
|
const ids: Array<string> = [];
|
|
75
82
|
for(const di of dataIds){
|
|
76
83
|
if(!(di instanceof HTMLElement)) continue;
|
|
@@ -83,6 +90,7 @@ export function genIds(enhancedElement: Element){
|
|
|
83
90
|
ids.push(id);
|
|
84
91
|
}
|
|
85
92
|
if(ids.length === 0) return;
|
|
93
|
+
|
|
86
94
|
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
87
95
|
if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
|
|
88
96
|
|