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.es2019.cjs.js
CHANGED
|
@@ -1703,7 +1703,9 @@ var ComponentBinder = class {
|
|
|
1703
1703
|
const contextAliasName = binder.__config.__builtInNames.contextAlias;
|
|
1704
1704
|
const bindName = binder.__config.__builtInNames.bind;
|
|
1705
1705
|
const definedProps = (_b = (_a = registeredComponent.props) == null ? void 0 : _a.map(camelize)) != null ? _b : [];
|
|
1706
|
-
const
|
|
1706
|
+
const inheritedPropAttrs = [];
|
|
1707
|
+
const isInheritableSpecialProp = (propName) => propName === "class" || propName === "style";
|
|
1708
|
+
const getProps = (component2, capturedContext2, collectInheritedPropAttrs = false) => {
|
|
1707
1709
|
const props = {};
|
|
1708
1710
|
const hasContext = component2.hasAttribute(contextName);
|
|
1709
1711
|
parser.__scoped(capturedContext2, () => {
|
|
@@ -1726,7 +1728,11 @@ var ComponentBinder = class {
|
|
|
1726
1728
|
]) {
|
|
1727
1729
|
const value = component2.getAttribute(name);
|
|
1728
1730
|
if (value === null) continue;
|
|
1729
|
-
|
|
1731
|
+
const propName = camelize(name);
|
|
1732
|
+
props[propName] = value;
|
|
1733
|
+
if (collectInheritedPropAttrs && registeredComponent.inheritAttrs === true && isInheritableSpecialProp(propName)) {
|
|
1734
|
+
inheritedPropAttrs.push({ name, value });
|
|
1735
|
+
}
|
|
1730
1736
|
component2.removeAttribute(name);
|
|
1731
1737
|
}
|
|
1732
1738
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
@@ -1738,6 +1744,11 @@ var ComponentBinder = class {
|
|
|
1738
1744
|
);
|
|
1739
1745
|
if (!propName) continue;
|
|
1740
1746
|
if (name !== "." && name !== ":" && name !== bindName) continue;
|
|
1747
|
+
if (collectInheritedPropAttrs && name !== "." && registeredComponent.inheritAttrs === true && isInheritableSpecialProp(propName)) {
|
|
1748
|
+
const value = component2.getAttribute(attrName);
|
|
1749
|
+
if (value !== null)
|
|
1750
|
+
inheritedPropAttrs.push({ name: attrName, value });
|
|
1751
|
+
}
|
|
1741
1752
|
binder.__bind(
|
|
1742
1753
|
singlePropDirective,
|
|
1743
1754
|
component2,
|
|
@@ -1753,7 +1764,7 @@ var ComponentBinder = class {
|
|
|
1753
1764
|
const capturedContext = [...parser.__capture()];
|
|
1754
1765
|
const createComponentCtx = () => {
|
|
1755
1766
|
var _a2;
|
|
1756
|
-
const props = getProps(component, capturedContext);
|
|
1767
|
+
const props = getProps(component, capturedContext, true);
|
|
1757
1768
|
const head2 = new ComponentHead(
|
|
1758
1769
|
props,
|
|
1759
1770
|
component,
|
|
@@ -1913,25 +1924,47 @@ var ComponentBinder = class {
|
|
|
1913
1924
|
);
|
|
1914
1925
|
const inheritor = inheritorChildNodes[0];
|
|
1915
1926
|
if (!inheritor) return;
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
const
|
|
1927
|
+
const bindClassName = `${bindName}:class`;
|
|
1928
|
+
const bindStyleName = `${bindName}:style`;
|
|
1929
|
+
const mergeBinding = (shortName, longName, value) => {
|
|
1930
|
+
const existingAttr = inheritor.hasAttribute(shortName) ? shortName : inheritor.hasAttribute(longName) ? longName : shortName;
|
|
1931
|
+
const existingValue = inheritor.getAttribute(existingAttr);
|
|
1932
|
+
inheritor.setAttribute(
|
|
1933
|
+
existingAttr,
|
|
1934
|
+
isNullOrWhitespace(existingValue) ? value : `${existingValue}, ${value}`
|
|
1935
|
+
);
|
|
1936
|
+
};
|
|
1937
|
+
const transferAttribute = (attrName, value) => {
|
|
1920
1938
|
if (attrName === "class") {
|
|
1921
1939
|
const classTokens = toClassTokens(value);
|
|
1922
1940
|
if (classTokens.length > 0) inheritor.classList.add(...classTokens);
|
|
1941
|
+
} else if (attrName === ":class" || attrName === bindClassName) {
|
|
1942
|
+
mergeBinding(":class", bindClassName, value);
|
|
1923
1943
|
} else if (attrName === "style") {
|
|
1924
1944
|
const inheritorStyle = inheritor.style;
|
|
1925
1945
|
const componentStyle = component.style;
|
|
1926
1946
|
for (const s of componentStyle) {
|
|
1927
1947
|
inheritorStyle.setProperty(s, componentStyle.getPropertyValue(s));
|
|
1928
1948
|
}
|
|
1949
|
+
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1950
|
+
mergeBinding(":style", bindStyleName, value);
|
|
1929
1951
|
} else {
|
|
1930
1952
|
inheritor.setAttribute(
|
|
1931
1953
|
normalizeAttributeName(attrName, binder.__config),
|
|
1932
1954
|
value
|
|
1933
1955
|
);
|
|
1934
1956
|
}
|
|
1957
|
+
};
|
|
1958
|
+
for (const { name, value } of inheritedPropAttrs) {
|
|
1959
|
+
component.setAttribute(name, value);
|
|
1960
|
+
}
|
|
1961
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1962
|
+
if (attrName === contextName || attrName === contextAliasName)
|
|
1963
|
+
continue;
|
|
1964
|
+
transferAttribute(
|
|
1965
|
+
attrName,
|
|
1966
|
+
component.getAttribute(attrName)
|
|
1967
|
+
);
|
|
1935
1968
|
}
|
|
1936
1969
|
};
|
|
1937
1970
|
const clearUnusedAttributes = () => {
|
|
@@ -3334,30 +3367,34 @@ var classDirective = {
|
|
|
3334
3367
|
})
|
|
3335
3368
|
};
|
|
3336
3369
|
var patchClass = (el, next, prev) => {
|
|
3370
|
+
const nextValue = unref(next);
|
|
3371
|
+
const prevValue = unref(prev);
|
|
3337
3372
|
const classList = el.classList;
|
|
3338
|
-
const isClassString = isString(
|
|
3339
|
-
const isPrevClassString = isString(
|
|
3340
|
-
if (
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3373
|
+
const isClassString = isString(nextValue);
|
|
3374
|
+
const isPrevClassString = isString(prevValue);
|
|
3375
|
+
if (nextValue && !isClassString) {
|
|
3376
|
+
const nextMap = nextValue;
|
|
3377
|
+
if (prevValue && !isPrevClassString) {
|
|
3378
|
+
const prevMap = prevValue;
|
|
3379
|
+
for (const key in prevMap) {
|
|
3380
|
+
if (!(key in nextMap) || !unref(nextMap[key])) {
|
|
3344
3381
|
classList.remove(key);
|
|
3345
3382
|
}
|
|
3346
3383
|
}
|
|
3347
3384
|
}
|
|
3348
|
-
for (const key in
|
|
3349
|
-
if (
|
|
3385
|
+
for (const key in nextMap) {
|
|
3386
|
+
if (unref(nextMap[key])) classList.add(key);
|
|
3350
3387
|
}
|
|
3351
3388
|
} else {
|
|
3352
3389
|
if (isClassString) {
|
|
3353
|
-
if (
|
|
3354
|
-
const prevTokens = isPrevClassString ? toClassTokens(
|
|
3355
|
-
const nextTokens = toClassTokens(
|
|
3390
|
+
if (prevValue !== nextValue) {
|
|
3391
|
+
const prevTokens = isPrevClassString ? toClassTokens(prevValue) : [];
|
|
3392
|
+
const nextTokens = toClassTokens(nextValue);
|
|
3356
3393
|
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3357
3394
|
if (nextTokens.length > 0) classList.add(...nextTokens);
|
|
3358
3395
|
}
|
|
3359
|
-
} else if (
|
|
3360
|
-
const prevTokens = isPrevClassString ? toClassTokens(
|
|
3396
|
+
} else if (prevValue) {
|
|
3397
|
+
const prevTokens = isPrevClassString ? toClassTokens(prevValue) : [];
|
|
3361
3398
|
if (prevTokens.length > 0) classList.remove(...prevTokens);
|
|
3362
3399
|
}
|
|
3363
3400
|
}
|
|
@@ -4034,26 +4071,30 @@ var styleDirective = {
|
|
|
4034
4071
|
})
|
|
4035
4072
|
};
|
|
4036
4073
|
var patchStyle = (el, next, prev) => {
|
|
4074
|
+
const nextValue = unref(next);
|
|
4075
|
+
const prevValue = unref(prev);
|
|
4037
4076
|
const style = el.style;
|
|
4038
|
-
const isCssString = isString(
|
|
4039
|
-
if (
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4077
|
+
const isCssString = isString(nextValue);
|
|
4078
|
+
if (nextValue && !isCssString) {
|
|
4079
|
+
const nextMap = nextValue;
|
|
4080
|
+
if (prevValue && !isString(prevValue)) {
|
|
4081
|
+
const prevMap = prevValue;
|
|
4082
|
+
for (const key in prevMap) {
|
|
4083
|
+
if (unref(nextMap[key]) == null) {
|
|
4043
4084
|
setStyle(style, key, "");
|
|
4044
4085
|
}
|
|
4045
4086
|
}
|
|
4046
4087
|
}
|
|
4047
|
-
for (const key in
|
|
4048
|
-
setStyle(style, key,
|
|
4088
|
+
for (const key in nextMap) {
|
|
4089
|
+
setStyle(style, key, nextMap[key]);
|
|
4049
4090
|
}
|
|
4050
4091
|
} else {
|
|
4051
4092
|
const currentDisplay = style.display;
|
|
4052
4093
|
if (isCssString) {
|
|
4053
|
-
if (
|
|
4054
|
-
style.cssText =
|
|
4094
|
+
if (prevValue !== nextValue) {
|
|
4095
|
+
style.cssText = nextValue;
|
|
4055
4096
|
}
|
|
4056
|
-
} else if (
|
|
4097
|
+
} else if (prevValue) {
|
|
4057
4098
|
el.removeAttribute("style");
|
|
4058
4099
|
}
|
|
4059
4100
|
const data = getBindData(el).data;
|
|
@@ -4063,24 +4104,25 @@ var patchStyle = (el, next, prev) => {
|
|
|
4063
4104
|
};
|
|
4064
4105
|
var importantRE = /\s*!important$/;
|
|
4065
4106
|
function setStyle(style, name, val) {
|
|
4066
|
-
|
|
4067
|
-
|
|
4107
|
+
const value = unref(val);
|
|
4108
|
+
if (isArray(value)) {
|
|
4109
|
+
value.forEach((v) => {
|
|
4068
4110
|
setStyle(style, name, v);
|
|
4069
4111
|
});
|
|
4070
4112
|
} else {
|
|
4071
|
-
|
|
4113
|
+
const cssValue = value == null ? "" : String(value);
|
|
4072
4114
|
if (name.startsWith("--")) {
|
|
4073
|
-
style.setProperty(name,
|
|
4115
|
+
style.setProperty(name, cssValue);
|
|
4074
4116
|
} else {
|
|
4075
4117
|
const prefixed = autoPrefix(style, name);
|
|
4076
|
-
if (importantRE.test(
|
|
4118
|
+
if (importantRE.test(cssValue)) {
|
|
4077
4119
|
style.setProperty(
|
|
4078
4120
|
hyphenate(prefixed),
|
|
4079
|
-
|
|
4121
|
+
cssValue.replace(importantRE, ""),
|
|
4080
4122
|
"important"
|
|
4081
4123
|
);
|
|
4082
4124
|
} else {
|
|
4083
|
-
style[prefixed] =
|
|
4125
|
+
style[prefixed] = cssValue;
|
|
4084
4126
|
}
|
|
4085
4127
|
}
|
|
4086
4128
|
}
|