mount-observer 0.0.30 → 0.0.31
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/MountObserver.js +7 -7
- package/{birtualizeMatch.js → compose.js} +11 -3
- package/package.json +17 -8
package/MountObserver.js
CHANGED
|
@@ -48,15 +48,15 @@ export class MountObserver extends EventTarget {
|
|
|
48
48
|
this.#calculatedSelector = calculatedSelector;
|
|
49
49
|
return this.#calculatedSelector;
|
|
50
50
|
}
|
|
51
|
-
async
|
|
51
|
+
async composeFragment(fragment, level) {
|
|
52
52
|
const bis = fragment.querySelectorAll(inclTemplQry);
|
|
53
53
|
for (const bi of bis) {
|
|
54
|
-
await this.#
|
|
54
|
+
await this.#compose(bi, level);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
async #
|
|
58
|
-
const {
|
|
59
|
-
await
|
|
57
|
+
async #compose(el, level) {
|
|
58
|
+
const { compose } = await import('./compose.js');
|
|
59
|
+
await compose(this, el, level);
|
|
60
60
|
}
|
|
61
61
|
#templLookUp = new Map();
|
|
62
62
|
findByID(id, fragment) {
|
|
@@ -348,13 +348,13 @@ export class MountObserver extends EventTarget {
|
|
|
348
348
|
});
|
|
349
349
|
for (const elToMount of elsToMount) {
|
|
350
350
|
if (elToMount.matches(inclTemplQry)) {
|
|
351
|
-
await this.#
|
|
351
|
+
await this.#compose(elToMount, 0);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
this.#mount(elsToMount, initializing);
|
|
355
355
|
}
|
|
356
356
|
async #inspectWithin(within, initializing) {
|
|
357
|
-
await this.
|
|
357
|
+
await this.composeFragment(within, 0);
|
|
358
358
|
const els = Array.from(within.querySelectorAll(await this.#selector()));
|
|
359
359
|
this.#filterAndMount(els, false, initializing);
|
|
360
360
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { inclTemplQry } from './MountObserver.js';
|
|
2
|
-
export
|
|
2
|
+
export const guid = Symbol.for('Wr0WPVh84k+O93miuENdMA');
|
|
3
|
+
export async function compose(self, el, level) {
|
|
3
4
|
const src = el.getAttribute('src');
|
|
4
5
|
el.removeAttribute('src');
|
|
5
6
|
const templID = src.substring(1);
|
|
@@ -28,7 +29,7 @@ export async function birtualizeMatch(self, el, level) {
|
|
|
28
29
|
target.remove();
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
await self.
|
|
32
|
+
await self.composeFragment(clone, level + 1);
|
|
32
33
|
const shadowRootModeOnLoad = el.getAttribute('shadowRootModeOnLoad');
|
|
33
34
|
if (shadowRootModeOnLoad === null && level === 0) {
|
|
34
35
|
const slotMap = el.getAttribute('slotmap');
|
|
@@ -67,6 +68,13 @@ export async function birtualizeMatch(self, el, level) {
|
|
|
67
68
|
}
|
|
68
69
|
el.dispatchEvent(new LoadEvent(clone));
|
|
69
70
|
}
|
|
71
|
+
if (level === 0) {
|
|
72
|
+
const childRefs = [];
|
|
73
|
+
for (const child of clone.children) {
|
|
74
|
+
childRefs.push(new WeakRef(child));
|
|
75
|
+
}
|
|
76
|
+
el[guid] = childRefs;
|
|
77
|
+
}
|
|
70
78
|
if (shadowRootModeOnLoad !== null) {
|
|
71
79
|
const parent = el.parentElement;
|
|
72
80
|
if (parent === null)
|
|
@@ -78,7 +86,7 @@ export async function birtualizeMatch(self, el, level) {
|
|
|
78
86
|
else {
|
|
79
87
|
el.after(clone);
|
|
80
88
|
}
|
|
81
|
-
if (level !== 0 || slots.length === 0)
|
|
89
|
+
if (level !== 0 || (slots.length === 0 && !el.hasAttribute('itemscope')))
|
|
82
90
|
el.remove();
|
|
83
91
|
}
|
|
84
92
|
export class LoadEvent extends Event {
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@playwright/test": "1.
|
|
9
|
-
"may-it-serve": "0.0.
|
|
8
|
+
"@playwright/test": "1.46.0",
|
|
9
|
+
"may-it-serve": "0.0.8"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
"./MountObserver.js": "./MountObserver.js",
|
|
14
|
-
"./Synthesizer.js": "./Synthesizer.js",
|
|
15
|
-
"./types.d.ts": {
|
|
12
|
+
".": {
|
|
16
13
|
"default": "./MountObserver.js",
|
|
17
|
-
"types": "./
|
|
14
|
+
"types": "./MountObserver.ts"
|
|
15
|
+
},
|
|
16
|
+
"./MountObserver.js": {
|
|
17
|
+
"default": "./MountObserver.js",
|
|
18
|
+
"types": "./MountObserver.ts"
|
|
19
|
+
},
|
|
20
|
+
"./Synthesizer.js": {
|
|
21
|
+
"default": "./Synthesizer.js",
|
|
22
|
+
"types": "./Synthesizer.ts"
|
|
23
|
+
},
|
|
24
|
+
"./compose.js": {
|
|
25
|
+
"default": "./compose.js",
|
|
26
|
+
"types": "./compose.ts"
|
|
18
27
|
}
|
|
19
28
|
},
|
|
20
29
|
"files": [
|