regor 1.4.4 → 1.4.5
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/dist/regor.es2015.cjs.js +108 -36
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +108 -36
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +108 -36
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +108 -36
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +108 -36
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +108 -36
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +102 -31
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +102 -31
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +102 -31
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2019.cjs.js
CHANGED
|
@@ -529,10 +529,13 @@ var IfBinder = class {
|
|
|
529
529
|
}
|
|
530
530
|
__bindAll(element) {
|
|
531
531
|
const isIfElement = element.hasAttribute(this.__if);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
532
|
+
if (isIfElement) this.__bind(element);
|
|
533
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
534
|
+
element,
|
|
535
|
+
(el) => {
|
|
536
|
+
if (el.hasAttribute(this.__if)) this.__bind(el);
|
|
537
|
+
}
|
|
538
|
+
);
|
|
536
539
|
return isIfElement;
|
|
537
540
|
}
|
|
538
541
|
__isProcessedOrMark(el) {
|
|
@@ -1324,8 +1327,16 @@ var ComponentBinder = class {
|
|
|
1324
1327
|
}
|
|
1325
1328
|
return false;
|
|
1326
1329
|
}
|
|
1330
|
+
__isNamedSlotTemplateShortcut(node) {
|
|
1331
|
+
if (!isTemplate(node)) return false;
|
|
1332
|
+
const attributeNames = node.getAttributeNames();
|
|
1333
|
+
if (node.hasAttribute("name")) return true;
|
|
1334
|
+
return attributeNames.some((x) => x.startsWith("#"));
|
|
1335
|
+
}
|
|
1336
|
+
__isDefaultSlotTemplateShortcut(node) {
|
|
1337
|
+
return isTemplate(node) && node.getAttributeNames().length === 0;
|
|
1338
|
+
}
|
|
1327
1339
|
__unwrapComponents(element) {
|
|
1328
|
-
var _a;
|
|
1329
1340
|
const binder = this.__binder;
|
|
1330
1341
|
const parser = binder.__parser;
|
|
1331
1342
|
const registeredComponents = binder.__config.__components;
|
|
@@ -1334,16 +1345,9 @@ var ComponentBinder = class {
|
|
|
1334
1345
|
return;
|
|
1335
1346
|
}
|
|
1336
1347
|
const contextComponents = parser.__getComponents();
|
|
1337
|
-
const
|
|
1338
|
-
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1339
|
-
const selector = [
|
|
1340
|
-
...registeredSelector ? [registeredSelector] : [],
|
|
1341
|
-
...contextComponentSelectors,
|
|
1342
|
-
...contextComponentSelectors.map(hyphenate)
|
|
1343
|
-
].join(",");
|
|
1348
|
+
const selector = this.__getComponentSelector();
|
|
1344
1349
|
if (isNullOrWhitespace(selector)) return;
|
|
1345
|
-
const
|
|
1346
|
-
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1350
|
+
const components = this.__collectTopLevelComponentHosts(element, selector);
|
|
1347
1351
|
for (const component of components) {
|
|
1348
1352
|
if (component.hasAttribute(binder.__pre)) continue;
|
|
1349
1353
|
const parent = component.parentNode;
|
|
@@ -1417,7 +1421,7 @@ var ComponentBinder = class {
|
|
|
1417
1421
|
};
|
|
1418
1422
|
const capturedContext = [...parser.__capture()];
|
|
1419
1423
|
const createComponentCtx = () => {
|
|
1420
|
-
var
|
|
1424
|
+
var _a;
|
|
1421
1425
|
const props = getProps(component, capturedContext);
|
|
1422
1426
|
const head2 = new ComponentHead(
|
|
1423
1427
|
props,
|
|
@@ -1427,8 +1431,8 @@ var ComponentBinder = class {
|
|
|
1427
1431
|
endOfComponent
|
|
1428
1432
|
);
|
|
1429
1433
|
const componentCtx2 = useScope(() => {
|
|
1430
|
-
var
|
|
1431
|
-
return (
|
|
1434
|
+
var _a2;
|
|
1435
|
+
return (_a2 = registeredComponent.context(head2)) != null ? _a2 : {};
|
|
1432
1436
|
}).context;
|
|
1433
1437
|
if (head2.autoProps) {
|
|
1434
1438
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
@@ -1452,7 +1456,7 @@ var ComponentBinder = class {
|
|
|
1452
1456
|
}
|
|
1453
1457
|
} else componentCtx2[key] = propsValue;
|
|
1454
1458
|
}
|
|
1455
|
-
(
|
|
1459
|
+
(_a = head2.onAutoPropsAssigned) == null ? void 0 : _a.call(head2);
|
|
1456
1460
|
}
|
|
1457
1461
|
return { componentCtx: componentCtx2, head: head2 };
|
|
1458
1462
|
};
|
|
@@ -1461,6 +1465,7 @@ var ComponentBinder = class {
|
|
|
1461
1465
|
const len = childNodes.length;
|
|
1462
1466
|
const isEmptyComponent = component.childNodes.length === 0;
|
|
1463
1467
|
const expandSlot = (slot) => {
|
|
1468
|
+
var _a;
|
|
1464
1469
|
const parent2 = slot.parentElement;
|
|
1465
1470
|
let name = slot.name;
|
|
1466
1471
|
if (isNullOrWhitespace(name)) {
|
|
@@ -1490,9 +1495,12 @@ var ComponentBinder = class {
|
|
|
1490
1495
|
`template[name='${name}'], template[\\#${name}]`
|
|
1491
1496
|
);
|
|
1492
1497
|
if (!compTemplate && name === "default") {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1498
|
+
const unnamedTemplates = component.querySelectorAll(
|
|
1499
|
+
"template:not([name])"
|
|
1500
|
+
);
|
|
1501
|
+
compTemplate = (_a = [...unnamedTemplates].find(
|
|
1502
|
+
(x) => this.__isDefaultSlotTemplateShortcut(x)
|
|
1503
|
+
)) != null ? _a : null;
|
|
1496
1504
|
}
|
|
1497
1505
|
const createSwitchContext = (childNodes2) => {
|
|
1498
1506
|
if (!head.enableSwitch) return;
|
|
@@ -1528,7 +1536,7 @@ var ComponentBinder = class {
|
|
|
1528
1536
|
return;
|
|
1529
1537
|
}
|
|
1530
1538
|
const childNodes2 = [...getChildNodes(component)].filter(
|
|
1531
|
-
(x) => !
|
|
1539
|
+
(x) => !this.__isNamedSlotTemplateShortcut(x)
|
|
1532
1540
|
);
|
|
1533
1541
|
for (const slotChild of childNodes2) {
|
|
1534
1542
|
parent2.insertBefore(slotChild, slot);
|
|
@@ -1614,6 +1622,65 @@ var ComponentBinder = class {
|
|
|
1614
1622
|
parser.__scoped(capturedContext, bindComponent);
|
|
1615
1623
|
}
|
|
1616
1624
|
}
|
|
1625
|
+
__getComponentSelector() {
|
|
1626
|
+
const binder = this.__binder;
|
|
1627
|
+
const parser = binder.__parser;
|
|
1628
|
+
const registeredComponents = binder.__config.__components;
|
|
1629
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1630
|
+
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1631
|
+
return [
|
|
1632
|
+
...registeredSelector ? [registeredSelector] : [],
|
|
1633
|
+
...contextComponentSelectors,
|
|
1634
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1635
|
+
].join(",");
|
|
1636
|
+
}
|
|
1637
|
+
__collectTopLevelComponentHosts(root, selector) {
|
|
1638
|
+
var _a;
|
|
1639
|
+
const result = [];
|
|
1640
|
+
if (isNullOrWhitespace(selector)) return result;
|
|
1641
|
+
if ((_a = root.matches) == null ? void 0 : _a.call(root, selector)) return [root];
|
|
1642
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1643
|
+
while (stack.length > 0) {
|
|
1644
|
+
const current = stack.pop();
|
|
1645
|
+
if (current.matches(selector)) {
|
|
1646
|
+
result.push(current);
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1650
|
+
}
|
|
1651
|
+
return result;
|
|
1652
|
+
}
|
|
1653
|
+
__forEachBindableDescendant(root, action) {
|
|
1654
|
+
const selector = this.__getComponentSelector();
|
|
1655
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1656
|
+
while (stack.length > 0) {
|
|
1657
|
+
const current = stack.pop();
|
|
1658
|
+
action(current);
|
|
1659
|
+
if (!isNullOrWhitespace(selector) && current.matches(selector)) continue;
|
|
1660
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
__getChildElements(root) {
|
|
1664
|
+
const children = root == null ? void 0 : root.children;
|
|
1665
|
+
if ((children == null ? void 0 : children.length) != null) {
|
|
1666
|
+
const result = [];
|
|
1667
|
+
for (let i = 0; i < children.length; ++i) {
|
|
1668
|
+
const child = children[i];
|
|
1669
|
+
if (isElement(child)) result.push(child);
|
|
1670
|
+
}
|
|
1671
|
+
return result;
|
|
1672
|
+
}
|
|
1673
|
+
const childNodes = root == null ? void 0 : root.childNodes;
|
|
1674
|
+
if ((childNodes == null ? void 0 : childNodes.length) != null) {
|
|
1675
|
+
const result = [];
|
|
1676
|
+
for (let i = 0; i < childNodes.length; ++i) {
|
|
1677
|
+
const child = childNodes[i];
|
|
1678
|
+
if (isElement(child)) result.push(child);
|
|
1679
|
+
}
|
|
1680
|
+
return result;
|
|
1681
|
+
}
|
|
1682
|
+
return [];
|
|
1683
|
+
}
|
|
1617
1684
|
};
|
|
1618
1685
|
|
|
1619
1686
|
// src/bind/DirectiveCollector.ts
|
|
@@ -1706,10 +1773,10 @@ var DirectiveCollector = class {
|
|
|
1706
1773
|
};
|
|
1707
1774
|
processNode(element);
|
|
1708
1775
|
if (!isRecursive || !element.firstElementChild) return map;
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
processNode
|
|
1712
|
-
|
|
1776
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1777
|
+
element,
|
|
1778
|
+
processNode
|
|
1779
|
+
);
|
|
1713
1780
|
return map;
|
|
1714
1781
|
}
|
|
1715
1782
|
};
|
|
@@ -1727,17 +1794,19 @@ var DynamicBinder = class {
|
|
|
1727
1794
|
constructor(binder) {
|
|
1728
1795
|
__publicField(this, "__binder");
|
|
1729
1796
|
__publicField(this, "__is");
|
|
1730
|
-
__publicField(this, "__isSelector");
|
|
1731
1797
|
this.__binder = binder;
|
|
1732
1798
|
this.__is = binder.__config.__builtInNames.is;
|
|
1733
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1734
1799
|
}
|
|
1735
1800
|
__bindAll(element) {
|
|
1736
1801
|
const isComponentElement = element.hasAttribute(this.__is);
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1802
|
+
if (isComponentElement || element.hasAttribute("is"))
|
|
1803
|
+
this.__bind(element);
|
|
1804
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1805
|
+
element,
|
|
1806
|
+
(el) => {
|
|
1807
|
+
if (el.hasAttribute(this.__is) || el.hasAttribute("is")) this.__bind(el);
|
|
1808
|
+
}
|
|
1809
|
+
);
|
|
1741
1810
|
return isComponentElement;
|
|
1742
1811
|
}
|
|
1743
1812
|
__bind(el) {
|
|
@@ -2214,10 +2283,13 @@ var _ForBinder = class _ForBinder {
|
|
|
2214
2283
|
}
|
|
2215
2284
|
__bindAll(element) {
|
|
2216
2285
|
const isForElement = element.hasAttribute(this.__for);
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2286
|
+
if (isForElement) this.__bindFor(element);
|
|
2287
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
2288
|
+
element,
|
|
2289
|
+
(el) => {
|
|
2290
|
+
if (el.hasAttribute(this.__for)) this.__bindFor(el);
|
|
2291
|
+
}
|
|
2292
|
+
);
|
|
2221
2293
|
return isForElement;
|
|
2222
2294
|
}
|
|
2223
2295
|
__isProcessedOrMark(el) {
|