regor 1.5.6 → 1.5.8
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 +79 -37
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +79 -37
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +79 -37
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +79 -37
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +79 -37
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +79 -37
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +79 -37
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +79 -37
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +79 -37
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2015.esm.js
CHANGED
|
@@ -1673,7 +1673,9 @@ var ComponentBinder = class {
|
|
|
1673
1673
|
const contextAliasName = binder.__config.__builtInNames.contextAlias;
|
|
1674
1674
|
const bindName = binder.__config.__builtInNames.bind;
|
|
1675
1675
|
const definedProps = (_b = (_a = registeredComponent.props) == null ? void 0 : _a.map(camelize)) != null ? _b : [];
|
|
1676
|
-
const
|
|
1676
|
+
const inheritedPropAttrs = [];
|
|
1677
|
+
const isInheritableSpecialProp = (propName) => propName === "class" || propName === "style";
|
|
1678
|
+
const getProps = (component2, capturedContext2, collectInheritedPropAttrs = false) => {
|
|
1677
1679
|
const props = {};
|
|
1678
1680
|
const hasContext = component2.hasAttribute(contextName);
|
|
1679
1681
|
parser.__scoped(capturedContext2, () => {
|
|
@@ -1696,7 +1698,11 @@ var ComponentBinder = class {
|
|
|
1696
1698
|
]) {
|
|
1697
1699
|
const value = component2.getAttribute(name);
|
|
1698
1700
|
if (value === null) continue;
|
|
1699
|
-
|
|
1701
|
+
const propName = camelize(name);
|
|
1702
|
+
props[propName] = value;
|
|
1703
|
+
if (collectInheritedPropAttrs && registeredComponent.inheritAttrs === true && isInheritableSpecialProp(propName)) {
|
|
1704
|
+
inheritedPropAttrs.push({ name, value });
|
|
1705
|
+
}
|
|
1700
1706
|
component2.removeAttribute(name);
|
|
1701
1707
|
}
|
|
1702
1708
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
@@ -1708,6 +1714,11 @@ var ComponentBinder = class {
|
|
|
1708
1714
|
);
|
|
1709
1715
|
if (!propName) continue;
|
|
1710
1716
|
if (name !== "." && name !== ":" && name !== bindName) continue;
|
|
1717
|
+
if (collectInheritedPropAttrs && name !== "." && registeredComponent.inheritAttrs === true && isInheritableSpecialProp(propName)) {
|
|
1718
|
+
const value = component2.getAttribute(attrName);
|
|
1719
|
+
if (value !== null)
|
|
1720
|
+
inheritedPropAttrs.push({ name: attrName, value });
|
|
1721
|
+
}
|
|
1711
1722
|
binder.__bind(
|
|
1712
1723
|
singlePropDirective,
|
|
1713
1724
|
component2,
|
|
@@ -1723,7 +1734,7 @@ var ComponentBinder = class {
|
|
|
1723
1734
|
const capturedContext = [...parser.__capture()];
|
|
1724
1735
|
const createComponentCtx = () => {
|
|
1725
1736
|
var _a2;
|
|
1726
|
-
const props = getProps(component, capturedContext);
|
|
1737
|
+
const props = getProps(component, capturedContext, true);
|
|
1727
1738
|
const head2 = new ComponentHead(
|
|
1728
1739
|
props,
|
|
1729
1740
|
component,
|
|
@@ -1883,25 +1894,47 @@ var ComponentBinder = class {
|
|
|
1883
1894
|
);
|
|
1884
1895
|
const inheritor = inheritorChildNodes[0];
|
|
1885
1896
|
if (!inheritor) return;
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
const
|
|
1897
|
+
const bindClassName = `${bindName}:class`;
|
|
1898
|
+
const bindStyleName = `${bindName}:style`;
|
|
1899
|
+
const mergeBinding = (shortName, longName, value) => {
|
|
1900
|
+
const existingAttr = inheritor.hasAttribute(shortName) ? shortName : inheritor.hasAttribute(longName) ? longName : shortName;
|
|
1901
|
+
const existingValue = inheritor.getAttribute(existingAttr);
|
|
1902
|
+
inheritor.setAttribute(
|
|
1903
|
+
existingAttr,
|
|
1904
|
+
isNullOrWhitespace(existingValue) ? value : `${existingValue}, ${value}`
|
|
1905
|
+
);
|
|
1906
|
+
};
|
|
1907
|
+
const transferAttribute = (attrName, value) => {
|
|
1890
1908
|
if (attrName === "class") {
|
|
1891
1909
|
const classTokens = toClassTokens(value);
|
|
1892
1910
|
if (classTokens.length > 0) inheritor.classList.add(...classTokens);
|
|
1911
|
+
} else if (attrName === ":class" || attrName === bindClassName) {
|
|
1912
|
+
mergeBinding(":class", bindClassName, value);
|
|
1893
1913
|
} else if (attrName === "style") {
|
|
1894
1914
|
const inheritorStyle = inheritor.style;
|
|
1895
1915
|
const componentStyle = component.style;
|
|
1896
1916
|
for (const s of componentStyle) {
|
|
1897
1917
|
inheritorStyle.setProperty(s, componentStyle.getPropertyValue(s));
|
|
1898
1918
|
}
|
|
1919
|
+
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1920
|
+
mergeBinding(":style", bindStyleName, value);
|
|
1899
1921
|
} else {
|
|
1900
1922
|
inheritor.setAttribute(
|
|
1901
1923
|
normalizeAttributeName(attrName, binder.__config),
|
|
1902
1924
|
value
|
|
1903
1925
|
);
|
|
1904
1926
|
}
|
|
1927
|
+
};
|
|
1928
|
+
for (const { name, value } of inheritedPropAttrs) {
|
|
1929
|
+
component.setAttribute(name, value);
|
|
1930
|
+
}
|
|
1931
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1932
|
+
if (attrName === contextName || attrName === contextAliasName)
|
|
1933
|
+
continue;
|
|
1934
|
+
transferAttribute(
|
|
1935
|
+
attrName,
|
|
1936
|
+
component.getAttribute(attrName)
|
|
1937
|
+
);
|
|
1905
1938
|
}
|
|
1906
1939
|
};
|
|
1907
1940
|
const clearUnusedAttributes = () => {
|
|
@@ -3304,30 +3337,34 @@ var classDirective = {
|
|
|
3304
3337
|
})
|
|
3305
3338
|
};
|
|
3306
3339
|
var patchClass = (el, next, prev) => {
|
|
3340
|
+
const nextValue = unref(next);
|
|
3341
|
+
const prevValue = unref(prev);
|
|
3307
3342
|
const classList = el.classList;
|
|
3308
|
-
const isClassString = isString(
|
|
3309
|
-
const isPrevClassString = isString(
|
|
3310
|
-
if (
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3343
|
+
const isClassString = isString(nextValue);
|
|
3344
|
+
const isPrevClassString = isString(prevValue);
|
|
3345
|
+
if (nextValue && !isClassString) {
|
|
3346
|
+
const nextMap = nextValue;
|
|
3347
|
+
if (prevValue && !isPrevClassString) {
|
|
3348
|
+
const prevMap = prevValue;
|
|
3349
|
+
for (const key in prevMap) {
|
|
3350
|
+
if (!(key in nextMap) || !unref(nextMap[key])) {
|
|
3314
3351
|
classList.remove(key);
|
|
3315
3352
|
}
|
|
3316
3353
|
}
|
|
3317
3354
|
}
|
|
3318
|
-
for (const key in
|
|
3319
|
-
if (
|
|
3355
|
+
for (const key in nextMap) {
|
|
3356
|
+
if (unref(nextMap[key])) classList.add(key);
|
|
3320
3357
|
}
|
|
3321
3358
|
} else {
|
|
3322
3359
|
if (isClassString) {
|
|
3323
|
-
if (
|
|
3324
|
-
const prevTokens = isPrevClassString ? toClassTokens(
|
|
3325
|
-
const nextTokens = toClassTokens(
|
|
3360
|
+
if (prevValue !== nextValue) {
|
|
3361
|
+
const prevTokens = isPrevClassString ? toClassTokens(prevValue) : [];
|
|
3362
|
+
const nextTokens = toClassTokens(nextValue);
|
|
3326
3363
|
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3327
3364
|
if (nextTokens.length > 0) classList.add(...nextTokens);
|
|
3328
3365
|
}
|
|
3329
|
-
} else if (
|
|
3330
|
-
const prevTokens = isPrevClassString ? toClassTokens(
|
|
3366
|
+
} else if (prevValue) {
|
|
3367
|
+
const prevTokens = isPrevClassString ? toClassTokens(prevValue) : [];
|
|
3331
3368
|
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3332
3369
|
}
|
|
3333
3370
|
}
|
|
@@ -4004,26 +4041,30 @@ var styleDirective = {
|
|
|
4004
4041
|
})
|
|
4005
4042
|
};
|
|
4006
4043
|
var patchStyle = (el, next, prev) => {
|
|
4044
|
+
const nextValue = unref(next);
|
|
4045
|
+
const prevValue = unref(prev);
|
|
4007
4046
|
const style = el.style;
|
|
4008
|
-
const isCssString = isString(
|
|
4009
|
-
if (
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4047
|
+
const isCssString = isString(nextValue);
|
|
4048
|
+
if (nextValue && !isCssString) {
|
|
4049
|
+
const nextMap = nextValue;
|
|
4050
|
+
if (prevValue && !isString(prevValue)) {
|
|
4051
|
+
const prevMap = prevValue;
|
|
4052
|
+
for (const key in prevMap) {
|
|
4053
|
+
if (unref(nextMap[key]) == null) {
|
|
4013
4054
|
setStyle(style, key, "");
|
|
4014
4055
|
}
|
|
4015
4056
|
}
|
|
4016
4057
|
}
|
|
4017
|
-
for (const key in
|
|
4018
|
-
setStyle(style, key,
|
|
4058
|
+
for (const key in nextMap) {
|
|
4059
|
+
setStyle(style, key, nextMap[key]);
|
|
4019
4060
|
}
|
|
4020
4061
|
} else {
|
|
4021
4062
|
const currentDisplay = style.display;
|
|
4022
4063
|
if (isCssString) {
|
|
4023
|
-
if (
|
|
4024
|
-
style.cssText =
|
|
4064
|
+
if (prevValue !== nextValue) {
|
|
4065
|
+
style.cssText = nextValue;
|
|
4025
4066
|
}
|
|
4026
|
-
} else if (
|
|
4067
|
+
} else if (prevValue) {
|
|
4027
4068
|
el.removeAttribute("style");
|
|
4028
4069
|
}
|
|
4029
4070
|
const data = getBindData(el).data;
|
|
@@ -4033,24 +4074,25 @@ var patchStyle = (el, next, prev) => {
|
|
|
4033
4074
|
};
|
|
4034
4075
|
var importantRE = /\s*!important$/;
|
|
4035
4076
|
function setStyle(style, name, val) {
|
|
4036
|
-
|
|
4037
|
-
|
|
4077
|
+
const value = unref(val);
|
|
4078
|
+
if (isArray(value)) {
|
|
4079
|
+
value.forEach((v) => {
|
|
4038
4080
|
setStyle(style, name, v);
|
|
4039
4081
|
});
|
|
4040
4082
|
} else {
|
|
4041
|
-
|
|
4083
|
+
const cssValue = value == null ? "" : String(value);
|
|
4042
4084
|
if (name.startsWith("--")) {
|
|
4043
|
-
style.setProperty(name,
|
|
4085
|
+
style.setProperty(name, cssValue);
|
|
4044
4086
|
} else {
|
|
4045
4087
|
const prefixed = autoPrefix(style, name);
|
|
4046
|
-
if (importantRE.test(
|
|
4088
|
+
if (importantRE.test(cssValue)) {
|
|
4047
4089
|
style.setProperty(
|
|
4048
4090
|
hyphenate(prefixed),
|
|
4049
|
-
|
|
4091
|
+
cssValue.replace(importantRE, ""),
|
|
4050
4092
|
"important"
|
|
4051
4093
|
);
|
|
4052
4094
|
} else {
|
|
4053
|
-
style[prefixed] =
|
|
4095
|
+
style[prefixed] = cssValue;
|
|
4054
4096
|
}
|
|
4055
4097
|
}
|
|
4056
4098
|
}
|