mount-observer 0.0.96 → 0.0.98
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 +24 -4
- package/refid/genIds.ts +22 -5
package/package.json
CHANGED
package/refid/genIds.js
CHANGED
|
@@ -25,16 +25,16 @@ export function genIds(enhancedElement) {
|
|
|
25
25
|
for (const hi of hashIds) {
|
|
26
26
|
if (!(hi instanceof HTMLElement))
|
|
27
27
|
continue;
|
|
28
|
-
const
|
|
29
|
-
if (uniqueCheck.has(
|
|
28
|
+
const idName = hi.getAttribute('itemscope') || hi.localName;
|
|
29
|
+
if (uniqueCheck.has(idName))
|
|
30
30
|
throw 500;
|
|
31
|
-
uniqueCheck.add(
|
|
31
|
+
uniqueCheck.add(idName);
|
|
32
32
|
let sideEffects = '';
|
|
33
33
|
const hashValue = hi.getAttribute('#');
|
|
34
34
|
if (hashValue) {
|
|
35
35
|
sideEffects = `${hashValue} `;
|
|
36
36
|
}
|
|
37
|
-
hi.dataset.id = `{{${sideEffects}${
|
|
37
|
+
hi.dataset.id = `{{${sideEffects}${idName}}}`;
|
|
38
38
|
hi.removeAttribute('#');
|
|
39
39
|
}
|
|
40
40
|
//now find all elements with attribute @
|
|
@@ -52,6 +52,24 @@ export function genIds(enhancedElement) {
|
|
|
52
52
|
sideEffects = `${nameValue} `;
|
|
53
53
|
}
|
|
54
54
|
nameEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
55
|
+
nameEl.removeAttribute('@');
|
|
56
|
+
}
|
|
57
|
+
//now find all elements with attribute |
|
|
58
|
+
const itemprops = Array.from(scopeFragment.querySelectorAll('[itemprop]:not([itemprop=""])[\\|]')).filter(x => inScope(scopeFragment, x));
|
|
59
|
+
for (const itempropEl of itemprops) {
|
|
60
|
+
if (!(itempropEl instanceof HTMLElement))
|
|
61
|
+
continue;
|
|
62
|
+
const val = itempropEl.getAttribute('itemprop');
|
|
63
|
+
if (uniqueCheck.has(val))
|
|
64
|
+
throw 500;
|
|
65
|
+
uniqueCheck.add(val);
|
|
66
|
+
let sideEffects = '';
|
|
67
|
+
const nameValue = itempropEl.getAttribute('|');
|
|
68
|
+
if (nameValue) {
|
|
69
|
+
sideEffects = `${nameValue} `;
|
|
70
|
+
}
|
|
71
|
+
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
72
|
+
itempropEl.removeAttribute('|');
|
|
55
73
|
}
|
|
56
74
|
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
57
75
|
const ids = [];
|
|
@@ -68,6 +86,8 @@ export function genIds(enhancedElement) {
|
|
|
68
86
|
throw 500;
|
|
69
87
|
ids.push(id);
|
|
70
88
|
}
|
|
89
|
+
if (ids.length === 0)
|
|
90
|
+
return;
|
|
71
91
|
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
72
92
|
if (scopeFragment instanceof Element)
|
|
73
93
|
allChildren.push(scopeFragment);
|
package/refid/genIds.ts
CHANGED
|
@@ -26,15 +26,15 @@ export function genIds(enhancedElement: Element){
|
|
|
26
26
|
const uniqueCheck = new Set();
|
|
27
27
|
for(const hi of hashIds){
|
|
28
28
|
if(!(hi instanceof HTMLElement)) continue;
|
|
29
|
-
const
|
|
30
|
-
if(uniqueCheck.has(
|
|
31
|
-
uniqueCheck.add(
|
|
29
|
+
const idName = hi.getAttribute('itemscope') || hi.localName;
|
|
30
|
+
if(uniqueCheck.has(idName)) throw 500;
|
|
31
|
+
uniqueCheck.add(idName);
|
|
32
32
|
let sideEffects = '';
|
|
33
33
|
const hashValue = hi.getAttribute('#');
|
|
34
34
|
if(hashValue){
|
|
35
35
|
sideEffects = `${hashValue} `;
|
|
36
36
|
}
|
|
37
|
-
hi.dataset.id = `{{${sideEffects}${
|
|
37
|
+
hi.dataset.id = `{{${sideEffects}${idName}}}`;
|
|
38
38
|
hi.removeAttribute('#');
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -51,6 +51,23 @@ export function genIds(enhancedElement: Element){
|
|
|
51
51
|
sideEffects = `${nameValue} `;
|
|
52
52
|
}
|
|
53
53
|
nameEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
54
|
+
nameEl.removeAttribute('@');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//now find all elements with attribute |
|
|
58
|
+
const itemprops = Array.from(scopeFragment.querySelectorAll('[itemprop]:not([itemprop=""])[\\|]')).filter(x => inScope(scopeFragment, x));
|
|
59
|
+
for(const itempropEl of itemprops){
|
|
60
|
+
if(!(itempropEl instanceof HTMLElement)) continue;
|
|
61
|
+
const val = itempropEl.getAttribute('itemprop');
|
|
62
|
+
if(uniqueCheck.has(val)) throw 500;
|
|
63
|
+
uniqueCheck.add(val);
|
|
64
|
+
let sideEffects = '';
|
|
65
|
+
const nameValue = itempropEl.getAttribute('|');
|
|
66
|
+
if(nameValue){
|
|
67
|
+
sideEffects = `${nameValue} `;
|
|
68
|
+
}
|
|
69
|
+
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
70
|
+
itempropEl.removeAttribute('|');
|
|
54
71
|
}
|
|
55
72
|
|
|
56
73
|
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
@@ -65,7 +82,7 @@ export function genIds(enhancedElement: Element){
|
|
|
65
82
|
if(ids.includes(id)) throw 500;
|
|
66
83
|
ids.push(id);
|
|
67
84
|
}
|
|
68
|
-
|
|
85
|
+
if(ids.length === 0) return;
|
|
69
86
|
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
70
87
|
if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
|
|
71
88
|
|