@lwc/template-compiler 7.0.1 → 7.0.2
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/index.cjs.js +30 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -12961,15 +12961,15 @@ function parseStyleText(cssText) {
|
|
|
12961
12961
|
}
|
|
12962
12962
|
return styleMap;
|
|
12963
12963
|
}
|
|
12964
|
+
const IMPORTANT_FLAG = /\s*!\s*important\s*$/i;
|
|
12964
12965
|
// Given a map of CSS property keys to values, return an array AST like:
|
|
12965
12966
|
// ['color', 'blue', false] // { color: 'blue' }
|
|
12966
12967
|
// ['background', 'red', true] // { background: 'red !important' }
|
|
12967
12968
|
function styleMapToStyleDeclsAST(styleMap) {
|
|
12968
12969
|
const styles = Object.entries(styleMap).map(([key, value]) => {
|
|
12969
|
-
const important =
|
|
12970
|
+
const important = IMPORTANT_FLAG.test(value);
|
|
12970
12971
|
if (important) {
|
|
12971
|
-
|
|
12972
|
-
value = value.substring(0, value.length - 10).trim();
|
|
12972
|
+
value = value.replace(IMPORTANT_FLAG, '').trim();
|
|
12973
12973
|
}
|
|
12974
12974
|
return [key, value, important];
|
|
12975
12975
|
});
|
|
@@ -13010,9 +13010,6 @@ function isStaticNode(node, apiVersion) {
|
|
|
13010
13010
|
result &&= attributes.every(({ name, value }) => {
|
|
13011
13011
|
const isStaticSafeLiteral = isLiteral(value) &&
|
|
13012
13012
|
name !== 'slot' &&
|
|
13013
|
-
// check for ScopedId
|
|
13014
|
-
name !== 'id' &&
|
|
13015
|
-
!isIdReferencingAttribute(name) &&
|
|
13016
13013
|
// svg href needs sanitization.
|
|
13017
13014
|
!isSvgUseHref(nodeName, name, namespace) &&
|
|
13018
13015
|
// Check for ScopedFragId
|
|
@@ -13161,7 +13158,7 @@ function serializeAttrs(element, codeGen) {
|
|
|
13161
13158
|
*/
|
|
13162
13159
|
const attrs = [];
|
|
13163
13160
|
let hasClassAttr = false;
|
|
13164
|
-
const collector = ({ name, value, hasExpression, }) => {
|
|
13161
|
+
const collector = ({ name, value, hasExpression, isIdOrIdRef, }) => {
|
|
13165
13162
|
let v = typeof value === 'string' ? templateStringEscape(value) : value;
|
|
13166
13163
|
if (name === 'class') {
|
|
13167
13164
|
hasClassAttr = true;
|
|
@@ -13182,9 +13179,15 @@ function serializeAttrs(element, codeGen) {
|
|
|
13182
13179
|
v = String(v.toLowerCase() !== 'false');
|
|
13183
13180
|
}
|
|
13184
13181
|
if (typeof v === 'string') {
|
|
13182
|
+
// IDs/IDRefs must be handled dynamically at runtime due to synthetic shadow scoping.
|
|
13183
|
+
// Skip serializing here and handle it as if it were a dynamic attribute instead.
|
|
13184
|
+
// Note that, to maintain backwards compatibility with the non-static output, we treat the valueless
|
|
13185
|
+
// "boolean" format (e.g. `<div id>`) as the empty string, which is semantically equivalent.
|
|
13186
|
+
// TODO [#3658]: `disableSyntheticShadowSupport` should also disable this dynamic behavior
|
|
13187
|
+
const needsPlaceholder = hasExpression || isIdOrIdRef;
|
|
13185
13188
|
// Inject a placeholder where the staticPartId will go when an expression occurs.
|
|
13186
13189
|
// This is only needed for SSR to inject the expression value during serialization.
|
|
13187
|
-
attrs.push(
|
|
13190
|
+
attrs.push(needsPlaceholder ? `\${"${v}"}` : ` ${name}="${shared.htmlEscape(v, true)}"`);
|
|
13188
13191
|
}
|
|
13189
13192
|
else {
|
|
13190
13193
|
attrs.push(` ${name}`);
|
|
@@ -13192,13 +13195,20 @@ function serializeAttrs(element, codeGen) {
|
|
|
13192
13195
|
};
|
|
13193
13196
|
element.attributes
|
|
13194
13197
|
.map((attr) => {
|
|
13195
|
-
const
|
|
13198
|
+
const { name, value } = attr;
|
|
13199
|
+
const hasExpression = isExpression$1(value);
|
|
13200
|
+
// IDs/IDRefs must be handled dynamically at runtime due to synthetic shadow scoping.
|
|
13201
|
+
// Note that for backwards compat we only consider non-booleans to be dynamic IDs/IDRefs
|
|
13202
|
+
// TODO [#3658]: `disableSyntheticShadowSupport` should also disable this dynamic behavior
|
|
13203
|
+
const isIdOrIdRef = (name === 'id' || isIdReferencingAttribute(name)) &&
|
|
13204
|
+
(isExpression$1(value) || isStringLiteral(value));
|
|
13196
13205
|
return {
|
|
13197
13206
|
hasExpression,
|
|
13198
|
-
|
|
13199
|
-
|
|
13207
|
+
isIdOrIdRef,
|
|
13208
|
+
name,
|
|
13209
|
+
value: hasExpression || isIdOrIdRef
|
|
13200
13210
|
? codeGen.getStaticExpressionToken(attr)
|
|
13201
|
-
:
|
|
13211
|
+
: value.value,
|
|
13202
13212
|
};
|
|
13203
13213
|
})
|
|
13204
13214
|
.forEach(collector);
|
|
@@ -13901,7 +13911,12 @@ class CodeGen {
|
|
|
13901
13911
|
const attributeExpressions = [];
|
|
13902
13912
|
for (const attribute of elm.attributes) {
|
|
13903
13913
|
const { name, value } = attribute;
|
|
13904
|
-
|
|
13914
|
+
// IDs/IDRefs must be handled dynamically at runtime due to synthetic shadow scoping.
|
|
13915
|
+
// Note that for backwards compat we only consider non-booleans to be dynamic IDs/IDRefs
|
|
13916
|
+
// TODO [#3658]: `disableSyntheticShadowSupport` should also disable this dynamic behavior
|
|
13917
|
+
const isIdOrIdRef = (name === 'id' || isIdReferencingAttribute(name)) &&
|
|
13918
|
+
(isExpression$1(value) || isStringLiteral(value));
|
|
13919
|
+
if (isExpression$1(value) || isIdOrIdRef) {
|
|
13905
13920
|
let partToken = '';
|
|
13906
13921
|
if (name === 'style') {
|
|
13907
13922
|
partToken = `${"s" /* STATIC_PART_TOKEN_ID.STYLE */}${partId}`;
|
|
@@ -13912,6 +13927,7 @@ class CodeGen {
|
|
|
13912
13927
|
databag.push(property$1(identifier('className'), this.genClassExpression(value)));
|
|
13913
13928
|
}
|
|
13914
13929
|
else {
|
|
13930
|
+
// non-class, non-style (i.e. generic attribute or ID/IDRef)
|
|
13915
13931
|
partToken = `${"a" /* STATIC_PART_TOKEN_ID.ATTRIBUTE */}${partId}:${name}`;
|
|
13916
13932
|
attributeExpressions.push(property$1(literal$1(name), bindAttributeExpression(attribute, elm, this, false)));
|
|
13917
13933
|
}
|
|
@@ -14680,5 +14696,5 @@ exports.default = compile;
|
|
|
14680
14696
|
exports.kebabcaseToCamelcase = kebabcaseToCamelcase;
|
|
14681
14697
|
exports.parse = parse;
|
|
14682
14698
|
exports.toPropertyName = toPropertyName;
|
|
14683
|
-
/** version: 7.0.
|
|
14699
|
+
/** version: 7.0.2 */
|
|
14684
14700
|
//# sourceMappingURL=index.cjs.js.map
|