@lwc/template-compiler 8.1.1 → 8.1.3

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.
@@ -19,10 +19,6 @@ export declare function shouldFlatten(codeGen: CodeGen, children: ChildNode[]):
19
19
  */
20
20
  export declare function hasIdAttribute(node: Node): boolean;
21
21
  export declare function generateTemplateMetadata(codeGen: CodeGen): t.Statement[];
22
- export declare function parseStyleText(cssText: string): {
23
- [name: string]: string;
24
- };
25
- export declare function normalizeStyleAttribute(style: string): string;
26
22
  export declare function styleMapToStyleDeclsAST(styleMap: {
27
23
  [name: string]: string;
28
24
  }): t.ArrayExpression;
package/dist/index.cjs.js CHANGED
@@ -12951,40 +12951,14 @@ function generateStylesheetTokens(codeGen) {
12951
12951
  }
12952
12952
  return styleTokens;
12953
12953
  }
12954
- const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
12955
- const PROPERTY_DELIMITER = /:(.+)/;
12956
- // Borrowed from Vue template compiler.
12957
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
12958
- function parseStyleText(cssText) {
12959
- const styleMap = {};
12960
- const declarations = cssText.split(DECLARATION_DELIMITER);
12961
- for (const declaration of declarations) {
12962
- if (declaration) {
12963
- const [prop, value] = declaration.split(PROPERTY_DELIMITER);
12964
- if (prop !== undefined && value !== undefined) {
12965
- styleMap[prop.trim()] = value.trim();
12966
- }
12967
- }
12968
- }
12969
- return styleMap;
12970
- }
12971
- function normalizeStyleAttribute(style) {
12972
- const styleMap = parseStyleText(style);
12973
- const styles = Object.entries(styleMap).map(([key, value]) => {
12974
- value = value.replace(IMPORTANT_FLAG, ' !important').trim();
12975
- return `${key}: ${value};`;
12976
- });
12977
- return styles.join(' ');
12978
- }
12979
- const IMPORTANT_FLAG = /\s*!\s*important\s*$/i;
12980
12954
  // Given a map of CSS property keys to values, return an array AST like:
12981
12955
  // ['color', 'blue', false] // { color: 'blue' }
12982
12956
  // ['background', 'red', true] // { background: 'red !important' }
12983
12957
  function styleMapToStyleDeclsAST(styleMap) {
12984
12958
  const styles = Object.entries(styleMap).map(([key, value]) => {
12985
- const important = IMPORTANT_FLAG.test(value);
12959
+ const important = shared.IMPORTANT_FLAG.test(value);
12986
12960
  if (important) {
12987
- value = value.replace(IMPORTANT_FLAG, '').trim();
12961
+ value = value.replace(shared.IMPORTANT_FLAG, '').trim();
12988
12962
  }
12989
12963
  return [key, value, important];
12990
12964
  });
@@ -13201,7 +13175,7 @@ function serializeAttrs(element, codeGen) {
13201
13175
  v = String(v.toLowerCase() !== 'false');
13202
13176
  }
13203
13177
  if (name === 'style' && !hasExpression) {
13204
- v = normalizeStyleAttribute(v);
13178
+ v = shared.normalizeStyleAttribute(v);
13205
13179
  if (v === '') {
13206
13180
  // Do not serialize empty style attribute (consistent with non-static optimized)
13207
13181
  return;
@@ -14605,7 +14579,7 @@ function transform(codeGen) {
14605
14579
  data.push(property$1(identifier('style'), styleExpression));
14606
14580
  }
14607
14581
  else if (isStringLiteral(value)) {
14608
- const styleMap = parseStyleText(value.value);
14582
+ const styleMap = shared.parseStyleText(value.value);
14609
14583
  const styleAST = styleMapToStyleDeclsAST(styleMap);
14610
14584
  data.push(property$1(identifier('styleDecls'), styleAST));
14611
14585
  }
@@ -14793,5 +14767,5 @@ exports.generateScopeTokens = generateScopeTokens;
14793
14767
  exports.kebabcaseToCamelcase = kebabcaseToCamelcase;
14794
14768
  exports.parse = parse;
14795
14769
  exports.toPropertyName = toPropertyName;
14796
- /** version: 8.1.1 */
14770
+ /** version: 8.1.3 */
14797
14771
  //# sourceMappingURL=index.cjs.js.map