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
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) {
|
|
@@ -804,6 +807,12 @@ var teleportDirective = {
|
|
|
804
807
|
mount: () => void 0
|
|
805
808
|
};
|
|
806
809
|
|
|
810
|
+
// src/common/class-tokens.ts
|
|
811
|
+
var toClassTokens = (value) => {
|
|
812
|
+
const trimmed = value.trim();
|
|
813
|
+
return trimmed ? trimmed.split(/\s+/) : [];
|
|
814
|
+
};
|
|
815
|
+
|
|
807
816
|
// src/composition/callMounted.ts
|
|
808
817
|
var callMounted = (context) => {
|
|
809
818
|
var _a, _b;
|
|
@@ -1318,8 +1327,16 @@ var ComponentBinder = class {
|
|
|
1318
1327
|
}
|
|
1319
1328
|
return false;
|
|
1320
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
|
+
}
|
|
1321
1339
|
__unwrapComponents(element) {
|
|
1322
|
-
var _a;
|
|
1323
1340
|
const binder = this.__binder;
|
|
1324
1341
|
const parser = binder.__parser;
|
|
1325
1342
|
const registeredComponents = binder.__config.__components;
|
|
@@ -1328,16 +1345,9 @@ var ComponentBinder = class {
|
|
|
1328
1345
|
return;
|
|
1329
1346
|
}
|
|
1330
1347
|
const contextComponents = parser.__getComponents();
|
|
1331
|
-
const
|
|
1332
|
-
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1333
|
-
const selector = [
|
|
1334
|
-
...registeredSelector ? [registeredSelector] : [],
|
|
1335
|
-
...contextComponentSelectors,
|
|
1336
|
-
...contextComponentSelectors.map(hyphenate)
|
|
1337
|
-
].join(",");
|
|
1348
|
+
const selector = this.__getComponentSelector();
|
|
1338
1349
|
if (isNullOrWhitespace(selector)) return;
|
|
1339
|
-
const
|
|
1340
|
-
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1350
|
+
const components = this.__collectTopLevelComponentHosts(element, selector);
|
|
1341
1351
|
for (const component of components) {
|
|
1342
1352
|
if (component.hasAttribute(binder.__pre)) continue;
|
|
1343
1353
|
const parent = component.parentNode;
|
|
@@ -1411,7 +1421,7 @@ var ComponentBinder = class {
|
|
|
1411
1421
|
};
|
|
1412
1422
|
const capturedContext = [...parser.__capture()];
|
|
1413
1423
|
const createComponentCtx = () => {
|
|
1414
|
-
var
|
|
1424
|
+
var _a;
|
|
1415
1425
|
const props = getProps(component, capturedContext);
|
|
1416
1426
|
const head2 = new ComponentHead(
|
|
1417
1427
|
props,
|
|
@@ -1421,8 +1431,8 @@ var ComponentBinder = class {
|
|
|
1421
1431
|
endOfComponent
|
|
1422
1432
|
);
|
|
1423
1433
|
const componentCtx2 = useScope(() => {
|
|
1424
|
-
var
|
|
1425
|
-
return (
|
|
1434
|
+
var _a2;
|
|
1435
|
+
return (_a2 = registeredComponent.context(head2)) != null ? _a2 : {};
|
|
1426
1436
|
}).context;
|
|
1427
1437
|
if (head2.autoProps) {
|
|
1428
1438
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
@@ -1446,7 +1456,7 @@ var ComponentBinder = class {
|
|
|
1446
1456
|
}
|
|
1447
1457
|
} else componentCtx2[key] = propsValue;
|
|
1448
1458
|
}
|
|
1449
|
-
(
|
|
1459
|
+
(_a = head2.onAutoPropsAssigned) == null ? void 0 : _a.call(head2);
|
|
1450
1460
|
}
|
|
1451
1461
|
return { componentCtx: componentCtx2, head: head2 };
|
|
1452
1462
|
};
|
|
@@ -1455,6 +1465,7 @@ var ComponentBinder = class {
|
|
|
1455
1465
|
const len = childNodes.length;
|
|
1456
1466
|
const isEmptyComponent = component.childNodes.length === 0;
|
|
1457
1467
|
const expandSlot = (slot) => {
|
|
1468
|
+
var _a;
|
|
1458
1469
|
const parent2 = slot.parentElement;
|
|
1459
1470
|
let name = slot.name;
|
|
1460
1471
|
if (isNullOrWhitespace(name)) {
|
|
@@ -1484,9 +1495,12 @@ var ComponentBinder = class {
|
|
|
1484
1495
|
`template[name='${name}'], template[\\#${name}]`
|
|
1485
1496
|
);
|
|
1486
1497
|
if (!compTemplate && name === "default") {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1498
|
+
const unnamedTemplates = component.querySelectorAll(
|
|
1499
|
+
"template:not([name])"
|
|
1500
|
+
);
|
|
1501
|
+
compTemplate = (_a = [...unnamedTemplates].find(
|
|
1502
|
+
(x) => this.__isDefaultSlotTemplateShortcut(x)
|
|
1503
|
+
)) != null ? _a : null;
|
|
1490
1504
|
}
|
|
1491
1505
|
const createSwitchContext = (childNodes2) => {
|
|
1492
1506
|
if (!head.enableSwitch) return;
|
|
@@ -1522,7 +1536,7 @@ var ComponentBinder = class {
|
|
|
1522
1536
|
return;
|
|
1523
1537
|
}
|
|
1524
1538
|
const childNodes2 = [...getChildNodes(component)].filter(
|
|
1525
|
-
(x) => !
|
|
1539
|
+
(x) => !this.__isNamedSlotTemplateShortcut(x)
|
|
1526
1540
|
);
|
|
1527
1541
|
for (const slotChild of childNodes2) {
|
|
1528
1542
|
parent2.insertBefore(slotChild, slot);
|
|
@@ -1568,7 +1582,8 @@ var ComponentBinder = class {
|
|
|
1568
1582
|
continue;
|
|
1569
1583
|
const value = component.getAttribute(attrName);
|
|
1570
1584
|
if (attrName === "class") {
|
|
1571
|
-
|
|
1585
|
+
const classTokens = toClassTokens(value);
|
|
1586
|
+
if (classTokens.length > 0) inheritor.classList.add(...classTokens);
|
|
1572
1587
|
} else if (attrName === "style") {
|
|
1573
1588
|
const inheritorStyle = inheritor.style;
|
|
1574
1589
|
const componentStyle = component.style;
|
|
@@ -1607,6 +1622,65 @@ var ComponentBinder = class {
|
|
|
1607
1622
|
parser.__scoped(capturedContext, bindComponent);
|
|
1608
1623
|
}
|
|
1609
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
|
+
}
|
|
1610
1684
|
};
|
|
1611
1685
|
|
|
1612
1686
|
// src/bind/DirectiveCollector.ts
|
|
@@ -1699,10 +1773,10 @@ var DirectiveCollector = class {
|
|
|
1699
1773
|
};
|
|
1700
1774
|
processNode(element);
|
|
1701
1775
|
if (!isRecursive || !element.firstElementChild) return map;
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
processNode
|
|
1705
|
-
|
|
1776
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1777
|
+
element,
|
|
1778
|
+
processNode
|
|
1779
|
+
);
|
|
1706
1780
|
return map;
|
|
1707
1781
|
}
|
|
1708
1782
|
};
|
|
@@ -1720,17 +1794,19 @@ var DynamicBinder = class {
|
|
|
1720
1794
|
constructor(binder) {
|
|
1721
1795
|
__publicField(this, "__binder");
|
|
1722
1796
|
__publicField(this, "__is");
|
|
1723
|
-
__publicField(this, "__isSelector");
|
|
1724
1797
|
this.__binder = binder;
|
|
1725
1798
|
this.__is = binder.__config.__builtInNames.is;
|
|
1726
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1727
1799
|
}
|
|
1728
1800
|
__bindAll(element) {
|
|
1729
1801
|
const isComponentElement = element.hasAttribute(this.__is);
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
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
|
+
);
|
|
1734
1810
|
return isComponentElement;
|
|
1735
1811
|
}
|
|
1736
1812
|
__bind(el) {
|
|
@@ -2207,10 +2283,13 @@ var _ForBinder = class _ForBinder {
|
|
|
2207
2283
|
}
|
|
2208
2284
|
__bindAll(element) {
|
|
2209
2285
|
const isForElement = element.hasAttribute(this.__for);
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
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
|
+
);
|
|
2214
2293
|
return isForElement;
|
|
2215
2294
|
}
|
|
2216
2295
|
__isProcessedOrMark(el) {
|
|
@@ -2936,11 +3015,14 @@ var patchClass = (el, next, prev) => {
|
|
|
2936
3015
|
} else {
|
|
2937
3016
|
if (isClassString) {
|
|
2938
3017
|
if (prev !== next) {
|
|
2939
|
-
|
|
2940
|
-
|
|
3018
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
3019
|
+
const nextTokens = toClassTokens(next);
|
|
3020
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3021
|
+
if (nextTokens.length > 0) classList.add(...nextTokens);
|
|
2941
3022
|
}
|
|
2942
3023
|
} else if (prev) {
|
|
2943
|
-
|
|
3024
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
3025
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
2944
3026
|
}
|
|
2945
3027
|
}
|
|
2946
3028
|
};
|