mount-observer 0.0.11 → 0.0.13
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 +14 -6
- package/package.json +1 -1
package/MountObserver.js
CHANGED
|
@@ -46,7 +46,7 @@ export class MountObserver extends EventTarget {
|
|
|
46
46
|
return this.#calculatedSelector;
|
|
47
47
|
}
|
|
48
48
|
async #birtualizeFragment(fragment, level) {
|
|
49
|
-
const bis =
|
|
49
|
+
const bis = fragment.querySelectorAll(inclTemplQry);
|
|
50
50
|
for (const bi of bis) {
|
|
51
51
|
await this.#birtalizeMatch(bi, level);
|
|
52
52
|
}
|
|
@@ -65,18 +65,26 @@ export class MountObserver extends EventTarget {
|
|
|
65
65
|
const slots = el.content.querySelectorAll(`[slot]`);
|
|
66
66
|
for (const slot of slots) {
|
|
67
67
|
const name = slot.getAttribute('slot');
|
|
68
|
-
const
|
|
68
|
+
const slotQry = `slot[name="${name}"]`;
|
|
69
|
+
const targets = Array.from(clone.querySelectorAll(slotQry));
|
|
70
|
+
const innerTempls = clone.querySelectorAll(inclTemplQry);
|
|
71
|
+
for (const innerTempl of innerTempls) {
|
|
72
|
+
const innerSlots = innerTempl.content.querySelectorAll(slotQry);
|
|
73
|
+
for (const innerSlot of innerSlots) {
|
|
74
|
+
targets.push(innerSlot);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
69
77
|
for (const target of targets) {
|
|
70
78
|
const slotClone = slot.cloneNode(true);
|
|
71
79
|
target.after(slotClone);
|
|
72
80
|
target.remove();
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
|
-
this.#birtualizeFragment(clone, level + 1);
|
|
83
|
+
await this.#birtualizeFragment(clone, level + 1);
|
|
76
84
|
if (level === 0) {
|
|
77
85
|
const slotMap = el.getAttribute('slotmap');
|
|
78
86
|
let map = slotMap === null ? undefined : JSON.parse(slotMap);
|
|
79
|
-
const slots =
|
|
87
|
+
const slots = clone.querySelectorAll('[slot]');
|
|
80
88
|
for (const slot of slots) {
|
|
81
89
|
if (map !== undefined) {
|
|
82
90
|
const slotName = slot.slot;
|
|
@@ -361,7 +369,7 @@ export class MountObserver extends EventTarget {
|
|
|
361
369
|
return true;
|
|
362
370
|
});
|
|
363
371
|
for (const elToMount of elsToMount) {
|
|
364
|
-
if (elToMount.matches(
|
|
372
|
+
if (elToMount.matches(inclTemplQry)) {
|
|
365
373
|
await this.#birtalizeMatch(elToMount, 0);
|
|
366
374
|
}
|
|
367
375
|
}
|
|
@@ -374,7 +382,7 @@ export class MountObserver extends EventTarget {
|
|
|
374
382
|
}
|
|
375
383
|
}
|
|
376
384
|
const refCountErr = 'mount-observer ref count mismatch';
|
|
377
|
-
const
|
|
385
|
+
const inclTemplQry = 'template[href^="#"]:not([hidden])';
|
|
378
386
|
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
379
387
|
/**
|
|
380
388
|
* The `mutation-event` event represents something that happened.
|