regor 1.4.3 → 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 +122 -40
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +122 -40
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +122 -40
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +122 -40
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +122 -40
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +122 -40
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +116 -35
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +116 -35
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +116 -35
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
|
@@ -566,10 +566,13 @@ var Regor = (() => {
|
|
|
566
566
|
}
|
|
567
567
|
__bindAll(element) {
|
|
568
568
|
const isIfElement = element.hasAttribute(this.__if);
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
569
|
+
if (isIfElement) this.__bind(element);
|
|
570
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
571
|
+
element,
|
|
572
|
+
(el) => {
|
|
573
|
+
if (el.hasAttribute(this.__if)) this.__bind(el);
|
|
574
|
+
}
|
|
575
|
+
);
|
|
573
576
|
return isIfElement;
|
|
574
577
|
}
|
|
575
578
|
__isProcessedOrMark(el) {
|
|
@@ -841,6 +844,12 @@ var Regor = (() => {
|
|
|
841
844
|
mount: () => void 0
|
|
842
845
|
};
|
|
843
846
|
|
|
847
|
+
// src/common/class-tokens.ts
|
|
848
|
+
var toClassTokens = (value) => {
|
|
849
|
+
const trimmed = value.trim();
|
|
850
|
+
return trimmed ? trimmed.split(/\s+/) : [];
|
|
851
|
+
};
|
|
852
|
+
|
|
844
853
|
// src/composition/callMounted.ts
|
|
845
854
|
var callMounted = (context) => {
|
|
846
855
|
var _a, _b;
|
|
@@ -1355,8 +1364,16 @@ var Regor = (() => {
|
|
|
1355
1364
|
}
|
|
1356
1365
|
return false;
|
|
1357
1366
|
}
|
|
1367
|
+
__isNamedSlotTemplateShortcut(node) {
|
|
1368
|
+
if (!isTemplate(node)) return false;
|
|
1369
|
+
const attributeNames = node.getAttributeNames();
|
|
1370
|
+
if (node.hasAttribute("name")) return true;
|
|
1371
|
+
return attributeNames.some((x) => x.startsWith("#"));
|
|
1372
|
+
}
|
|
1373
|
+
__isDefaultSlotTemplateShortcut(node) {
|
|
1374
|
+
return isTemplate(node) && node.getAttributeNames().length === 0;
|
|
1375
|
+
}
|
|
1358
1376
|
__unwrapComponents(element) {
|
|
1359
|
-
var _a;
|
|
1360
1377
|
const binder = this.__binder;
|
|
1361
1378
|
const parser = binder.__parser;
|
|
1362
1379
|
const registeredComponents = binder.__config.__components;
|
|
@@ -1365,16 +1382,9 @@ var Regor = (() => {
|
|
|
1365
1382
|
return;
|
|
1366
1383
|
}
|
|
1367
1384
|
const contextComponents = parser.__getComponents();
|
|
1368
|
-
const
|
|
1369
|
-
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1370
|
-
const selector = [
|
|
1371
|
-
...registeredSelector ? [registeredSelector] : [],
|
|
1372
|
-
...contextComponentSelectors,
|
|
1373
|
-
...contextComponentSelectors.map(hyphenate)
|
|
1374
|
-
].join(",");
|
|
1385
|
+
const selector = this.__getComponentSelector();
|
|
1375
1386
|
if (isNullOrWhitespace(selector)) return;
|
|
1376
|
-
const
|
|
1377
|
-
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1387
|
+
const components = this.__collectTopLevelComponentHosts(element, selector);
|
|
1378
1388
|
for (const component of components) {
|
|
1379
1389
|
if (component.hasAttribute(binder.__pre)) continue;
|
|
1380
1390
|
const parent = component.parentNode;
|
|
@@ -1448,7 +1458,7 @@ var Regor = (() => {
|
|
|
1448
1458
|
};
|
|
1449
1459
|
const capturedContext = [...parser.__capture()];
|
|
1450
1460
|
const createComponentCtx = () => {
|
|
1451
|
-
var
|
|
1461
|
+
var _a;
|
|
1452
1462
|
const props = getProps(component, capturedContext);
|
|
1453
1463
|
const head2 = new ComponentHead(
|
|
1454
1464
|
props,
|
|
@@ -1458,8 +1468,8 @@ var Regor = (() => {
|
|
|
1458
1468
|
endOfComponent
|
|
1459
1469
|
);
|
|
1460
1470
|
const componentCtx2 = useScope(() => {
|
|
1461
|
-
var
|
|
1462
|
-
return (
|
|
1471
|
+
var _a2;
|
|
1472
|
+
return (_a2 = registeredComponent.context(head2)) != null ? _a2 : {};
|
|
1463
1473
|
}).context;
|
|
1464
1474
|
if (head2.autoProps) {
|
|
1465
1475
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
@@ -1483,7 +1493,7 @@ var Regor = (() => {
|
|
|
1483
1493
|
}
|
|
1484
1494
|
} else componentCtx2[key] = propsValue;
|
|
1485
1495
|
}
|
|
1486
|
-
(
|
|
1496
|
+
(_a = head2.onAutoPropsAssigned) == null ? void 0 : _a.call(head2);
|
|
1487
1497
|
}
|
|
1488
1498
|
return { componentCtx: componentCtx2, head: head2 };
|
|
1489
1499
|
};
|
|
@@ -1492,6 +1502,7 @@ var Regor = (() => {
|
|
|
1492
1502
|
const len = childNodes.length;
|
|
1493
1503
|
const isEmptyComponent = component.childNodes.length === 0;
|
|
1494
1504
|
const expandSlot = (slot) => {
|
|
1505
|
+
var _a;
|
|
1495
1506
|
const parent2 = slot.parentElement;
|
|
1496
1507
|
let name = slot.name;
|
|
1497
1508
|
if (isNullOrWhitespace(name)) {
|
|
@@ -1521,9 +1532,12 @@ var Regor = (() => {
|
|
|
1521
1532
|
`template[name='${name}'], template[\\#${name}]`
|
|
1522
1533
|
);
|
|
1523
1534
|
if (!compTemplate && name === "default") {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1535
|
+
const unnamedTemplates = component.querySelectorAll(
|
|
1536
|
+
"template:not([name])"
|
|
1537
|
+
);
|
|
1538
|
+
compTemplate = (_a = [...unnamedTemplates].find(
|
|
1539
|
+
(x) => this.__isDefaultSlotTemplateShortcut(x)
|
|
1540
|
+
)) != null ? _a : null;
|
|
1527
1541
|
}
|
|
1528
1542
|
const createSwitchContext = (childNodes2) => {
|
|
1529
1543
|
if (!head.enableSwitch) return;
|
|
@@ -1559,7 +1573,7 @@ var Regor = (() => {
|
|
|
1559
1573
|
return;
|
|
1560
1574
|
}
|
|
1561
1575
|
const childNodes2 = [...getChildNodes(component)].filter(
|
|
1562
|
-
(x) => !
|
|
1576
|
+
(x) => !this.__isNamedSlotTemplateShortcut(x)
|
|
1563
1577
|
);
|
|
1564
1578
|
for (const slotChild of childNodes2) {
|
|
1565
1579
|
parent2.insertBefore(slotChild, slot);
|
|
@@ -1605,7 +1619,8 @@ var Regor = (() => {
|
|
|
1605
1619
|
continue;
|
|
1606
1620
|
const value = component.getAttribute(attrName);
|
|
1607
1621
|
if (attrName === "class") {
|
|
1608
|
-
|
|
1622
|
+
const classTokens = toClassTokens(value);
|
|
1623
|
+
if (classTokens.length > 0) inheritor.classList.add(...classTokens);
|
|
1609
1624
|
} else if (attrName === "style") {
|
|
1610
1625
|
const inheritorStyle = inheritor.style;
|
|
1611
1626
|
const componentStyle = component.style;
|
|
@@ -1644,6 +1659,65 @@ var Regor = (() => {
|
|
|
1644
1659
|
parser.__scoped(capturedContext, bindComponent);
|
|
1645
1660
|
}
|
|
1646
1661
|
}
|
|
1662
|
+
__getComponentSelector() {
|
|
1663
|
+
const binder = this.__binder;
|
|
1664
|
+
const parser = binder.__parser;
|
|
1665
|
+
const registeredComponents = binder.__config.__components;
|
|
1666
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1667
|
+
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1668
|
+
return [
|
|
1669
|
+
...registeredSelector ? [registeredSelector] : [],
|
|
1670
|
+
...contextComponentSelectors,
|
|
1671
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1672
|
+
].join(",");
|
|
1673
|
+
}
|
|
1674
|
+
__collectTopLevelComponentHosts(root, selector) {
|
|
1675
|
+
var _a;
|
|
1676
|
+
const result = [];
|
|
1677
|
+
if (isNullOrWhitespace(selector)) return result;
|
|
1678
|
+
if ((_a = root.matches) == null ? void 0 : _a.call(root, selector)) return [root];
|
|
1679
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1680
|
+
while (stack.length > 0) {
|
|
1681
|
+
const current = stack.pop();
|
|
1682
|
+
if (current.matches(selector)) {
|
|
1683
|
+
result.push(current);
|
|
1684
|
+
continue;
|
|
1685
|
+
}
|
|
1686
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1687
|
+
}
|
|
1688
|
+
return result;
|
|
1689
|
+
}
|
|
1690
|
+
__forEachBindableDescendant(root, action) {
|
|
1691
|
+
const selector = this.__getComponentSelector();
|
|
1692
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1693
|
+
while (stack.length > 0) {
|
|
1694
|
+
const current = stack.pop();
|
|
1695
|
+
action(current);
|
|
1696
|
+
if (!isNullOrWhitespace(selector) && current.matches(selector)) continue;
|
|
1697
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
__getChildElements(root) {
|
|
1701
|
+
const children = root == null ? void 0 : root.children;
|
|
1702
|
+
if ((children == null ? void 0 : children.length) != null) {
|
|
1703
|
+
const result = [];
|
|
1704
|
+
for (let i = 0; i < children.length; ++i) {
|
|
1705
|
+
const child = children[i];
|
|
1706
|
+
if (isElement(child)) result.push(child);
|
|
1707
|
+
}
|
|
1708
|
+
return result;
|
|
1709
|
+
}
|
|
1710
|
+
const childNodes = root == null ? void 0 : root.childNodes;
|
|
1711
|
+
if ((childNodes == null ? void 0 : childNodes.length) != null) {
|
|
1712
|
+
const result = [];
|
|
1713
|
+
for (let i = 0; i < childNodes.length; ++i) {
|
|
1714
|
+
const child = childNodes[i];
|
|
1715
|
+
if (isElement(child)) result.push(child);
|
|
1716
|
+
}
|
|
1717
|
+
return result;
|
|
1718
|
+
}
|
|
1719
|
+
return [];
|
|
1720
|
+
}
|
|
1647
1721
|
};
|
|
1648
1722
|
|
|
1649
1723
|
// src/bind/DirectiveCollector.ts
|
|
@@ -1736,10 +1810,10 @@ var Regor = (() => {
|
|
|
1736
1810
|
};
|
|
1737
1811
|
processNode(element);
|
|
1738
1812
|
if (!isRecursive || !element.firstElementChild) return map;
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
processNode
|
|
1742
|
-
|
|
1813
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1814
|
+
element,
|
|
1815
|
+
processNode
|
|
1816
|
+
);
|
|
1743
1817
|
return map;
|
|
1744
1818
|
}
|
|
1745
1819
|
};
|
|
@@ -1757,17 +1831,19 @@ var Regor = (() => {
|
|
|
1757
1831
|
constructor(binder) {
|
|
1758
1832
|
__publicField(this, "__binder");
|
|
1759
1833
|
__publicField(this, "__is");
|
|
1760
|
-
__publicField(this, "__isSelector");
|
|
1761
1834
|
this.__binder = binder;
|
|
1762
1835
|
this.__is = binder.__config.__builtInNames.is;
|
|
1763
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1764
1836
|
}
|
|
1765
1837
|
__bindAll(element) {
|
|
1766
1838
|
const isComponentElement = element.hasAttribute(this.__is);
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1839
|
+
if (isComponentElement || element.hasAttribute("is"))
|
|
1840
|
+
this.__bind(element);
|
|
1841
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1842
|
+
element,
|
|
1843
|
+
(el) => {
|
|
1844
|
+
if (el.hasAttribute(this.__is) || el.hasAttribute("is")) this.__bind(el);
|
|
1845
|
+
}
|
|
1846
|
+
);
|
|
1771
1847
|
return isComponentElement;
|
|
1772
1848
|
}
|
|
1773
1849
|
__bind(el) {
|
|
@@ -2244,10 +2320,13 @@ var Regor = (() => {
|
|
|
2244
2320
|
}
|
|
2245
2321
|
__bindAll(element) {
|
|
2246
2322
|
const isForElement = element.hasAttribute(this.__for);
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2323
|
+
if (isForElement) this.__bindFor(element);
|
|
2324
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
2325
|
+
element,
|
|
2326
|
+
(el) => {
|
|
2327
|
+
if (el.hasAttribute(this.__for)) this.__bindFor(el);
|
|
2328
|
+
}
|
|
2329
|
+
);
|
|
2251
2330
|
return isForElement;
|
|
2252
2331
|
}
|
|
2253
2332
|
__isProcessedOrMark(el) {
|
|
@@ -2973,11 +3052,14 @@ var Regor = (() => {
|
|
|
2973
3052
|
} else {
|
|
2974
3053
|
if (isClassString) {
|
|
2975
3054
|
if (prev !== next) {
|
|
2976
|
-
|
|
2977
|
-
|
|
3055
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
3056
|
+
const nextTokens = toClassTokens(next);
|
|
3057
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3058
|
+
if (nextTokens.length > 0) classList.add(...nextTokens);
|
|
2978
3059
|
}
|
|
2979
3060
|
} else if (prev) {
|
|
2980
|
-
|
|
3061
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
3062
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
2981
3063
|
}
|
|
2982
3064
|
}
|
|
2983
3065
|
};
|