mount-observer 0.0.112 → 0.1.1
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 +62 -26
- package/Events.ts +52 -30
- package/MountObserver.js +285 -514
- package/MountObserver.ts +362 -538
- package/README.md +149 -56
- package/SharedMutationObserver.js +70 -0
- package/SharedMutationObserver.ts +96 -0
- package/attrCoordinates.js +93 -0
- package/attrCoordinates.ts +122 -0
- package/index.js +3 -0
- package/index.ts +22 -0
- package/loadImports.js +47 -0
- package/loadImports.ts +56 -0
- package/mediaQuery.js +86 -0
- package/mediaQuery.ts +113 -0
- package/package.json +11 -119
- package/playwright.config.ts +0 -1
- package/types.d.ts +104 -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 -24
- 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 -198
- 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/compose.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { wasItemReffed } from './MountObserver.js';
|
|
2
|
-
//import {prep} from './slotkin/affine.js';
|
|
3
|
-
//goal: deprecate this key, in favor of comments
|
|
4
|
-
export const childRefsKey = Symbol.for('Wr0WPVh84k+O93miuENdMA');
|
|
5
|
-
export const cloneKey = Symbol.for('LD97VKZYc02CQv23DT/6fQ');
|
|
6
|
-
const autogenKey = Symbol.for('YpP5EP0i1UKcBBBH9tsm0w');
|
|
7
|
-
//const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
8
|
-
export async function compose(self, el, level, refName, refType) {
|
|
9
|
-
const src = el.getAttribute('src');
|
|
10
|
-
if (src === null)
|
|
11
|
-
return;
|
|
12
|
-
el.removeAttribute('src');
|
|
13
|
-
//const templID = src!.substring(1);
|
|
14
|
-
//const refType = src![0];
|
|
15
|
-
const fragment = self.objNde?.deref();
|
|
16
|
-
if (fragment === undefined)
|
|
17
|
-
return;
|
|
18
|
-
const templ = await self.findByID(refName, fragment, refType);
|
|
19
|
-
if (!(templ instanceof HTMLTemplateElement))
|
|
20
|
-
throw 404;
|
|
21
|
-
if (refType === '#') {
|
|
22
|
-
(await import('./slotkin/wrap.js')).wrap(templ, refName);
|
|
23
|
-
}
|
|
24
|
-
const clone = templ.content.cloneNode(true);
|
|
25
|
-
const dataLd = el.dataset.ld;
|
|
26
|
-
const wasReffed = templ[wasItemReffed];
|
|
27
|
-
if (wasReffed || dataLd) {
|
|
28
|
-
const firstElement = clone.firstElementChild;
|
|
29
|
-
if (wasReffed) {
|
|
30
|
-
let ns = firstElement.nextElementSibling;
|
|
31
|
-
const ids = [];
|
|
32
|
-
let count = window[autogenKey];
|
|
33
|
-
if (count === undefined) {
|
|
34
|
-
count = 0;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
count++;
|
|
38
|
-
}
|
|
39
|
-
window[autogenKey] = count;
|
|
40
|
-
while (ns !== null) {
|
|
41
|
-
const id = ns.id = `mount-observer-${count}`;
|
|
42
|
-
ids.push(id);
|
|
43
|
-
ns = ns.nextElementSibling;
|
|
44
|
-
}
|
|
45
|
-
firstElement.setAttribute('itemref', ids.join(' '));
|
|
46
|
-
}
|
|
47
|
-
if (dataLd) {
|
|
48
|
-
const parsed = JSON.parse(dataLd);
|
|
49
|
-
let type = parsed['@type'];
|
|
50
|
-
const itemscopeAttr = firstElement.getAttribute('itemscope');
|
|
51
|
-
if (type && !itemscopeAttr) {
|
|
52
|
-
firstElement.setAttribute('itemscope', type);
|
|
53
|
-
}
|
|
54
|
-
firstElement['ish'] = parsed;
|
|
55
|
-
delete el.dataset.ld;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (el.content.childElementCount > 0) {
|
|
59
|
-
const { affine } = await import('./slotkin/affine.js');
|
|
60
|
-
const children = Array.from(el.content.children);
|
|
61
|
-
for (const child of children) {
|
|
62
|
-
//TODO support clean up
|
|
63
|
-
const mo = affine(clone, child);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
await self.composeFragment(clone, level + 1);
|
|
67
|
-
// if (false) {
|
|
68
|
-
// const shadowRootModeOnLoad = el.getAttribute('shadowRootModeOnLoad') as null | ShadowRootMode;
|
|
69
|
-
// if (shadowRootModeOnLoad === null && level === 0) {
|
|
70
|
-
// const slotMap = el.getAttribute('slotmap');
|
|
71
|
-
// let map = slotMap === null ? undefined : JSON.parse(slotMap);
|
|
72
|
-
// const slots = clone.querySelectorAll('[slot]');
|
|
73
|
-
// for (const slot of slots) {
|
|
74
|
-
// if (map !== undefined) {
|
|
75
|
-
// const slotName = slot.slot;
|
|
76
|
-
// for (const key in map) {
|
|
77
|
-
// if (slot.matches(key)) {
|
|
78
|
-
// const targetAttSymbols = map[key] as string;
|
|
79
|
-
// for (const sym of targetAttSymbols) {
|
|
80
|
-
// switch (sym) {
|
|
81
|
-
// case '|':
|
|
82
|
-
// slot.setAttribute('itemprop', slotName);
|
|
83
|
-
// break;
|
|
84
|
-
// case '$':
|
|
85
|
-
// slot.setAttribute('itemscope', '');
|
|
86
|
-
// slot.setAttribute('itemprop', slotName);
|
|
87
|
-
// break;
|
|
88
|
-
// case '@':
|
|
89
|
-
// slot.setAttribute('name', slotName);
|
|
90
|
-
// break;
|
|
91
|
-
// case '.':
|
|
92
|
-
// slot.classList.add(slotName);
|
|
93
|
-
// break;
|
|
94
|
-
// case '%':
|
|
95
|
-
// slot.part.add(slotName);
|
|
96
|
-
// break;
|
|
97
|
-
// }
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
|
-
// }
|
|
102
|
-
// slot.removeAttribute('slot');
|
|
103
|
-
// }
|
|
104
|
-
// el.dispatchEvent(new LoadEvent(clone));
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
107
|
-
if (level === 0) {
|
|
108
|
-
const refs = [];
|
|
109
|
-
for (const child of clone.children) {
|
|
110
|
-
refs.push(new WeakRef(child));
|
|
111
|
-
}
|
|
112
|
-
el[childRefsKey] = refs;
|
|
113
|
-
}
|
|
114
|
-
//if template has itemscope attribute, assume want to do some data binding before instantiating into
|
|
115
|
-
//DOM fragment.
|
|
116
|
-
let cloneStashed = false;
|
|
117
|
-
if (el.hasAttribute('itemscope')) {
|
|
118
|
-
el[cloneKey] = clone;
|
|
119
|
-
cloneStashed = true;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// if (false /*shadowRootModeOnLoad !== null */) {
|
|
123
|
-
// const parent = el.parentElement;
|
|
124
|
-
// if (parent === null) throw 404;
|
|
125
|
-
// if (parent.shadowRoot === null) parent.attachShadow({ mode: shadowRootModeOnLoad });
|
|
126
|
-
// parent.shadowRoot?.append(clone);
|
|
127
|
-
// } else {
|
|
128
|
-
el.after(clone);
|
|
129
|
-
//}
|
|
130
|
-
}
|
|
131
|
-
//moving the code down here broke be-inclusive Example2.html (but maybe it caused something else to work, so will need to revisit)
|
|
132
|
-
//check to make sure the progresive loading of css-charts works as before.
|
|
133
|
-
// if(level === 0){
|
|
134
|
-
// el.dispatchEvent(new LoadEvent(clone));
|
|
135
|
-
// }
|
|
136
|
-
if (!cloneStashed) {
|
|
137
|
-
if (level !== 0 || el.attributes.length === 0)
|
|
138
|
-
el.remove();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export class LoadEvent extends Event {
|
|
142
|
-
clone;
|
|
143
|
-
static eventName = 'load';
|
|
144
|
-
constructor(clone) {
|
|
145
|
-
super(LoadEvent.eventName);
|
|
146
|
-
this.clone = clone;
|
|
147
|
-
}
|
|
148
|
-
}
|
package/compose.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { ILoadEvent, loadEventName, RefType } from './ts-refs/mount-observer/types';
|
|
2
|
-
import { MountObserver, inclTemplQry, wasItemReffed } from './MountObserver.js';
|
|
3
|
-
//import {prep} from './slotkin/affine.js';
|
|
4
|
-
|
|
5
|
-
//goal: deprecate this key, in favor of comments
|
|
6
|
-
export const childRefsKey = Symbol.for('Wr0WPVh84k+O93miuENdMA');
|
|
7
|
-
export const cloneKey = Symbol.for('LD97VKZYc02CQv23DT/6fQ');
|
|
8
|
-
const autogenKey = Symbol.for('YpP5EP0i1UKcBBBH9tsm0w');
|
|
9
|
-
//const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
10
|
-
export async function compose(
|
|
11
|
-
self: MountObserver,
|
|
12
|
-
el: HTMLTemplateElement,
|
|
13
|
-
level: number,
|
|
14
|
-
refName: string,
|
|
15
|
-
refType: RefType,
|
|
16
|
-
) {
|
|
17
|
-
const src = el.getAttribute('src'); if (src === null) return;
|
|
18
|
-
el.removeAttribute('src');
|
|
19
|
-
//const templID = src!.substring(1);
|
|
20
|
-
//const refType = src![0];
|
|
21
|
-
const fragment = self.objNde?.deref() as DocumentFragment;
|
|
22
|
-
if (fragment === undefined) return;
|
|
23
|
-
const templ = await self.findByID(refName, fragment, refType);
|
|
24
|
-
if (!(templ instanceof HTMLTemplateElement)) throw 404;
|
|
25
|
-
if (refType === '#') {
|
|
26
|
-
(await import('./slotkin/wrap.js')).wrap(templ, refName);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const clone = templ.content.cloneNode(true) as DocumentFragment;
|
|
30
|
-
const dataLd = el.dataset.ld;
|
|
31
|
-
const wasReffed = (<any>templ)[wasItemReffed];
|
|
32
|
-
if (wasReffed || dataLd) {
|
|
33
|
-
const firstElement = clone.firstElementChild!;
|
|
34
|
-
if (wasReffed) {
|
|
35
|
-
let ns = firstElement.nextElementSibling;
|
|
36
|
-
const ids = [];
|
|
37
|
-
let count = (<any>window)[autogenKey];
|
|
38
|
-
if (count === undefined) {
|
|
39
|
-
count = 0;
|
|
40
|
-
} else {
|
|
41
|
-
count++;
|
|
42
|
-
}
|
|
43
|
-
(<any>window)[autogenKey] = count;
|
|
44
|
-
while (ns !== null) {
|
|
45
|
-
const id = ns.id = `mount-observer-${count}`;
|
|
46
|
-
ids.push(id);
|
|
47
|
-
ns = ns.nextElementSibling;
|
|
48
|
-
}
|
|
49
|
-
firstElement.setAttribute('itemref', ids.join(' '));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (dataLd) {
|
|
53
|
-
const parsed = JSON.parse(dataLd);
|
|
54
|
-
let type = parsed['@type'];
|
|
55
|
-
const itemscopeAttr = firstElement.getAttribute('itemscope');
|
|
56
|
-
if (type && !itemscopeAttr) {
|
|
57
|
-
firstElement.setAttribute('itemscope', type);
|
|
58
|
-
}
|
|
59
|
-
(<any>firstElement)['ish'] = parsed;
|
|
60
|
-
delete el.dataset.ld;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
if (el.content.childElementCount > 0) {
|
|
65
|
-
const { affine } = await import('./slotkin/affine.js');
|
|
66
|
-
const children = Array.from(el.content.children);
|
|
67
|
-
for (const child of children) {
|
|
68
|
-
//TODO support clean up
|
|
69
|
-
const mo = affine(clone, child);
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await self.composeFragment(clone, level + 1);
|
|
77
|
-
// if (false) {
|
|
78
|
-
// const shadowRootModeOnLoad = el.getAttribute('shadowRootModeOnLoad') as null | ShadowRootMode;
|
|
79
|
-
// if (shadowRootModeOnLoad === null && level === 0) {
|
|
80
|
-
|
|
81
|
-
// const slotMap = el.getAttribute('slotmap');
|
|
82
|
-
// let map = slotMap === null ? undefined : JSON.parse(slotMap);
|
|
83
|
-
// const slots = clone.querySelectorAll('[slot]');
|
|
84
|
-
// for (const slot of slots) {
|
|
85
|
-
// if (map !== undefined) {
|
|
86
|
-
// const slotName = slot.slot;
|
|
87
|
-
// for (const key in map) {
|
|
88
|
-
// if (slot.matches(key)) {
|
|
89
|
-
// const targetAttSymbols = map[key] as string;
|
|
90
|
-
// for (const sym of targetAttSymbols) {
|
|
91
|
-
// switch (sym) {
|
|
92
|
-
// case '|':
|
|
93
|
-
// slot.setAttribute('itemprop', slotName);
|
|
94
|
-
// break;
|
|
95
|
-
// case '$':
|
|
96
|
-
// slot.setAttribute('itemscope', '');
|
|
97
|
-
// slot.setAttribute('itemprop', slotName);
|
|
98
|
-
// break;
|
|
99
|
-
// case '@':
|
|
100
|
-
// slot.setAttribute('name', slotName);
|
|
101
|
-
// break;
|
|
102
|
-
// case '.':
|
|
103
|
-
// slot.classList.add(slotName);
|
|
104
|
-
// break;
|
|
105
|
-
// case '%':
|
|
106
|
-
// slot.part.add(slotName);
|
|
107
|
-
// break;
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
|
-
// }
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
|
-
// slot.removeAttribute('slot');
|
|
114
|
-
// }
|
|
115
|
-
// el.dispatchEvent(new LoadEvent(clone));
|
|
116
|
-
// }
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
|
-
if (level === 0) {
|
|
120
|
-
const refs: Array<WeakRef<Element>> = [];
|
|
121
|
-
for (const child of clone.children) {
|
|
122
|
-
refs.push(new WeakRef(child));
|
|
123
|
-
}
|
|
124
|
-
(<any>el)[childRefsKey] = refs;
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
//if template has itemscope attribute, assume want to do some data binding before instantiating into
|
|
128
|
-
//DOM fragment.
|
|
129
|
-
let cloneStashed = false;
|
|
130
|
-
if (el.hasAttribute('itemscope')) {
|
|
131
|
-
(<any>el)[cloneKey] = clone;
|
|
132
|
-
cloneStashed = true;
|
|
133
|
-
} else {
|
|
134
|
-
// if (false /*shadowRootModeOnLoad !== null */) {
|
|
135
|
-
// const parent = el.parentElement;
|
|
136
|
-
// if (parent === null) throw 404;
|
|
137
|
-
// if (parent.shadowRoot === null) parent.attachShadow({ mode: shadowRootModeOnLoad });
|
|
138
|
-
// parent.shadowRoot?.append(clone);
|
|
139
|
-
// } else {
|
|
140
|
-
el.after(clone);
|
|
141
|
-
//}
|
|
142
|
-
}
|
|
143
|
-
//moving the code down here broke be-inclusive Example2.html (but maybe it caused something else to work, so will need to revisit)
|
|
144
|
-
//check to make sure the progresive loading of css-charts works as before.
|
|
145
|
-
// if(level === 0){
|
|
146
|
-
// el.dispatchEvent(new LoadEvent(clone));
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
|
-
if (!cloneStashed) {
|
|
150
|
-
if (level !== 0 || el.attributes.length === 0) el.remove();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export class LoadEvent extends Event implements ILoadEvent {
|
|
156
|
-
static eventName: loadEventName = 'load';
|
|
157
|
-
constructor(public clone: DocumentFragment) {
|
|
158
|
-
super(LoadEvent.eventName);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
interface HTMLElementEventMap {
|
|
163
|
-
'load': LoadEvent,
|
|
164
|
-
}
|
package/doCleanup.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export function doCleanup(htmlSrc, clone, options = {
|
|
2
|
-
removeInner: '[itemprop]:not([itemscope])',
|
|
3
|
-
removeOuter: '[itemprop][itemscope]'
|
|
4
|
-
}) {
|
|
5
|
-
const removeInner = htmlSrc.getAttribute('remove-inner') || options.removeInner;
|
|
6
|
-
if (removeInner) {
|
|
7
|
-
const removeInnerEls = clone.querySelectorAll(removeInner);
|
|
8
|
-
for (const removeInnerEl of removeInnerEls) {
|
|
9
|
-
if ('href' in removeInnerEl) {
|
|
10
|
-
removeInnerEl.href = '';
|
|
11
|
-
}
|
|
12
|
-
else if ('value' in removeInnerEl) {
|
|
13
|
-
removeInnerEl.value = '';
|
|
14
|
-
}
|
|
15
|
-
else if ('datetime' in removeInnerEl) {
|
|
16
|
-
removeInnerEl.datetime = '';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
//any other exceptions?
|
|
20
|
-
removeInnerEl.textContent = '';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const removeOuter = htmlSrc.getAttribute('remove-outer') || options.removeOuter;
|
|
25
|
-
if (removeOuter) {
|
|
26
|
-
const removeOuterEls = clone.querySelectorAll(removeOuter);
|
|
27
|
-
for (const removeOuterEl of removeOuterEls) {
|
|
28
|
-
removeOuterEl.remove();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
package/doCleanup.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface doCleanUpOptions {
|
|
2
|
-
removeInner?: string;
|
|
3
|
-
removeOuter?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function doCleanup(htmlSrc: HTMLElement, clone: DocumentFragment, options: doCleanUpOptions = {
|
|
7
|
-
removeInner: '[itemprop]:not([itemscope])',
|
|
8
|
-
removeOuter: '[itemprop][itemscope]'
|
|
9
|
-
}){
|
|
10
|
-
const removeInner = htmlSrc.getAttribute('remove-inner') || options.removeInner;
|
|
11
|
-
if(removeInner){
|
|
12
|
-
const removeInnerEls = clone.querySelectorAll(removeInner);
|
|
13
|
-
for(const removeInnerEl of removeInnerEls){
|
|
14
|
-
if('href' in removeInnerEl){
|
|
15
|
-
removeInnerEl.href = '';
|
|
16
|
-
} else if ('value' in removeInnerEl){
|
|
17
|
-
removeInnerEl.value = '';
|
|
18
|
-
}else if('datetime' in removeInnerEl){
|
|
19
|
-
removeInnerEl.datetime = '';
|
|
20
|
-
}else{
|
|
21
|
-
//any other exceptions?
|
|
22
|
-
removeInnerEl.textContent = '';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const removeOuter = htmlSrc.getAttribute('remove-outer') || options.removeOuter;
|
|
27
|
-
if(removeOuter){
|
|
28
|
-
const removeOuterEls = clone.querySelectorAll(removeOuter);
|
|
29
|
-
for(const removeOuterEl of removeOuterEls){
|
|
30
|
-
removeOuterEl.remove();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
package/getWhereAttrSelector.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export async function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
2
|
-
const { hasBase, hasBranchIn, hasRootIn } = whereAttr;
|
|
3
|
-
let fullListOfAttrs = [];
|
|
4
|
-
const partitionedAttrs = [];
|
|
5
|
-
if (hasBase !== undefined) {
|
|
6
|
-
const hasRootInGuaranteed = hasRootIn || [{
|
|
7
|
-
start: '',
|
|
8
|
-
context: 'Both'
|
|
9
|
-
}];
|
|
10
|
-
let prefixLessMatches = [];
|
|
11
|
-
const hasBaseIsString = typeof hasBase === 'string';
|
|
12
|
-
const baseSelector = hasBaseIsString ? hasBase : hasBase[1];
|
|
13
|
-
const rootToBaseDelimiter = hasBaseIsString ? '-' : hasBase[0];
|
|
14
|
-
if (hasBranchIn !== undefined) {
|
|
15
|
-
let baseToBranchDelimiter = '-';
|
|
16
|
-
let branches;
|
|
17
|
-
if (hasBranchIn.length === 2 && Array.isArray(hasBranchIn[1])) {
|
|
18
|
-
baseToBranchDelimiter = hasBranchIn[0];
|
|
19
|
-
branches = hasBranchIn[1];
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
branches = hasBranchIn;
|
|
23
|
-
}
|
|
24
|
-
prefixLessMatches = branches.map(x => ({
|
|
25
|
-
rootToBaseDelimiter,
|
|
26
|
-
base: baseSelector,
|
|
27
|
-
baseToBranchDelimiter: x ? baseToBranchDelimiter : '',
|
|
28
|
-
branch: x
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
prefixLessMatches.push({
|
|
33
|
-
rootToBaseDelimiter,
|
|
34
|
-
base: baseSelector,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
for (const rootCnfg of hasRootInGuaranteed) {
|
|
38
|
-
const { start } = rootCnfg;
|
|
39
|
-
for (const match of prefixLessMatches) {
|
|
40
|
-
const { base, baseToBranchDelimiter, branch, rootToBaseDelimiter } = match;
|
|
41
|
-
let branchIdx = 0;
|
|
42
|
-
for (const prefixLessMatch of prefixLessMatches) {
|
|
43
|
-
const { base, baseToBranchDelimiter, branch } = prefixLessMatch;
|
|
44
|
-
const startAndRootToBaseDelimiter = start ? `${start}${rootToBaseDelimiter}` : '';
|
|
45
|
-
//TODO: could probably reduce the size of the code below
|
|
46
|
-
if (branch) {
|
|
47
|
-
//will always have branch?
|
|
48
|
-
const name = `${startAndRootToBaseDelimiter}${base}${baseToBranchDelimiter}${branch}`;
|
|
49
|
-
fullListOfAttrs.push(name);
|
|
50
|
-
partitionedAttrs.push({
|
|
51
|
-
root: start,
|
|
52
|
-
name,
|
|
53
|
-
base,
|
|
54
|
-
branch,
|
|
55
|
-
branchIdx,
|
|
56
|
-
rootCnfg
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const name = `${startAndRootToBaseDelimiter}${base}`;
|
|
61
|
-
fullListOfAttrs.push(name);
|
|
62
|
-
partitionedAttrs.push({
|
|
63
|
-
root: start,
|
|
64
|
-
name,
|
|
65
|
-
base,
|
|
66
|
-
rootCnfg,
|
|
67
|
-
branchIdx
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
branchIdx++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
fullListOfAttrs = Array.from(new Set(fullListOfAttrs));
|
|
76
|
-
const listOfSelectors = fullListOfAttrs.map(s => `${withoutAttrs}[${s}]`);
|
|
77
|
-
const calculatedSelector = listOfSelectors.join(',');
|
|
78
|
-
return {
|
|
79
|
-
fullListOfAttrs,
|
|
80
|
-
calculatedSelector,
|
|
81
|
-
partitionedAttrs,
|
|
82
|
-
};
|
|
83
|
-
}
|
package/getWhereAttrSelector.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {AttrParts, RootCnfg, WhereAttr} from './ts-refs/mount-observer/types';
|
|
2
|
-
export async function getWhereAttrSelector(whereAttr: WhereAttr, withoutAttrs: string){
|
|
3
|
-
const {hasBase, hasBranchIn, hasRootIn} = whereAttr;
|
|
4
|
-
|
|
5
|
-
let fullListOfAttrs: Array<string> = [];
|
|
6
|
-
const partitionedAttrs: Array<AttrParts> = [];
|
|
7
|
-
if(hasBase !== undefined){
|
|
8
|
-
const hasRootInGuaranteed: Array<RootCnfg> = hasRootIn || [{
|
|
9
|
-
start: '',
|
|
10
|
-
context: 'Both'
|
|
11
|
-
} as RootCnfg];
|
|
12
|
-
|
|
13
|
-
let prefixLessMatches: Array<{
|
|
14
|
-
rootToBaseDelimiter: string,
|
|
15
|
-
base: string,
|
|
16
|
-
branch?: string,
|
|
17
|
-
leaf?: string //todo,
|
|
18
|
-
baseToBranchDelimiter?: string,
|
|
19
|
-
}> = [];
|
|
20
|
-
const hasBaseIsString = typeof hasBase === 'string';
|
|
21
|
-
const baseSelector = hasBaseIsString ? hasBase : hasBase[1];
|
|
22
|
-
const rootToBaseDelimiter = hasBaseIsString ? '-' : hasBase[0];
|
|
23
|
-
if(hasBranchIn !== undefined){
|
|
24
|
-
let baseToBranchDelimiter = '-';
|
|
25
|
-
let branches: Array<string> | undefined;
|
|
26
|
-
if(hasBranchIn.length === 2 && Array.isArray(hasBranchIn[1])){
|
|
27
|
-
baseToBranchDelimiter = hasBranchIn[0];
|
|
28
|
-
branches = hasBranchIn[1];
|
|
29
|
-
}else{
|
|
30
|
-
branches = hasBranchIn as Array<string>;
|
|
31
|
-
}
|
|
32
|
-
prefixLessMatches = branches.map(x => ({
|
|
33
|
-
rootToBaseDelimiter,
|
|
34
|
-
base: baseSelector,
|
|
35
|
-
baseToBranchDelimiter: x ? baseToBranchDelimiter : '',
|
|
36
|
-
branch: x
|
|
37
|
-
}));
|
|
38
|
-
}else{
|
|
39
|
-
prefixLessMatches.push({
|
|
40
|
-
rootToBaseDelimiter,
|
|
41
|
-
base: baseSelector,
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
for(const rootCnfg of hasRootInGuaranteed){
|
|
45
|
-
const {start} = rootCnfg;
|
|
46
|
-
for(const match of prefixLessMatches){
|
|
47
|
-
const {base, baseToBranchDelimiter, branch, rootToBaseDelimiter} = match;
|
|
48
|
-
let branchIdx = 0;
|
|
49
|
-
for(const prefixLessMatch of prefixLessMatches){
|
|
50
|
-
const {base, baseToBranchDelimiter, branch} = prefixLessMatch;
|
|
51
|
-
const startAndRootToBaseDelimiter = start ? `${start}${rootToBaseDelimiter}` : '';
|
|
52
|
-
//TODO: could probably reduce the size of the code below
|
|
53
|
-
if(branch){
|
|
54
|
-
//will always have branch?
|
|
55
|
-
const name = `${startAndRootToBaseDelimiter}${base}${baseToBranchDelimiter}${branch}`
|
|
56
|
-
fullListOfAttrs.push(name);
|
|
57
|
-
partitionedAttrs.push({
|
|
58
|
-
root: start,
|
|
59
|
-
name,
|
|
60
|
-
base,
|
|
61
|
-
branch,
|
|
62
|
-
branchIdx,
|
|
63
|
-
rootCnfg
|
|
64
|
-
});
|
|
65
|
-
}else{
|
|
66
|
-
const name = `${startAndRootToBaseDelimiter}${base}`;
|
|
67
|
-
fullListOfAttrs.push(name);
|
|
68
|
-
partitionedAttrs.push({
|
|
69
|
-
root: start,
|
|
70
|
-
name,
|
|
71
|
-
base,
|
|
72
|
-
rootCnfg,
|
|
73
|
-
branchIdx
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
branchIdx++;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fullListOfAttrs = Array.from(new Set(fullListOfAttrs));
|
|
84
|
-
const listOfSelectors = fullListOfAttrs.map(s => `${withoutAttrs}[${s}]`);
|
|
85
|
-
const calculatedSelector = listOfSelectors.join(',');
|
|
86
|
-
return {
|
|
87
|
-
fullListOfAttrs,
|
|
88
|
-
calculatedSelector,
|
|
89
|
-
partitionedAttrs,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
}
|
package/preloadContent.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { upShadowSearch } from './upShadowSearch.js';
|
|
2
|
-
const remoteTemplElSym = Symbol.for('du3y+tfsAUGFHMG/iHZiMQ');
|
|
3
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
|
|
4
|
-
get() {
|
|
5
|
-
const templ = this;
|
|
6
|
-
const src = templ.getAttribute('src');
|
|
7
|
-
if (src === null) {
|
|
8
|
-
const head = document.head;
|
|
9
|
-
if (window[remoteTemplElSym] === undefined) {
|
|
10
|
-
window[remoteTemplElSym] = 0;
|
|
11
|
-
}
|
|
12
|
-
const id = templ.id || `mount-observer-${window[remoteTemplElSym]++}`;
|
|
13
|
-
const sourceTempl = document.createElement('template');
|
|
14
|
-
sourceTempl.id = '' + id;
|
|
15
|
-
sourceTempl.content.appendChild(templ.content);
|
|
16
|
-
head.append(sourceTempl);
|
|
17
|
-
templ.innerHTML = '';
|
|
18
|
-
templ.setAttribute('src', `#${id}`);
|
|
19
|
-
templ.setAttribute('rel', 'preload');
|
|
20
|
-
templ[remoteTemplElSym] = new WeakRef(sourceTempl);
|
|
21
|
-
return sourceTempl.content;
|
|
22
|
-
}
|
|
23
|
-
{
|
|
24
|
-
const test = templ[remoteTemplElSym]?.deref();
|
|
25
|
-
if (test !== undefined)
|
|
26
|
-
return test.content;
|
|
27
|
-
if (templ.getAttribute('rel') !== 'preload')
|
|
28
|
-
throw 'NI';
|
|
29
|
-
const isIntraDoc = src[0] === '#';
|
|
30
|
-
if (!isIntraDoc)
|
|
31
|
-
throw 'NI';
|
|
32
|
-
const id = src.substring(1);
|
|
33
|
-
const remoteTempl = upShadowSearch(templ, id);
|
|
34
|
-
if (!(remoteTempl instanceof HTMLTemplateElement))
|
|
35
|
-
throw 404; //not found
|
|
36
|
-
templ[remoteTemplElSym] = new WeakRef(remoteTempl);
|
|
37
|
-
return remoteTempl.content;
|
|
38
|
-
//templ.dispatchEvent(new Event('load'));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
export function preloadContent(templ) {
|
|
43
|
-
const content = templ.remoteContent;
|
|
44
|
-
}
|
package/preloadContent.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {TemplateWithRemoteContent} from './ts-refs/mount-observer/types.js';
|
|
2
|
-
import {upShadowSearch} from './upShadowSearch.js';
|
|
3
|
-
const remoteTemplElSym = Symbol.for('du3y+tfsAUGFHMG/iHZiMQ');
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
|
|
6
|
-
get(){
|
|
7
|
-
const templ = this as HTMLTemplateElement;
|
|
8
|
-
const src = templ.getAttribute('src');
|
|
9
|
-
if(src === null){
|
|
10
|
-
const head = document.head;
|
|
11
|
-
if((<any>window)[remoteTemplElSym] === undefined ){
|
|
12
|
-
(<any>window)[remoteTemplElSym] = 0;
|
|
13
|
-
}
|
|
14
|
-
const id = templ.id || `mount-observer-${(<any>window)[remoteTemplElSym]++}`;
|
|
15
|
-
const sourceTempl = document.createElement('template');
|
|
16
|
-
sourceTempl.id = '' + id;
|
|
17
|
-
sourceTempl.content.appendChild(templ.content);
|
|
18
|
-
head.append(sourceTempl);
|
|
19
|
-
templ.innerHTML = '';
|
|
20
|
-
templ.setAttribute('src', `#${id}`);
|
|
21
|
-
templ.setAttribute('rel', 'preload');
|
|
22
|
-
(<any>templ)[remoteTemplElSym] = new WeakRef(sourceTempl);
|
|
23
|
-
return sourceTempl.content;
|
|
24
|
-
}
|
|
25
|
-
{
|
|
26
|
-
const test = (<any>templ)[remoteTemplElSym]?.deref();
|
|
27
|
-
if(test !== undefined) return test.content;
|
|
28
|
-
if(templ.getAttribute('rel') !== 'preload') throw 'NI';
|
|
29
|
-
const isIntraDoc = src[0] === '#';
|
|
30
|
-
if(!isIntraDoc) throw 'NI';
|
|
31
|
-
const id = src.substring(1);
|
|
32
|
-
const remoteTempl = upShadowSearch(templ, id);
|
|
33
|
-
if(!(remoteTempl instanceof HTMLTemplateElement)) throw 404; //not found
|
|
34
|
-
(<any>templ)[remoteTemplElSym] = new WeakRef(remoteTempl);
|
|
35
|
-
return remoteTempl.content;
|
|
36
|
-
//templ.dispatchEvent(new Event('load'));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
export function preloadContent(
|
|
43
|
-
templ: HTMLTemplateElement,
|
|
44
|
-
) {
|
|
45
|
-
const content = (<any>templ).remoteContent;
|
|
46
|
-
|
|
47
|
-
}
|