mount-observer 0.0.108 → 0.0.109
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/ism.js +12 -12
- package/refid/ism.ts +12 -12
- package/ts-refs/be-parsing/types.d.ts +1 -1
package/package.json
CHANGED
package/refid/ism.js
CHANGED
|
@@ -8,8 +8,8 @@ Object.defineProperty(HTMLElement.prototype, 'ism', {
|
|
|
8
8
|
return parse(el);
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const
|
|
12
|
-
export function parse(el, obj = {},
|
|
11
|
+
const parsedItempropMaps = new WeakMap();
|
|
12
|
+
export function parse(el, obj = {}, scopedLists = {}) {
|
|
13
13
|
const itemprop = el.getAttribute('itemprop');
|
|
14
14
|
if (itemprop) {
|
|
15
15
|
obj[itemprop] = stdVal(el); //TODO full logic
|
|
@@ -20,10 +20,10 @@ export function parse(el, obj = {}, itemscopeMap = {}) {
|
|
|
20
20
|
const jsonEl = upShadowSearch(el, itempropmap);
|
|
21
21
|
if (!jsonEl)
|
|
22
22
|
throw 500;
|
|
23
|
-
if (!
|
|
24
|
-
|
|
23
|
+
if (!parsedItempropMaps.has(jsonEl)) {
|
|
24
|
+
parsedItempropMaps.set(jsonEl, JSON.parse(jsonEl.innerHTML));
|
|
25
25
|
}
|
|
26
|
-
const parsed = /** @type {ItemPropMap} */ (
|
|
26
|
+
const parsed = /** @type {ItemPropMap} */ (parsedItempropMaps.get(jsonEl));
|
|
27
27
|
for (const key in parsed) {
|
|
28
28
|
const attr = el.getAttribute(key);
|
|
29
29
|
if (attr === null)
|
|
@@ -52,8 +52,8 @@ export function parse(el, obj = {}, itemscopeMap = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
//el.ish = obj;
|
|
54
54
|
const children = Array.from(el.children);
|
|
55
|
-
const isItemScoped = el.hasAttribute('itemscope');
|
|
56
|
-
let itemscopeMapToPass =
|
|
55
|
+
//const isItemScoped = el.hasAttribute('itemscope');
|
|
56
|
+
let itemscopeMapToPass = scopedLists;
|
|
57
57
|
for (const child of children) {
|
|
58
58
|
if (!(child instanceof HTMLElement))
|
|
59
59
|
continue;
|
|
@@ -63,13 +63,13 @@ export function parse(el, obj = {}, itemscopeMap = {}) {
|
|
|
63
63
|
itemscopeMapToPass = {};
|
|
64
64
|
}
|
|
65
65
|
parse(child, objToPass, itemscopeMapToPass);
|
|
66
|
-
const isItemScopeAndChildHasBothItempropAndItemscope =
|
|
66
|
+
const isItemScopeAndChildHasBothItempropAndItemscope = scopedLists && child.hasAttribute('itemprop') && child.hasAttribute('itemscope');
|
|
67
67
|
if (isItemScopeAndChildHasBothItempropAndItemscope) {
|
|
68
68
|
const itemprops = child.getAttribute('itemprop').split(" ").filter(x => x);
|
|
69
69
|
for (const itemprop of itemprops) {
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
if (!scopedLists[itemprop])
|
|
71
|
+
scopedLists[itemprop] = [];
|
|
72
|
+
scopedLists[itemprop].push(objToPass);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -78,6 +78,6 @@ export function parse(el, obj = {}, itemscopeMap = {}) {
|
|
|
78
78
|
// }
|
|
79
79
|
return {
|
|
80
80
|
obj,
|
|
81
|
-
|
|
81
|
+
scopedLists
|
|
82
82
|
};
|
|
83
83
|
}
|
package/refid/ism.ts
CHANGED
|
@@ -9,11 +9,11 @@ Object.defineProperty(HTMLElement.prototype, 'ism', {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
type
|
|
12
|
+
type ScopedLists = {[key: string] : any[]}
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const parsedItempropMaps = new WeakMap<HTMLScriptElement, any>();
|
|
15
15
|
|
|
16
|
-
export function parse(el: HTMLElement, obj: any = {},
|
|
16
|
+
export function parse(el: HTMLElement, obj: any = {}, scopedLists: ScopedLists = {}){
|
|
17
17
|
const itemprop = el.getAttribute('itemprop');
|
|
18
18
|
if(itemprop){
|
|
19
19
|
obj[itemprop] = stdVal(el); //TODO full logic
|
|
@@ -23,10 +23,10 @@ export function parse(el: HTMLElement, obj: any = {}, itemscopeMap: ItemscopeMap
|
|
|
23
23
|
//const el = document.getElementById(itempropmap);
|
|
24
24
|
const jsonEl = upShadowSearch(el, itempropmap)
|
|
25
25
|
if(!jsonEl) throw 500;
|
|
26
|
-
if(!
|
|
27
|
-
|
|
26
|
+
if(!parsedItempropMaps.has(jsonEl)){
|
|
27
|
+
parsedItempropMaps.set(jsonEl, JSON.parse(jsonEl.innerHTML));
|
|
28
28
|
}
|
|
29
|
-
const parsed =/** @type {ItemPropMap} */ (
|
|
29
|
+
const parsed =/** @type {ItemPropMap} */ (parsedItempropMaps.get(jsonEl));
|
|
30
30
|
for(const key in parsed){
|
|
31
31
|
const attr = el.getAttribute(key);
|
|
32
32
|
if(attr === null) continue;
|
|
@@ -57,8 +57,8 @@ export function parse(el: HTMLElement, obj: any = {}, itemscopeMap: ItemscopeMap
|
|
|
57
57
|
}
|
|
58
58
|
//el.ish = obj;
|
|
59
59
|
const children = Array.from(el.children);
|
|
60
|
-
const isItemScoped = el.hasAttribute('itemscope');
|
|
61
|
-
let itemscopeMapToPass =
|
|
60
|
+
//const isItemScoped = el.hasAttribute('itemscope');
|
|
61
|
+
let itemscopeMapToPass = scopedLists;
|
|
62
62
|
for(const child of children){
|
|
63
63
|
if(!(child instanceof HTMLElement)) continue;
|
|
64
64
|
const childHasItemScopeAttr = child.hasAttribute('itemscope')
|
|
@@ -67,12 +67,12 @@ export function parse(el: HTMLElement, obj: any = {}, itemscopeMap: ItemscopeMap
|
|
|
67
67
|
itemscopeMapToPass = {};
|
|
68
68
|
}
|
|
69
69
|
parse(child, objToPass, itemscopeMapToPass);
|
|
70
|
-
const isItemScopeAndChildHasBothItempropAndItemscope =
|
|
70
|
+
const isItemScopeAndChildHasBothItempropAndItemscope = scopedLists && child.hasAttribute('itemprop') && child.hasAttribute('itemscope');
|
|
71
71
|
if(isItemScopeAndChildHasBothItempropAndItemscope){
|
|
72
72
|
const itemprops = child.getAttribute('itemprop')!.split(" ").filter(x => x);
|
|
73
73
|
for(const itemprop of itemprops){
|
|
74
|
-
if(!
|
|
75
|
-
|
|
74
|
+
if(!scopedLists![itemprop]) scopedLists![itemprop] = [];
|
|
75
|
+
scopedLists![itemprop].push(objToPass);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -81,6 +81,6 @@ export function parse(el: HTMLElement, obj: any = {}, itemscopeMap: ItemscopeMap
|
|
|
81
81
|
// }
|
|
82
82
|
return {
|
|
83
83
|
obj,
|
|
84
|
-
|
|
84
|
+
scopedLists
|
|
85
85
|
};
|
|
86
86
|
}
|