jsf.js_next_gen 4.1.0-beta.20 → 4.1.0-beta.21
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/README.md +10 -0
- package/dist/docs/index.html +35 -1
- package/dist/window/faces-development.js +54 -7
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +54 -7
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.map +1 -1
- package/package.json +2 -2
|
@@ -1055,15 +1055,46 @@ class DomQuery {
|
|
|
1055
1055
|
if (queryRes.length) {
|
|
1056
1056
|
found.push(queryRes);
|
|
1057
1057
|
}
|
|
1058
|
-
let shadowRoots = this.
|
|
1058
|
+
let shadowRoots = this._collectShadowRoots();
|
|
1059
1059
|
if (shadowRoots.length) {
|
|
1060
|
-
let shadowRes = shadowRoots.querySelectorAllDeep(queryStr);
|
|
1060
|
+
let shadowRes = new DomQuery(shadowRoots).querySelectorAllDeep(queryStr);
|
|
1061
1061
|
if (shadowRes.length) {
|
|
1062
1062
|
found.push(shadowRes);
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
1065
|
return new DomQuery(found);
|
|
1066
1066
|
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Collects the shadow roots hosted by the light-DOM descendants of each root
|
|
1069
|
+
* node in a single pass.
|
|
1070
|
+
*
|
|
1071
|
+
* This replaces the prior `querySelectorAll("*").shadowRoot`, which
|
|
1072
|
+
* materialized a DomQuery wrapping every element on the page and then walked
|
|
1073
|
+
* that throwaway collection a second time through the shadowRoot getter. We
|
|
1074
|
+
* still have to inspect every element - there is no CSS selector for "has a
|
|
1075
|
+
* shadow root", so the cost stays O(number of elements) - but we drop the
|
|
1076
|
+
* intermediate all-elements DomQuery and the redundant second traversal.
|
|
1077
|
+
*
|
|
1078
|
+
* @private
|
|
1079
|
+
*/
|
|
1080
|
+
_collectShadowRoots() {
|
|
1081
|
+
var _a, _b;
|
|
1082
|
+
let shadowRoots = [];
|
|
1083
|
+
for (let cnt = 0; cnt < ((_b = (_a = this === null || this === void 0 ? void 0 : this.rootNode) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); cnt++) {
|
|
1084
|
+
let root = this.rootNode[cnt];
|
|
1085
|
+
if (!(root === null || root === void 0 ? void 0 : root.querySelectorAll)) {
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
let all = root.querySelectorAll("*");
|
|
1089
|
+
for (let i = 0, len = all.length; i < len; i++) {
|
|
1090
|
+
let shadowRoot = all[i].shadowRoot;
|
|
1091
|
+
if (shadowRoot) {
|
|
1092
|
+
shadowRoots.push(shadowRoot);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
return shadowRoots;
|
|
1097
|
+
}
|
|
1067
1098
|
/**
|
|
1068
1099
|
* disabled flag
|
|
1069
1100
|
*/
|
|
@@ -1085,7 +1116,11 @@ class DomQuery {
|
|
|
1085
1116
|
get childNodes() {
|
|
1086
1117
|
let childNodeArr = [];
|
|
1087
1118
|
this.eachElem((item) => {
|
|
1088
|
-
|
|
1119
|
+
// push the live childNodes list straight into the single target in
|
|
1120
|
+
// chunks instead of concat(objToArray(...)) per root, which both
|
|
1121
|
+
// copied each child list and reallocated the growing accumulator
|
|
1122
|
+
// (O(roots * total children))
|
|
1123
|
+
(0,_Es2019Array__WEBPACK_IMPORTED_MODULE_4__.pushChunked)(childNodeArr, item.childNodes);
|
|
1089
1124
|
});
|
|
1090
1125
|
return new DomQuery(childNodeArr);
|
|
1091
1126
|
}
|
|
@@ -1339,6 +1374,11 @@ class DomQuery {
|
|
|
1339
1374
|
.filter(item => id == item.id)
|
|
1340
1375
|
.map(item => new DomQuery(item)));
|
|
1341
1376
|
}
|
|
1377
|
+
// a "deep" id search must collect matches across every scope: ids are
|
|
1378
|
+
// unique only within a single node-tree, so the same id may legitimately
|
|
1379
|
+
// exist in the light DOM and inside one or more shadow roots at once.
|
|
1380
|
+
// We therefore cannot short-circuit on a light-DOM hit and must run the
|
|
1381
|
+
// full deep search.
|
|
1342
1382
|
let subItems = this.querySelectorAllDeep(`[id="${id}"]`);
|
|
1343
1383
|
if (subItems.length) {
|
|
1344
1384
|
res.push(subItems);
|
|
@@ -1355,9 +1395,12 @@ class DomQuery {
|
|
|
1355
1395
|
var _a;
|
|
1356
1396
|
let res = [];
|
|
1357
1397
|
if (includeRoot) {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1398
|
+
// append the matching roots in a single pass; the prior
|
|
1399
|
+
// reduce(reduction.concat([item])) reallocated the accumulator on
|
|
1400
|
+
// every match (O(matches^2))
|
|
1401
|
+
let matchingRoots = (0,_Es2019Array__WEBPACK_IMPORTED_MODULE_4__.Es2019ArrayFrom)((_a = this === null || this === void 0 ? void 0 : this.rootNode) !== null && _a !== void 0 ? _a : [])
|
|
1402
|
+
.filter(element => (element === null || element === void 0 ? void 0 : element.tagName) == tagName);
|
|
1403
|
+
(0,_Es2019Array__WEBPACK_IMPORTED_MODULE_4__.pushChunked)(res, matchingRoots);
|
|
1361
1404
|
}
|
|
1362
1405
|
(deep) ? res.push(this.querySelectorAllDeep(tagName)) : res.push(this.querySelectorAll(tagName));
|
|
1363
1406
|
return new DomQuery(res);
|
|
@@ -2457,7 +2500,11 @@ class DomQuery {
|
|
|
2457
2500
|
continue;
|
|
2458
2501
|
}
|
|
2459
2502
|
let res = this.rootNode[cnt].querySelectorAll(selector);
|
|
2460
|
-
|
|
2503
|
+
// push the NodeList straight into the single target array in
|
|
2504
|
+
// argument-stack-safe chunks; this avoids the objToArray copy plus
|
|
2505
|
+
// the concat reallocation, which doubled a large result set (e.g. the
|
|
2506
|
+
// querySelectorAll("*") shadow scan) on every root iteration
|
|
2507
|
+
(0,_Es2019Array__WEBPACK_IMPORTED_MODULE_4__.pushChunked)(nodes, res);
|
|
2461
2508
|
}
|
|
2462
2509
|
return new DomQuery(nodes);
|
|
2463
2510
|
}
|