mount-observer 0.0.17 → 0.0.18
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 +27 -17
- package/getWhereAttrSelector.js +8 -2
- package/package.json +1 -1
- package/types.d.ts +2 -0
package/MountObserver.js
CHANGED
|
@@ -190,7 +190,6 @@ export class MountObserver extends EventTarget {
|
|
|
190
190
|
const alreadyMounted = await this.#filterAndDismount();
|
|
191
191
|
const mount = this.#mountInit.do?.mount;
|
|
192
192
|
const { import: imp } = this.#mountInit;
|
|
193
|
-
const fullListOfAttrs = this.#fullListOfAttrs;
|
|
194
193
|
for (const match of matching) {
|
|
195
194
|
if (alreadyMounted.has(match))
|
|
196
195
|
continue;
|
|
@@ -220,25 +219,36 @@ export class MountObserver extends EventTarget {
|
|
|
220
219
|
});
|
|
221
220
|
}
|
|
222
221
|
this.dispatchEvent(new MountEvent(match, initializing));
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
222
|
+
//should we automatically call readAttrs?
|
|
223
|
+
//the thinking is it might make more sense to call that after mounting
|
|
224
|
+
this.#mountedList?.push(new WeakRef(match));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
readAttrs(match, branchIndexes) {
|
|
228
|
+
const fullListOfAttrs = this.#fullListOfAttrs;
|
|
229
|
+
const attrChangeInfos = [];
|
|
230
|
+
if (fullListOfAttrs !== undefined) {
|
|
231
|
+
const attrParts = this.#attrParts;
|
|
232
|
+
for (let idx = 0, ii = fullListOfAttrs.length; idx < ii; idx++) {
|
|
233
|
+
const parts = attrParts[idx];
|
|
234
|
+
const { branchIdx } = parts;
|
|
235
|
+
if (branchIndexes !== undefined) {
|
|
236
|
+
if (!branchIndexes.has(branchIdx))
|
|
237
|
+
continue;
|
|
237
238
|
}
|
|
238
|
-
|
|
239
|
+
const name = fullListOfAttrs[idx];
|
|
240
|
+
const oldValue = null;
|
|
241
|
+
const newValue = match.getAttribute(name);
|
|
242
|
+
attrChangeInfos.push({
|
|
243
|
+
idx,
|
|
244
|
+
newValue,
|
|
245
|
+
oldValue,
|
|
246
|
+
parts
|
|
247
|
+
});
|
|
239
248
|
}
|
|
240
|
-
this
|
|
249
|
+
//this.dispatchEvent(new AttrChangeEvent(match, attrChangeInfos));
|
|
241
250
|
}
|
|
251
|
+
return attrChangeInfos;
|
|
242
252
|
}
|
|
243
253
|
async #dismount(unmatching) {
|
|
244
254
|
const onDismount = this.#mountInit.do?.dismount;
|
package/getWhereAttrSelector.js
CHANGED
|
@@ -23,7 +23,7 @@ export function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
|
23
23
|
prefixLessMatches = branches.map(x => ({
|
|
24
24
|
rootToBaseDelimiter,
|
|
25
25
|
base: baseSelector,
|
|
26
|
-
baseToBranchDelimiter,
|
|
26
|
+
baseToBranchDelimiter: x ? baseToBranchDelimiter : '',
|
|
27
27
|
branch: x
|
|
28
28
|
}));
|
|
29
29
|
}
|
|
@@ -37,10 +37,13 @@ export function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
|
37
37
|
const { start } = rootCnfg;
|
|
38
38
|
for (const match of prefixLessMatches) {
|
|
39
39
|
const { base, baseToBranchDelimiter, branch, rootToBaseDelimiter } = match;
|
|
40
|
+
let branchIdx = 0;
|
|
40
41
|
for (const prefixLessMatch of prefixLessMatches) {
|
|
41
42
|
const { base, baseToBranchDelimiter, branch } = prefixLessMatch;
|
|
42
43
|
const startAndRootToBaseDelimiter = start ? `${start}${rootToBaseDelimiter}` : '';
|
|
44
|
+
//TODO: could probably reduce the size of the code below
|
|
43
45
|
if (branch) {
|
|
46
|
+
//will always have branch?
|
|
44
47
|
const name = `${startAndRootToBaseDelimiter}${base}${baseToBranchDelimiter}${branch}`;
|
|
45
48
|
fullListOfAttrs.push(name);
|
|
46
49
|
partitionedAttrs.push({
|
|
@@ -48,6 +51,7 @@ export function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
|
48
51
|
name,
|
|
49
52
|
base,
|
|
50
53
|
branch,
|
|
54
|
+
branchIdx,
|
|
51
55
|
rootCnfg
|
|
52
56
|
});
|
|
53
57
|
}
|
|
@@ -58,9 +62,11 @@ export function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
|
58
62
|
root: start,
|
|
59
63
|
name,
|
|
60
64
|
base,
|
|
61
|
-
rootCnfg
|
|
65
|
+
rootCnfg,
|
|
66
|
+
branchIdx
|
|
62
67
|
});
|
|
63
68
|
}
|
|
69
|
+
branchIdx++;
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
}
|
package/package.json
CHANGED