mount-observer 0.0.111 → 0.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/Events.js +28 -26
- package/Events.ts +34 -30
- package/MountObserver.js +235 -520
- package/MountObserver.ts +281 -542
- package/README.md +149 -56
- package/attrCoordinates.js +93 -0
- package/attrCoordinates.ts +122 -0
- package/constants.js +6 -0
- package/constants.ts +7 -0
- package/index.js +3 -0
- package/index.ts +19 -0
- package/loadImports.js +47 -0
- package/loadImports.ts +56 -0
- package/package.json +8 -115
- package/playwright.config.ts +0 -1
- package/types.d.ts +86 -0
- package/whereAttr.js +174 -0
- package/whereAttr.ts +221 -0
- package/LICENSE +0 -21
- package/Newish.js +0 -145
- package/Newish.ts +0 -169
- package/ObsAttr.js +0 -18
- package/ObsAttr.ts +0 -18
- package/RootMutObs.js +0 -49
- package/RootMutObs.ts +0 -58
- package/Synthesizer.js +0 -125
- package/Synthesizer.ts +0 -130
- package/bindish.js +0 -15
- package/bindish.ts +0 -22
- package/compose.js +0 -148
- package/compose.ts +0 -164
- package/doCleanup.js +0 -31
- package/doCleanup.ts +0 -34
- package/getWhereAttrSelector.js +0 -83
- package/getWhereAttrSelector.ts +0 -92
- package/preloadContent.js +0 -44
- package/preloadContent.ts +0 -47
- package/readAttrs.ts +0 -60
- package/refid/README.md +0 -259
- package/refid/arr.js +0 -4
- package/refid/arr.ts +0 -4
- package/refid/camelToKebab.js +0 -4
- package/refid/camelToKebab.ts +0 -4
- package/refid/genIds.js +0 -190
- package/refid/genIds.ts +0 -177
- package/refid/getAdjRefs.js +0 -38
- package/refid/getAdjRefs.ts +0 -38
- package/refid/getContext.js +0 -13
- package/refid/getContext.ts +0 -14
- package/refid/getCount.js +0 -8
- package/refid/getCount.ts +0 -8
- package/refid/getIsh.js +0 -35
- package/refid/getIsh.ts +0 -37
- package/refid/hostish.js +0 -18
- package/refid/hostish.ts +0 -20
- package/refid/ism.js +0 -78
- package/refid/ism.ts +0 -81
- package/refid/itemprops.js +0 -60
- package/refid/itemprops.ts +0 -67
- package/refid/joinMatching.js +0 -56
- package/refid/joinMatching.ts +0 -54
- package/refid/nudge.js +0 -23
- package/refid/nudge.ts +0 -23
- package/refid/regIsh.js +0 -27
- package/refid/regIsh.ts +0 -31
- package/refid/secretKeys.js +0 -5
- package/refid/secretKeys.ts +0 -5
- package/refid/splitRefs.js +0 -6
- package/refid/splitRefs.ts +0 -6
- package/refid/stdVal.js +0 -15
- package/refid/stdVal.ts +0 -15
- package/refid/via.js +0 -114
- package/refid/via.ts +0 -113
- package/slotkin/affine.js +0 -39
- package/slotkin/affine.ts +0 -46
- package/slotkin/beKindred.js +0 -45
- package/slotkin/beKindred.ts +0 -55
- package/slotkin/getBreadth.js +0 -19
- package/slotkin/getBreadth.ts +0 -21
- package/slotkin/getFrag.js +0 -22
- package/slotkin/getFrag.ts +0 -21
- package/slotkin/toQuery.js +0 -12
- package/slotkin/toQuery.ts +0 -13
- package/slotkin/wrap.js +0 -13
- package/slotkin/wrap.ts +0 -18
- package/ts-refs/LICENSE +0 -21
- package/ts-refs/README.md +0 -18
- package/ts-refs/be-a-beacon/types.d.ts +0 -22
- package/ts-refs/be-alit/types.d.ts +0 -1
- package/ts-refs/be-based/types.d.ts +0 -32
- package/ts-refs/be-bound/types.d.ts +0 -65
- package/ts-refs/be-buttoned-up/types.d.ts +0 -21
- package/ts-refs/be-calculating/types.d.ts +0 -57
- package/ts-refs/be-clonable/types.d.ts +0 -28
- package/ts-refs/be-committed/types.d.ts +0 -26
- package/ts-refs/be-consoling/types.d.ts +0 -25
- package/ts-refs/be-counted/types.d.ts +0 -88
- package/ts-refs/be-delible/types.d.ts +0 -26
- package/ts-refs/be-directive/types.d.ts +0 -43
- package/ts-refs/be-dispatching/types.d.ts +0 -41
- package/ts-refs/be-elevating/types.d.ts +0 -55
- package/ts-refs/be-enhanced/types.d.ts +0 -32
- package/ts-refs/be-enhancing/types.d.ts +0 -31
- package/ts-refs/be-evanescent/types.d.ts +0 -20
- package/ts-refs/be-eventing/types.d.ts +0 -27
- package/ts-refs/be-exportable/types.d.ts +0 -26
- package/ts-refs/be-fetching/types.d.ts +0 -73
- package/ts-refs/be-flashy/types.d.ts +0 -27
- package/ts-refs/be-formalizing/types.d.ts +0 -29
- package/ts-refs/be-formidable/types.d.ts +0 -64
- package/ts-refs/be-giddy/types.d.ts +0 -26
- package/ts-refs/be-gingerly/types.d.ts +0 -19
- package/ts-refs/be-gone/types.d.ts +0 -24
- package/ts-refs/be-hashing-out/types.d.ts +0 -22
- package/ts-refs/be-hive/types.d.ts +0 -18
- package/ts-refs/be-imbued/types.d.ts +0 -30
- package/ts-refs/be-included/types.d.ts +0 -20
- package/ts-refs/be-inclusive/types.d.ts +0 -30
- package/ts-refs/be-intersectional/types.d.ts +0 -37
- package/ts-refs/be-intl/types.d.ts +0 -28
- package/ts-refs/be-invoking/types.d.ts +0 -28
- package/ts-refs/be-joining/types.d.ts +0 -26
- package/ts-refs/be-kvetching/types.d.ts +0 -24
- package/ts-refs/be-lazy/types.d.ts +0 -29
- package/ts-refs/be-literate/types.d.ts +0 -29
- package/ts-refs/be-mediating/types.d.ts +0 -34
- package/ts-refs/be-methodical/types.d.ts +0 -20
- package/ts-refs/be-modding/types.d.ts +0 -18
- package/ts-refs/be-observant/types.d.ts +0 -27
- package/ts-refs/be-observing/types.d.ts +0 -84
- package/ts-refs/be-parsed/types.d.ts +0 -19
- package/ts-refs/be-parsing/types.d.ts +0 -37
- package/ts-refs/be-persistent/types.d.ts +0 -66
- package/ts-refs/be-propagating/types.d.ts +0 -26
- package/ts-refs/be-reformable/types.d.ts +0 -48
- package/ts-refs/be-render-neutral/types.d.ts +0 -31
- package/ts-refs/be-scoped/types.d.ts +0 -24
- package/ts-refs/be-sharing/types.d.ts +0 -17
- package/ts-refs/be-switched/types.d.ts +0 -155
- package/ts-refs/be-typed/types.d.ts +0 -36
- package/ts-refs/be-value-added/types.d.ts +0 -34
- package/ts-refs/be-valued/types.d.ts +0 -22
- package/ts-refs/be-written/types.d.ts +0 -59
- package/ts-refs/css-charts/types.d.ts +0 -38
- package/ts-refs/css-echarts/types.d.ts +0 -13
- package/ts-refs/data-props/types.d.ts +0 -27
- package/ts-refs/do-inc/types.d.ts +0 -28
- package/ts-refs/do-invoke/types.d.ts +0 -28
- package/ts-refs/do-toggle/types.d.ts +0 -27
- package/ts-refs/em-bower/types.d.ts +0 -18
- package/ts-refs/fetch-for/types.d.ts +0 -37
- package/ts-refs/folder-picker/types.d.ts +0 -43
- package/ts-refs/for-fetch/doc.d.ts +0 -98
- package/ts-refs/for-fetch/types.d.ts +0 -83
- package/ts-refs/mount-observer/types.d.ts +0 -248
- package/ts-refs/mt-si/types.d.ts +0 -21
- package/ts-refs/per-each/types.d.ts +0 -51
- package/ts-refs/soak-up/types.d.ts +0 -36
- package/ts-refs/trans-render/XV/types.d.ts +0 -69
- package/ts-refs/trans-render/asmr/types.d.ts +0 -138
- package/ts-refs/trans-render/be/types.d.ts +0 -190
- package/ts-refs/trans-render/dss/types.d.ts +0 -57
- package/ts-refs/trans-render/froop/types.d.ts +0 -416
- package/ts-refs/trans-render/funions/types.d.ts +0 -12
- package/ts-refs/trans-render/lib/mixins/types.d.ts +0 -42
- package/ts-refs/trans-render/lib/prs/types.d.ts +0 -40
- package/ts-refs/trans-render/lib/types.d.ts +0 -489
- package/ts-refs/trans-render/types.d.ts +0 -583
- package/ts-refs/wc-info/SimpleWCInfo.d.ts +0 -15
- package/ts-refs/when-resolved/types.d.ts +0 -30
- package/ts-refs/xp-as/types.d.ts +0 -20
- package/ts-refs/xtal-element/types.d.ts +0 -43
- package/ts-refs/xtal-frappe-chart/types.d.ts +0 -193
- package/upShadowSearch.js +0 -25
- package/upShadowSearch.ts +0 -23
- package/waitForEvent.js +0 -12
- package/waitForEvent.ts +0 -13
- package/waitForIsh.js +0 -21
- package/waitForIsh.ts +0 -20
package/refid/genIds.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { nudge } from './nudge.js';
|
|
2
|
-
import { getCount } from './getCount.js';
|
|
3
|
-
const attrMap = {
|
|
4
|
-
'@': 'name',
|
|
5
|
-
'|': 'itemprop',
|
|
6
|
-
};
|
|
7
|
-
const scopeMatches = '[itemscope],fieldset';
|
|
8
|
-
export function inScope(scopeFragment, el) {
|
|
9
|
-
const closest = el.closest(scopeMatches); //TODO account for itemref?
|
|
10
|
-
if (closest === null)
|
|
11
|
-
return true;
|
|
12
|
-
if (scopeFragment === closest)
|
|
13
|
-
return true;
|
|
14
|
-
if (scopeFragment.contains(closest))
|
|
15
|
-
return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
export function genIds(enhancedElement) {
|
|
19
|
-
// const {parentElement} = enhancedElement;
|
|
20
|
-
// if(parentElement === null) throw 404;
|
|
21
|
-
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode());
|
|
22
|
-
//first find all elements with attribute #
|
|
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);
|
|
27
|
-
const uniqueCheck = new Set();
|
|
28
|
-
for (const hi of hashIds) {
|
|
29
|
-
if (!(hi instanceof HTMLElement))
|
|
30
|
-
continue;
|
|
31
|
-
const idName = hi.getAttribute('itemscope') || hi.localName;
|
|
32
|
-
if (uniqueCheck.has(idName))
|
|
33
|
-
throw 500;
|
|
34
|
-
uniqueCheck.add(idName);
|
|
35
|
-
let sideEffects = '';
|
|
36
|
-
const hashValue = hi.getAttribute('#');
|
|
37
|
-
if (hashValue) {
|
|
38
|
-
sideEffects = `${hashValue} `;
|
|
39
|
-
}
|
|
40
|
-
hi.dataset.id = `{{${sideEffects}${idName}}}`;
|
|
41
|
-
hi.removeAttribute('#');
|
|
42
|
-
}
|
|
43
|
-
//now find all elements with attribute @
|
|
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);
|
|
48
|
-
for (const nameEl of names) {
|
|
49
|
-
if (!(nameEl instanceof HTMLElement))
|
|
50
|
-
continue;
|
|
51
|
-
const val = nameEl.getAttribute('name');
|
|
52
|
-
if (uniqueCheck.has(val))
|
|
53
|
-
throw 500;
|
|
54
|
-
uniqueCheck.add(val);
|
|
55
|
-
let sideEffects = '';
|
|
56
|
-
const nameValue = nameEl.getAttribute('@');
|
|
57
|
-
if (nameValue) {
|
|
58
|
-
sideEffects = `${nameValue} `;
|
|
59
|
-
}
|
|
60
|
-
nameEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
61
|
-
nameEl.removeAttribute('@');
|
|
62
|
-
}
|
|
63
|
-
//now find all elements with attribute |
|
|
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);
|
|
68
|
-
for (const itempropEl of itemprops) {
|
|
69
|
-
if (!(itempropEl instanceof HTMLElement))
|
|
70
|
-
continue;
|
|
71
|
-
const val = itempropEl.getAttribute('itemprop');
|
|
72
|
-
if (uniqueCheck.has(val))
|
|
73
|
-
throw 500;
|
|
74
|
-
uniqueCheck.add(val);
|
|
75
|
-
let sideEffects = '';
|
|
76
|
-
const nameValue = itempropEl.getAttribute('|');
|
|
77
|
-
if (nameValue) {
|
|
78
|
-
sideEffects = `${nameValue} `;
|
|
79
|
-
}
|
|
80
|
-
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
81
|
-
itempropEl.removeAttribute('|');
|
|
82
|
-
}
|
|
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);
|
|
87
|
-
const ids = [];
|
|
88
|
-
for (const di of dataIds) {
|
|
89
|
-
if (!(di instanceof HTMLElement))
|
|
90
|
-
continue;
|
|
91
|
-
const unparsedID = di.dataset.id;
|
|
92
|
-
const inner = unparsedID?.substring(2, unparsedID.length - 2);
|
|
93
|
-
if (!inner)
|
|
94
|
-
continue;
|
|
95
|
-
const split = inner.split(' ');
|
|
96
|
-
const id = split.length === 2 ? split[1] : split[0];
|
|
97
|
-
if (ids.includes(id))
|
|
98
|
-
throw 500;
|
|
99
|
-
ids.push(id);
|
|
100
|
-
}
|
|
101
|
-
if (ids.length === 0)
|
|
102
|
-
return;
|
|
103
|
-
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
104
|
-
if (scopeFragment instanceof Element)
|
|
105
|
-
allChildren.push(scopeFragment);
|
|
106
|
-
const idLookup = {};
|
|
107
|
-
const base = 'gid';
|
|
108
|
-
for (const child of allChildren) {
|
|
109
|
-
const attrs = child.attributes;
|
|
110
|
-
for (const attr of attrs) {
|
|
111
|
-
const { name, value } = attr;
|
|
112
|
-
if (!name.startsWith('data-'))
|
|
113
|
-
continue;
|
|
114
|
-
if (name === 'data-id') {
|
|
115
|
-
if (!value.startsWith('{{') || !value.endsWith('}}'))
|
|
116
|
-
continue;
|
|
117
|
-
const inner = value.substring(2, value.length - 2);
|
|
118
|
-
const split = inner.split(' ');
|
|
119
|
-
const id = split.length === 2 ? split[1] : split[0];
|
|
120
|
-
if (!(id in idLookup)) {
|
|
121
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
122
|
-
}
|
|
123
|
-
if (split.length === 2) {
|
|
124
|
-
const sideEffects = split[0];
|
|
125
|
-
for (const char of sideEffects) {
|
|
126
|
-
switch (char) {
|
|
127
|
-
case '@':
|
|
128
|
-
case '|':
|
|
129
|
-
child.setAttribute(attrMap[char], id);
|
|
130
|
-
break;
|
|
131
|
-
case '%':
|
|
132
|
-
child.part.add(id);
|
|
133
|
-
break;
|
|
134
|
-
case '.':
|
|
135
|
-
child.classList.add(id);
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
child.id = idLookup[id];
|
|
141
|
-
child.setAttribute('data-id', id);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
let newValue = value;
|
|
145
|
-
for (const id of ids) {
|
|
146
|
-
const token = `{{${id}}}`;
|
|
147
|
-
if (!newValue.includes(token))
|
|
148
|
-
continue;
|
|
149
|
-
if (!(id in idLookup)) {
|
|
150
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
151
|
-
}
|
|
152
|
-
newValue = newValue.replaceAll(token, idLookup[id]);
|
|
153
|
-
}
|
|
154
|
-
if (newValue === value)
|
|
155
|
-
continue;
|
|
156
|
-
child.setAttribute(name.substring(5), newValue);
|
|
157
|
-
child.removeAttribute(name);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
for (const attr of attrs) {
|
|
161
|
-
const { name, value } = attr;
|
|
162
|
-
if (!name.startsWith('defer-'))
|
|
163
|
-
continue;
|
|
164
|
-
const nameWithoutDefer = name.substring(6);
|
|
165
|
-
const attrWithoutDefer = child.getAttributeNode(nameWithoutDefer);
|
|
166
|
-
if (attrWithoutDefer === null)
|
|
167
|
-
continue;
|
|
168
|
-
const valueWithoutDefer = attrWithoutDefer.value;
|
|
169
|
-
let newValue = valueWithoutDefer;
|
|
170
|
-
let changeMade = false;
|
|
171
|
-
for (const id of ids) {
|
|
172
|
-
const token = `{{${id}}}`;
|
|
173
|
-
if (!newValue.includes(token))
|
|
174
|
-
continue;
|
|
175
|
-
if (!(id in idLookup)) {
|
|
176
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
177
|
-
}
|
|
178
|
-
newValue = newValue.replaceAll(token, idLookup[id]);
|
|
179
|
-
changeMade = true;
|
|
180
|
-
}
|
|
181
|
-
//child.setAttribute(nameWithoutDefer, newValue);
|
|
182
|
-
if (changeMade)
|
|
183
|
-
attrWithoutDefer.value = newValue;
|
|
184
|
-
nudge(child, name);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (scopeFragment instanceof Element && 'disabled' in scopeFragment) {
|
|
188
|
-
nudge(scopeFragment);
|
|
189
|
-
}
|
|
190
|
-
}
|
package/refid/genIds.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import {nudge} from './nudge.js';
|
|
2
|
-
import {getCount} from './getCount.js';
|
|
3
|
-
|
|
4
|
-
const attrMap = {
|
|
5
|
-
'@': 'name',
|
|
6
|
-
'|': 'itemprop',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const scopeMatches = '[itemscope],fieldset';
|
|
10
|
-
|
|
11
|
-
export function inScope(scopeFragment: DocumentFragment | Element, el: Element){
|
|
12
|
-
const closest = el.closest(scopeMatches);//TODO account for itemref?
|
|
13
|
-
if(closest === null) return true;
|
|
14
|
-
if(scopeFragment === closest) return true;
|
|
15
|
-
if(scopeFragment.contains(closest)) return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function genIds(enhancedElement: Element){
|
|
20
|
-
// const {parentElement} = enhancedElement;
|
|
21
|
-
// if(parentElement === null) throw 404;
|
|
22
|
-
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode()) as DocumentFragment | Element;
|
|
23
|
-
|
|
24
|
-
//first find all elements with attribute #
|
|
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);
|
|
28
|
-
const uniqueCheck = new Set();
|
|
29
|
-
for(const hi of hashIds){
|
|
30
|
-
if(!(hi instanceof HTMLElement)) continue;
|
|
31
|
-
const idName = hi.getAttribute('itemscope') || hi.localName;
|
|
32
|
-
if(uniqueCheck.has(idName)) throw 500;
|
|
33
|
-
uniqueCheck.add(idName);
|
|
34
|
-
let sideEffects = '';
|
|
35
|
-
const hashValue = hi.getAttribute('#');
|
|
36
|
-
if(hashValue){
|
|
37
|
-
sideEffects = `${hashValue} `;
|
|
38
|
-
}
|
|
39
|
-
hi.dataset.id = `{{${sideEffects}${idName}}}`;
|
|
40
|
-
hi.removeAttribute('#');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//now find all elements with attribute @
|
|
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);
|
|
47
|
-
for(const nameEl of names){
|
|
48
|
-
if(!(nameEl instanceof HTMLElement)) continue;
|
|
49
|
-
const val = nameEl.getAttribute('name');
|
|
50
|
-
if(uniqueCheck.has(val)) throw 500;
|
|
51
|
-
uniqueCheck.add(val);
|
|
52
|
-
let sideEffects = '';
|
|
53
|
-
const nameValue = nameEl.getAttribute('@');
|
|
54
|
-
if(nameValue){
|
|
55
|
-
sideEffects = `${nameValue} `;
|
|
56
|
-
}
|
|
57
|
-
nameEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
58
|
-
nameEl.removeAttribute('@');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
//now find all elements with attribute |
|
|
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);
|
|
65
|
-
for(const itempropEl of itemprops){
|
|
66
|
-
if(!(itempropEl instanceof HTMLElement)) continue;
|
|
67
|
-
const val = itempropEl.getAttribute('itemprop');
|
|
68
|
-
if(uniqueCheck.has(val)) throw 500;
|
|
69
|
-
uniqueCheck.add(val);
|
|
70
|
-
let sideEffects = '';
|
|
71
|
-
const nameValue = itempropEl.getAttribute('|');
|
|
72
|
-
if(nameValue){
|
|
73
|
-
sideEffects = `${nameValue} `;
|
|
74
|
-
}
|
|
75
|
-
itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
|
|
76
|
-
itempropEl.removeAttribute('|');
|
|
77
|
-
}
|
|
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);
|
|
81
|
-
const ids: Array<string> = [];
|
|
82
|
-
for(const di of dataIds){
|
|
83
|
-
if(!(di instanceof HTMLElement)) continue;
|
|
84
|
-
const unparsedID = di.dataset.id;
|
|
85
|
-
const inner = unparsedID?.substring(2, unparsedID.length - 2);
|
|
86
|
-
if(!inner) continue;
|
|
87
|
-
const split = inner.split(' ');
|
|
88
|
-
const id = split.length === 2 ? split[1] : split[0];
|
|
89
|
-
if(ids.includes(id)) throw 500;
|
|
90
|
-
ids.push(id);
|
|
91
|
-
}
|
|
92
|
-
if(ids.length === 0) return;
|
|
93
|
-
|
|
94
|
-
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
95
|
-
if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
|
|
96
|
-
|
|
97
|
-
const idLookup: {[key: string]: string} = {};
|
|
98
|
-
const base = 'gid';
|
|
99
|
-
for(const child of allChildren){
|
|
100
|
-
const attrs = child.attributes;
|
|
101
|
-
for(const attr of attrs){
|
|
102
|
-
const {name, value} = attr;
|
|
103
|
-
if(!name.startsWith('data-')) continue;
|
|
104
|
-
if(name === 'data-id'){
|
|
105
|
-
if(!value.startsWith('{{') || !value.endsWith('}}')) continue;
|
|
106
|
-
const inner = value.substring(2, value.length - 2);
|
|
107
|
-
const split = inner.split(' ');
|
|
108
|
-
const id = split.length === 2 ? split[1] : split[0];
|
|
109
|
-
if(!(id in idLookup)){
|
|
110
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
111
|
-
}
|
|
112
|
-
if(split.length === 2){
|
|
113
|
-
const sideEffects = split[0];
|
|
114
|
-
for(const char of sideEffects){
|
|
115
|
-
switch(char){
|
|
116
|
-
case '@':
|
|
117
|
-
case '|':
|
|
118
|
-
child.setAttribute(attrMap[char], id);
|
|
119
|
-
break;
|
|
120
|
-
case '%':
|
|
121
|
-
child.part.add(id);
|
|
122
|
-
break;
|
|
123
|
-
case '.':
|
|
124
|
-
child.classList.add(id);
|
|
125
|
-
break;
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
child.id = idLookup[id];
|
|
131
|
-
child.setAttribute('data-id', id);
|
|
132
|
-
}else{
|
|
133
|
-
let newValue = value;
|
|
134
|
-
for(const id of ids){
|
|
135
|
-
const token = `{{${id}}}`;
|
|
136
|
-
if(!newValue.includes(token)) continue;
|
|
137
|
-
if(!(id in idLookup)){
|
|
138
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
139
|
-
}
|
|
140
|
-
newValue = newValue.replaceAll(token, idLookup[id]);
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
if(newValue === value) continue;
|
|
144
|
-
child.setAttribute(name.substring(5), newValue);
|
|
145
|
-
child.removeAttribute(name);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
for(const attr of attrs){
|
|
150
|
-
const {name, value} = attr;
|
|
151
|
-
if(!name.startsWith('defer-')) continue;
|
|
152
|
-
const nameWithoutDefer = name.substring(6);
|
|
153
|
-
const attrWithoutDefer = child.getAttributeNode(nameWithoutDefer);
|
|
154
|
-
if(attrWithoutDefer === null) continue;
|
|
155
|
-
const valueWithoutDefer = attrWithoutDefer.value;
|
|
156
|
-
|
|
157
|
-
let newValue = valueWithoutDefer;
|
|
158
|
-
let changeMade = false;
|
|
159
|
-
for(const id of ids){
|
|
160
|
-
const token = `{{${id}}}`;
|
|
161
|
-
if(!newValue.includes(token)) continue;
|
|
162
|
-
if(!(id in idLookup)){
|
|
163
|
-
idLookup[id] = `${base}-${getCount(base)}`;
|
|
164
|
-
}
|
|
165
|
-
newValue = newValue.replaceAll(token, idLookup[id]);
|
|
166
|
-
changeMade = true;
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
//child.setAttribute(nameWithoutDefer, newValue);
|
|
170
|
-
if(changeMade) attrWithoutDefer.value = newValue;
|
|
171
|
-
nudge(child, name);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if(scopeFragment instanceof Element && 'disabled' in scopeFragment){
|
|
175
|
-
nudge(scopeFragment);
|
|
176
|
-
}
|
|
177
|
-
}
|
package/refid/getAdjRefs.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { splitRefs } from './splitRefs.js';
|
|
2
|
-
export function getAdjRefs(node) {
|
|
3
|
-
const returnArr = [node];
|
|
4
|
-
if (node.nodeType === node.COMMENT_NODE) {
|
|
5
|
-
const openText = node.data.split(' ')[0];
|
|
6
|
-
const closedText = `/${openText}`;
|
|
7
|
-
let ns = node.nextSibling;
|
|
8
|
-
while (ns) {
|
|
9
|
-
returnArr.push(ns);
|
|
10
|
-
if (node.nodeType === node.COMMENT_NODE && node.data === closedText) {
|
|
11
|
-
return returnArr;
|
|
12
|
-
}
|
|
13
|
-
ns = ns.nextSibling;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
const el = node;
|
|
18
|
-
const itemref = el.getAttribute('itemref');
|
|
19
|
-
if (itemref === null)
|
|
20
|
-
return returnArr;
|
|
21
|
-
const itemrefList = splitRefs(itemref); // itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
22
|
-
if (itemrefList.length === 0)
|
|
23
|
-
return returnArr;
|
|
24
|
-
let ns = el.nextSibling;
|
|
25
|
-
while (ns !== null) {
|
|
26
|
-
if (ns instanceof Element) {
|
|
27
|
-
if (ns.id && itemrefList.includes(ns.id)) {
|
|
28
|
-
returnArr.push(ns);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return returnArr;
|
|
33
|
-
}
|
|
34
|
-
ns = ns.nextSibling;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return returnArr;
|
|
38
|
-
}
|
package/refid/getAdjRefs.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { splitRefs } from './splitRefs.js';
|
|
2
|
-
export function getAdjRefs(node: Node){
|
|
3
|
-
const returnArr: Array<Node> = [node];
|
|
4
|
-
if(node.nodeType === node.COMMENT_NODE){
|
|
5
|
-
const openText = (node as Comment).data.split(' ')[0];
|
|
6
|
-
const closedText = `/${openText}`;
|
|
7
|
-
let ns = node.nextSibling;
|
|
8
|
-
while(ns){
|
|
9
|
-
returnArr.push(ns);
|
|
10
|
-
if(node.nodeType === node.COMMENT_NODE && (node as Comment).data === closedText){
|
|
11
|
-
return returnArr;
|
|
12
|
-
}
|
|
13
|
-
ns = ns.nextSibling;
|
|
14
|
-
}
|
|
15
|
-
}else{
|
|
16
|
-
const el = node as Element;
|
|
17
|
-
const itemref = el.getAttribute('itemref');
|
|
18
|
-
if(itemref === null) return returnArr;
|
|
19
|
-
const itemrefList = splitRefs(itemref);// itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
20
|
-
if(itemrefList.length === 0) return returnArr;
|
|
21
|
-
let ns = el.nextSibling;
|
|
22
|
-
while(ns !== null){
|
|
23
|
-
if(ns instanceof Element){
|
|
24
|
-
if(ns.id && itemrefList.includes(ns.id)){
|
|
25
|
-
returnArr.push(ns);
|
|
26
|
-
}
|
|
27
|
-
}else{
|
|
28
|
-
return returnArr;
|
|
29
|
-
}
|
|
30
|
-
ns = ns.nextSibling;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return returnArr;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
package/refid/getContext.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import './hostish.js';
|
|
2
|
-
export function getContext(el, ctr) {
|
|
3
|
-
let hostish = el.hostish(false);
|
|
4
|
-
while (hostish && !(hostish instanceof ctr)) {
|
|
5
|
-
if ('hostish' in hostish) {
|
|
6
|
-
hostish = hostish.hostish();
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return hostish;
|
|
13
|
-
}
|
package/refid/getContext.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import './hostish.js';
|
|
2
|
-
|
|
3
|
-
export function getContext<T extends Object>(el: Element, ctr: {new(): T}){
|
|
4
|
-
let hostish = (<any>el).hostish(false);
|
|
5
|
-
while(hostish && !(hostish instanceof ctr)){
|
|
6
|
-
if('hostish' in hostish){
|
|
7
|
-
hostish = hostish.hostish();
|
|
8
|
-
}else{
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return hostish;
|
|
14
|
-
}
|
package/refid/getCount.js
DELETED
package/refid/getCount.ts
DELETED
package/refid/getIsh.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { sym, guid } from './regIsh.js';
|
|
2
|
-
export async function getIsh(scope, name) {
|
|
3
|
-
let test = scope;
|
|
4
|
-
while (true) {
|
|
5
|
-
const map = test[sym];
|
|
6
|
-
if (map !== undefined) {
|
|
7
|
-
if (map.has(name)) {
|
|
8
|
-
return map.get(name);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
if (test === document) {
|
|
12
|
-
return await watch(scope, name);
|
|
13
|
-
}
|
|
14
|
-
if (test instanceof ShadowRoot) {
|
|
15
|
-
test = test.host;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
let newTest = test.parentElement;
|
|
19
|
-
if (newTest) {
|
|
20
|
-
test = newTest;
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const lastTest = test;
|
|
24
|
-
test = test.getRootNode();
|
|
25
|
-
if (test === lastTest) {
|
|
26
|
-
return await watch(scope, name);
|
|
27
|
-
}
|
|
28
|
-
;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function watch(scope, name) {
|
|
32
|
-
const { waitForEvent } = await import('../waitForEvent.js');
|
|
33
|
-
await waitForEvent(document, guid);
|
|
34
|
-
return await getIsh(scope, name);
|
|
35
|
-
}
|
package/refid/getIsh.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {sym, guid} from './regIsh.js';
|
|
2
|
-
import {IshCtr} from '../ts-refs/mount-observer/types.js';
|
|
3
|
-
export async function getIsh(scope: Element | ShadowRoot | Document | Node, name: string): Promise<IshCtr>{
|
|
4
|
-
let test = scope as any;
|
|
5
|
-
|
|
6
|
-
while(true){
|
|
7
|
-
const map = test[sym] as Map<string, IshCtr>;
|
|
8
|
-
if(map !== undefined){
|
|
9
|
-
if(map.has(name)){
|
|
10
|
-
return map.get(name)!;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
if(test === document){
|
|
14
|
-
return await watch(scope, name);
|
|
15
|
-
}
|
|
16
|
-
if(test instanceof ShadowRoot){
|
|
17
|
-
test = test.host;
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
let newTest = test.parentElement;
|
|
21
|
-
if(newTest){
|
|
22
|
-
test = newTest;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
const lastTest = test;
|
|
26
|
-
test = test.getRootNode();
|
|
27
|
-
if(test === lastTest) {
|
|
28
|
-
return await watch(scope, name);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function watch(scope: Element | ShadowRoot | Document | Node, name: string){
|
|
34
|
-
const {waitForEvent} = await import('../waitForEvent.js');
|
|
35
|
-
await waitForEvent(document, guid);
|
|
36
|
-
return await getIsh(scope, name);
|
|
37
|
-
}
|
package/refid/hostish.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Element.prototype.hostish = async function (checkSelf = true) {
|
|
3
|
-
const from = checkSelf ? this : this.hasAttribute('itemscope') ? this.parentElement : this;
|
|
4
|
-
const closest = from?.closest('[itemscope]');
|
|
5
|
-
if (closest === null || closest === undefined)
|
|
6
|
-
return this.getRootNode().host;
|
|
7
|
-
const { localName } = closest;
|
|
8
|
-
const itemScopeAttr = closest.getAttribute('itemscope');
|
|
9
|
-
if (itemScopeAttr) {
|
|
10
|
-
const { waitForIsh } = await import('mount-observer/waitForIsh.js');
|
|
11
|
-
return await waitForIsh(closest);
|
|
12
|
-
}
|
|
13
|
-
if (localName.includes('-')) {
|
|
14
|
-
await customElements.whenDefined(localName);
|
|
15
|
-
return closest;
|
|
16
|
-
}
|
|
17
|
-
return this.getRootNode().host;
|
|
18
|
-
};
|
package/refid/hostish.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface Element{
|
|
2
|
-
hostish(): Promise<any>
|
|
3
|
-
}
|
|
4
|
-
Element.prototype.hostish = async function(checkSelf = true){
|
|
5
|
-
const from = checkSelf ? this : this.hasAttribute('itemscope') ? this.parentElement : this;
|
|
6
|
-
const closest = from?.closest('[itemscope]') as HTMLElement;
|
|
7
|
-
if(closest === null || closest === undefined) return (<any>this.getRootNode()).host;
|
|
8
|
-
const {localName} = closest;
|
|
9
|
-
const itemScopeAttr = closest.getAttribute('itemscope');
|
|
10
|
-
if(itemScopeAttr){
|
|
11
|
-
const {waitForIsh} = await import('mount-observer/waitForIsh.js');
|
|
12
|
-
return await waitForIsh(closest);
|
|
13
|
-
}
|
|
14
|
-
if(localName.includes('-')){
|
|
15
|
-
await customElements.whenDefined(localName);
|
|
16
|
-
return closest;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (<any>this.getRootNode()).host;
|
|
20
|
-
}
|
package/refid/ism.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { upShadowSearch } from '../upShadowSearch.js';
|
|
2
|
-
import { stdVal } from './stdVal.js';
|
|
3
|
-
Object.defineProperty(HTMLElement.prototype, 'ism', {
|
|
4
|
-
get() {
|
|
5
|
-
const el = this;
|
|
6
|
-
if (!el.hasAttribute('itemscope'))
|
|
7
|
-
return;
|
|
8
|
-
return parse(el);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const parsedItempropMaps = new WeakMap();
|
|
12
|
-
export function parse(el, scope = {}, scopedLists = {}) {
|
|
13
|
-
const itemprop = el.getAttribute('itemprop');
|
|
14
|
-
if (itemprop) {
|
|
15
|
-
scope[itemprop] = stdVal(el); //TODO full logic
|
|
16
|
-
}
|
|
17
|
-
const itempropmap = el.getAttribute('itempropmap');
|
|
18
|
-
if (itempropmap) {
|
|
19
|
-
//const el = document.getElementById(itempropmap);
|
|
20
|
-
const jsonEl = upShadowSearch(el, itempropmap);
|
|
21
|
-
if (!jsonEl)
|
|
22
|
-
throw 500;
|
|
23
|
-
if (!parsedItempropMaps.has(jsonEl)) {
|
|
24
|
-
parsedItempropMaps.set(jsonEl, JSON.parse(jsonEl.innerHTML));
|
|
25
|
-
}
|
|
26
|
-
const parsed = /** @type {ItemPropMap} */ (parsedItempropMaps.get(jsonEl));
|
|
27
|
-
for (const key in parsed) {
|
|
28
|
-
const attr = el.getAttribute(key);
|
|
29
|
-
if (attr === null)
|
|
30
|
-
continue;
|
|
31
|
-
const rhs = parsed[key];
|
|
32
|
-
switch (typeof rhs) {
|
|
33
|
-
case 'string':
|
|
34
|
-
scope[rhs] = attr;
|
|
35
|
-
break;
|
|
36
|
-
case 'object':
|
|
37
|
-
const { instanceOf, mapsTo } = rhs;
|
|
38
|
-
switch (instanceOf) {
|
|
39
|
-
case 'Number':
|
|
40
|
-
case Number:
|
|
41
|
-
scope[mapsTo] = Number(attr);
|
|
42
|
-
break;
|
|
43
|
-
case 'Object':
|
|
44
|
-
case Object:
|
|
45
|
-
case 'Boolean':
|
|
46
|
-
case Boolean:
|
|
47
|
-
scope[mapsTo] = JSON.parse(attr);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const children = Array.from(el.children);
|
|
54
|
-
let itemscopeMapToPass = scopedLists;
|
|
55
|
-
for (const child of children) {
|
|
56
|
-
if (!(child instanceof HTMLElement))
|
|
57
|
-
continue;
|
|
58
|
-
const childHasItemScopeAttr = child.hasAttribute('itemscope');
|
|
59
|
-
const objToPass = childHasItemScopeAttr ? {} : scope;
|
|
60
|
-
if (childHasItemScopeAttr) {
|
|
61
|
-
itemscopeMapToPass = {};
|
|
62
|
-
}
|
|
63
|
-
parse(child, objToPass, itemscopeMapToPass);
|
|
64
|
-
const isItemScopeAndChildHasBothItempropAndItemscope = scopedLists && child.hasAttribute('itemprop') && child.hasAttribute('itemscope');
|
|
65
|
-
if (isItemScopeAndChildHasBothItempropAndItemscope) {
|
|
66
|
-
const itemprops = child.getAttribute('itemprop').split(" ").filter(x => x);
|
|
67
|
-
for (const itemprop of itemprops) {
|
|
68
|
-
if (!scopedLists[itemprop])
|
|
69
|
-
scopedLists[itemprop] = [];
|
|
70
|
-
scopedLists[itemprop].push(objToPass);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
scope,
|
|
76
|
-
scopedLists
|
|
77
|
-
};
|
|
78
|
-
}
|