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.es2015.esm.js
CHANGED
|
@@ -501,10 +501,13 @@ var IfBinder = class {
|
|
|
501
501
|
}
|
|
502
502
|
__bindAll(element) {
|
|
503
503
|
const isIfElement = element.hasAttribute(this.__if);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
504
|
+
if (isIfElement) this.__bind(element);
|
|
505
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
506
|
+
element,
|
|
507
|
+
(el) => {
|
|
508
|
+
if (el.hasAttribute(this.__if)) this.__bind(el);
|
|
509
|
+
}
|
|
510
|
+
);
|
|
508
511
|
return isIfElement;
|
|
509
512
|
}
|
|
510
513
|
__isProcessedOrMark(el) {
|
|
@@ -776,6 +779,12 @@ var teleportDirective = {
|
|
|
776
779
|
mount: () => void 0
|
|
777
780
|
};
|
|
778
781
|
|
|
782
|
+
// src/common/class-tokens.ts
|
|
783
|
+
var toClassTokens = (value) => {
|
|
784
|
+
const trimmed = value.trim();
|
|
785
|
+
return trimmed ? trimmed.split(/\s+/) : [];
|
|
786
|
+
};
|
|
787
|
+
|
|
779
788
|
// src/composition/callMounted.ts
|
|
780
789
|
var callMounted = (context) => {
|
|
781
790
|
var _a, _b;
|
|
@@ -1290,8 +1299,16 @@ var ComponentBinder = class {
|
|
|
1290
1299
|
}
|
|
1291
1300
|
return false;
|
|
1292
1301
|
}
|
|
1302
|
+
__isNamedSlotTemplateShortcut(node) {
|
|
1303
|
+
if (!isTemplate(node)) return false;
|
|
1304
|
+
const attributeNames = node.getAttributeNames();
|
|
1305
|
+
if (node.hasAttribute("name")) return true;
|
|
1306
|
+
return attributeNames.some((x) => x.startsWith("#"));
|
|
1307
|
+
}
|
|
1308
|
+
__isDefaultSlotTemplateShortcut(node) {
|
|
1309
|
+
return isTemplate(node) && node.getAttributeNames().length === 0;
|
|
1310
|
+
}
|
|
1293
1311
|
__unwrapComponents(element) {
|
|
1294
|
-
var _a;
|
|
1295
1312
|
const binder = this.__binder;
|
|
1296
1313
|
const parser = binder.__parser;
|
|
1297
1314
|
const registeredComponents = binder.__config.__components;
|
|
@@ -1300,16 +1317,9 @@ var ComponentBinder = class {
|
|
|
1300
1317
|
return;
|
|
1301
1318
|
}
|
|
1302
1319
|
const contextComponents = parser.__getComponents();
|
|
1303
|
-
const
|
|
1304
|
-
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1305
|
-
const selector = [
|
|
1306
|
-
...registeredSelector ? [registeredSelector] : [],
|
|
1307
|
-
...contextComponentSelectors,
|
|
1308
|
-
...contextComponentSelectors.map(hyphenate)
|
|
1309
|
-
].join(",");
|
|
1320
|
+
const selector = this.__getComponentSelector();
|
|
1310
1321
|
if (isNullOrWhitespace(selector)) return;
|
|
1311
|
-
const
|
|
1312
|
-
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1322
|
+
const components = this.__collectTopLevelComponentHosts(element, selector);
|
|
1313
1323
|
for (const component of components) {
|
|
1314
1324
|
if (component.hasAttribute(binder.__pre)) continue;
|
|
1315
1325
|
const parent = component.parentNode;
|
|
@@ -1383,7 +1393,7 @@ var ComponentBinder = class {
|
|
|
1383
1393
|
};
|
|
1384
1394
|
const capturedContext = [...parser.__capture()];
|
|
1385
1395
|
const createComponentCtx = () => {
|
|
1386
|
-
var
|
|
1396
|
+
var _a;
|
|
1387
1397
|
const props = getProps(component, capturedContext);
|
|
1388
1398
|
const head2 = new ComponentHead(
|
|
1389
1399
|
props,
|
|
@@ -1393,8 +1403,8 @@ var ComponentBinder = class {
|
|
|
1393
1403
|
endOfComponent
|
|
1394
1404
|
);
|
|
1395
1405
|
const componentCtx2 = useScope(() => {
|
|
1396
|
-
var
|
|
1397
|
-
return (
|
|
1406
|
+
var _a2;
|
|
1407
|
+
return (_a2 = registeredComponent.context(head2)) != null ? _a2 : {};
|
|
1398
1408
|
}).context;
|
|
1399
1409
|
if (head2.autoProps) {
|
|
1400
1410
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
@@ -1418,7 +1428,7 @@ var ComponentBinder = class {
|
|
|
1418
1428
|
}
|
|
1419
1429
|
} else componentCtx2[key] = propsValue;
|
|
1420
1430
|
}
|
|
1421
|
-
(
|
|
1431
|
+
(_a = head2.onAutoPropsAssigned) == null ? void 0 : _a.call(head2);
|
|
1422
1432
|
}
|
|
1423
1433
|
return { componentCtx: componentCtx2, head: head2 };
|
|
1424
1434
|
};
|
|
@@ -1427,6 +1437,7 @@ var ComponentBinder = class {
|
|
|
1427
1437
|
const len = childNodes.length;
|
|
1428
1438
|
const isEmptyComponent = component.childNodes.length === 0;
|
|
1429
1439
|
const expandSlot = (slot) => {
|
|
1440
|
+
var _a;
|
|
1430
1441
|
const parent2 = slot.parentElement;
|
|
1431
1442
|
let name = slot.name;
|
|
1432
1443
|
if (isNullOrWhitespace(name)) {
|
|
@@ -1456,9 +1467,12 @@ var ComponentBinder = class {
|
|
|
1456
1467
|
`template[name='${name}'], template[\\#${name}]`
|
|
1457
1468
|
);
|
|
1458
1469
|
if (!compTemplate && name === "default") {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1470
|
+
const unnamedTemplates = component.querySelectorAll(
|
|
1471
|
+
"template:not([name])"
|
|
1472
|
+
);
|
|
1473
|
+
compTemplate = (_a = [...unnamedTemplates].find(
|
|
1474
|
+
(x) => this.__isDefaultSlotTemplateShortcut(x)
|
|
1475
|
+
)) != null ? _a : null;
|
|
1462
1476
|
}
|
|
1463
1477
|
const createSwitchContext = (childNodes2) => {
|
|
1464
1478
|
if (!head.enableSwitch) return;
|
|
@@ -1494,7 +1508,7 @@ var ComponentBinder = class {
|
|
|
1494
1508
|
return;
|
|
1495
1509
|
}
|
|
1496
1510
|
const childNodes2 = [...getChildNodes(component)].filter(
|
|
1497
|
-
(x) => !
|
|
1511
|
+
(x) => !this.__isNamedSlotTemplateShortcut(x)
|
|
1498
1512
|
);
|
|
1499
1513
|
for (const slotChild of childNodes2) {
|
|
1500
1514
|
parent2.insertBefore(slotChild, slot);
|
|
@@ -1540,7 +1554,8 @@ var ComponentBinder = class {
|
|
|
1540
1554
|
continue;
|
|
1541
1555
|
const value = component.getAttribute(attrName);
|
|
1542
1556
|
if (attrName === "class") {
|
|
1543
|
-
|
|
1557
|
+
const classTokens = toClassTokens(value);
|
|
1558
|
+
if (classTokens.length > 0) inheritor.classList.add(...classTokens);
|
|
1544
1559
|
} else if (attrName === "style") {
|
|
1545
1560
|
const inheritorStyle = inheritor.style;
|
|
1546
1561
|
const componentStyle = component.style;
|
|
@@ -1579,6 +1594,65 @@ var ComponentBinder = class {
|
|
|
1579
1594
|
parser.__scoped(capturedContext, bindComponent);
|
|
1580
1595
|
}
|
|
1581
1596
|
}
|
|
1597
|
+
__getComponentSelector() {
|
|
1598
|
+
const binder = this.__binder;
|
|
1599
|
+
const parser = binder.__parser;
|
|
1600
|
+
const registeredComponents = binder.__config.__components;
|
|
1601
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1602
|
+
const registeredSelector = this.__getRegisteredComponentSelector(registeredComponents);
|
|
1603
|
+
return [
|
|
1604
|
+
...registeredSelector ? [registeredSelector] : [],
|
|
1605
|
+
...contextComponentSelectors,
|
|
1606
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1607
|
+
].join(",");
|
|
1608
|
+
}
|
|
1609
|
+
__collectTopLevelComponentHosts(root, selector) {
|
|
1610
|
+
var _a;
|
|
1611
|
+
const result = [];
|
|
1612
|
+
if (isNullOrWhitespace(selector)) return result;
|
|
1613
|
+
if ((_a = root.matches) == null ? void 0 : _a.call(root, selector)) return [root];
|
|
1614
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1615
|
+
while (stack.length > 0) {
|
|
1616
|
+
const current = stack.pop();
|
|
1617
|
+
if (current.matches(selector)) {
|
|
1618
|
+
result.push(current);
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1622
|
+
}
|
|
1623
|
+
return result;
|
|
1624
|
+
}
|
|
1625
|
+
__forEachBindableDescendant(root, action) {
|
|
1626
|
+
const selector = this.__getComponentSelector();
|
|
1627
|
+
const stack = this.__getChildElements(root).reverse();
|
|
1628
|
+
while (stack.length > 0) {
|
|
1629
|
+
const current = stack.pop();
|
|
1630
|
+
action(current);
|
|
1631
|
+
if (!isNullOrWhitespace(selector) && current.matches(selector)) continue;
|
|
1632
|
+
stack.push(...this.__getChildElements(current).reverse());
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
__getChildElements(root) {
|
|
1636
|
+
const children = root == null ? void 0 : root.children;
|
|
1637
|
+
if ((children == null ? void 0 : children.length) != null) {
|
|
1638
|
+
const result = [];
|
|
1639
|
+
for (let i = 0; i < children.length; ++i) {
|
|
1640
|
+
const child = children[i];
|
|
1641
|
+
if (isElement(child)) result.push(child);
|
|
1642
|
+
}
|
|
1643
|
+
return result;
|
|
1644
|
+
}
|
|
1645
|
+
const childNodes = root == null ? void 0 : root.childNodes;
|
|
1646
|
+
if ((childNodes == null ? void 0 : childNodes.length) != null) {
|
|
1647
|
+
const result = [];
|
|
1648
|
+
for (let i = 0; i < childNodes.length; ++i) {
|
|
1649
|
+
const child = childNodes[i];
|
|
1650
|
+
if (isElement(child)) result.push(child);
|
|
1651
|
+
}
|
|
1652
|
+
return result;
|
|
1653
|
+
}
|
|
1654
|
+
return [];
|
|
1655
|
+
}
|
|
1582
1656
|
};
|
|
1583
1657
|
|
|
1584
1658
|
// src/bind/DirectiveCollector.ts
|
|
@@ -1671,10 +1745,10 @@ var DirectiveCollector = class {
|
|
|
1671
1745
|
};
|
|
1672
1746
|
processNode(element);
|
|
1673
1747
|
if (!isRecursive || !element.firstElementChild) return map;
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
processNode
|
|
1677
|
-
|
|
1748
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1749
|
+
element,
|
|
1750
|
+
processNode
|
|
1751
|
+
);
|
|
1678
1752
|
return map;
|
|
1679
1753
|
}
|
|
1680
1754
|
};
|
|
@@ -1692,17 +1766,19 @@ var DynamicBinder = class {
|
|
|
1692
1766
|
constructor(binder) {
|
|
1693
1767
|
__publicField(this, "__binder");
|
|
1694
1768
|
__publicField(this, "__is");
|
|
1695
|
-
__publicField(this, "__isSelector");
|
|
1696
1769
|
this.__binder = binder;
|
|
1697
1770
|
this.__is = binder.__config.__builtInNames.is;
|
|
1698
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1699
1771
|
}
|
|
1700
1772
|
__bindAll(element) {
|
|
1701
1773
|
const isComponentElement = element.hasAttribute(this.__is);
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1774
|
+
if (isComponentElement || element.hasAttribute("is"))
|
|
1775
|
+
this.__bind(element);
|
|
1776
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
1777
|
+
element,
|
|
1778
|
+
(el) => {
|
|
1779
|
+
if (el.hasAttribute(this.__is) || el.hasAttribute("is")) this.__bind(el);
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1706
1782
|
return isComponentElement;
|
|
1707
1783
|
}
|
|
1708
1784
|
__bind(el) {
|
|
@@ -2179,10 +2255,13 @@ var _ForBinder = class _ForBinder {
|
|
|
2179
2255
|
}
|
|
2180
2256
|
__bindAll(element) {
|
|
2181
2257
|
const isForElement = element.hasAttribute(this.__for);
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2258
|
+
if (isForElement) this.__bindFor(element);
|
|
2259
|
+
this.__binder.__componentBinder.__forEachBindableDescendant(
|
|
2260
|
+
element,
|
|
2261
|
+
(el) => {
|
|
2262
|
+
if (el.hasAttribute(this.__for)) this.__bindFor(el);
|
|
2263
|
+
}
|
|
2264
|
+
);
|
|
2186
2265
|
return isForElement;
|
|
2187
2266
|
}
|
|
2188
2267
|
__isProcessedOrMark(el) {
|
|
@@ -2908,11 +2987,14 @@ var patchClass = (el, next, prev) => {
|
|
|
2908
2987
|
} else {
|
|
2909
2988
|
if (isClassString) {
|
|
2910
2989
|
if (prev !== next) {
|
|
2911
|
-
|
|
2912
|
-
|
|
2990
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
2991
|
+
const nextTokens = toClassTokens(next);
|
|
2992
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
2993
|
+
if (nextTokens.length > 0) classList.add(...nextTokens);
|
|
2913
2994
|
}
|
|
2914
2995
|
} else if (prev) {
|
|
2915
|
-
|
|
2996
|
+
const prevTokens = isPrevClassString ? toClassTokens(prev) : [];
|
|
2997
|
+
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
2916
2998
|
}
|
|
2917
2999
|
}
|
|
2918
3000
|
};
|