@vue/compiler-sfc 3.2.28 → 3.2.29

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.
@@ -109,7 +109,8 @@ function sum (o) {
109
109
  var hashSum = sum;
110
110
 
111
111
  const CSS_VARS_HELPER = `useCssVars`;
112
- const cssVarRE = /\bv-bind\s*\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^;]*))\s*\)/g;
112
+ // match v-bind() with max 2-levels of nested parens.
113
+ const cssVarRE = /v-bind\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
113
114
  function genCssVarsFromList(vars, id, isProd) {
114
115
  return `{\n ${vars
115
116
  .map(key => `"${genVarName(id, key, isProd)}": (${key})`)
@@ -123,6 +124,14 @@ function genVarName(id, raw, isProd) {
123
124
  return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
124
125
  }
125
126
  }
127
+ function noramlizeExpression(exp) {
128
+ exp = exp.trim();
129
+ if ((exp[0] === `'` && exp[exp.length - 1] === `'`) ||
130
+ (exp[0] === `"` && exp[exp.length - 1] === `"`)) {
131
+ return exp.slice(1, -1);
132
+ }
133
+ return exp;
134
+ }
126
135
  function parseCssVars(sfc) {
127
136
  const vars = [];
128
137
  sfc.styles.forEach(style => {
@@ -130,7 +139,7 @@ function parseCssVars(sfc) {
130
139
  // ignore v-bind() in comments /* ... */
131
140
  const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
132
141
  while ((match = cssVarRE.exec(content))) {
133
- const variable = match[1] || match[2] || match[3];
142
+ const variable = noramlizeExpression(match[1]);
134
143
  if (!vars.includes(variable)) {
135
144
  vars.push(variable);
136
145
  }
@@ -145,8 +154,8 @@ const cssVarsPlugin = opts => {
145
154
  Declaration(decl) {
146
155
  // rewrite CSS variables
147
156
  if (cssVarRE.test(decl.value)) {
148
- decl.value = decl.value.replace(cssVarRE, (_, $1, $2, $3) => {
149
- return `var(--${genVarName(id, $1 || $2 || $3, isProd)})`;
157
+ decl.value = decl.value.replace(cssVarRE, (_, $1) => {
158
+ return `var(--${genVarName(id, noramlizeExpression($1), isProd)})`;
150
159
  });
151
160
  }
152
161
  }
@@ -27662,7 +27662,8 @@ function sum (o) {
27662
27662
  var hashSum = sum;
27663
27663
 
27664
27664
  const CSS_VARS_HELPER = `useCssVars`;
27665
- const cssVarRE = /\bv-bind\s*\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^;]*))\s*\)/g;
27665
+ // match v-bind() with max 2-levels of nested parens.
27666
+ const cssVarRE = /v-bind\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
27666
27667
  function genCssVarsFromList(vars, id, isProd) {
27667
27668
  return `{\n ${vars
27668
27669
  .map(key => `"${genVarName(id, key, isProd)}": (${key})`)
@@ -27676,6 +27677,14 @@ function genVarName(id, raw, isProd) {
27676
27677
  return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
27677
27678
  }
27678
27679
  }
27680
+ function noramlizeExpression(exp) {
27681
+ exp = exp.trim();
27682
+ if ((exp[0] === `'` && exp[exp.length - 1] === `'`) ||
27683
+ (exp[0] === `"` && exp[exp.length - 1] === `"`)) {
27684
+ return exp.slice(1, -1);
27685
+ }
27686
+ return exp;
27687
+ }
27679
27688
  function parseCssVars(sfc) {
27680
27689
  const vars = [];
27681
27690
  sfc.styles.forEach(style => {
@@ -27683,7 +27692,7 @@ function parseCssVars(sfc) {
27683
27692
  // ignore v-bind() in comments /* ... */
27684
27693
  const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
27685
27694
  while ((match = cssVarRE.exec(content))) {
27686
- const variable = match[1] || match[2] || match[3];
27695
+ const variable = noramlizeExpression(match[1]);
27687
27696
  if (!vars.includes(variable)) {
27688
27697
  vars.push(variable);
27689
27698
  }
@@ -27698,8 +27707,8 @@ const cssVarsPlugin = opts => {
27698
27707
  Declaration(decl) {
27699
27708
  // rewrite CSS variables
27700
27709
  if (cssVarRE.test(decl.value)) {
27701
- decl.value = decl.value.replace(cssVarRE, (_, $1, $2, $3) => {
27702
- return `var(--${genVarName(id, $1 || $2 || $3, isProd)})`;
27710
+ decl.value = decl.value.replace(cssVarRE, (_, $1) => {
27711
+ return `var(--${genVarName(id, noramlizeExpression($1), isProd)})`;
27703
27712
  });
27704
27713
  }
27705
27714
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.28",
3
+ "version": "3.2.29",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -33,11 +33,11 @@
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
34
34
  "dependencies": {
35
35
  "@babel/parser": "^7.16.4",
36
- "@vue/compiler-core": "3.2.28",
37
- "@vue/compiler-dom": "3.2.28",
38
- "@vue/compiler-ssr": "3.2.28",
39
- "@vue/reactivity-transform": "3.2.28",
40
- "@vue/shared": "3.2.28",
36
+ "@vue/compiler-core": "3.2.29",
37
+ "@vue/compiler-dom": "3.2.29",
38
+ "@vue/compiler-ssr": "3.2.29",
39
+ "@vue/reactivity-transform": "3.2.29",
40
+ "@vue/shared": "3.2.29",
41
41
  "estree-walker": "^2.0.2",
42
42
  "magic-string": "^0.25.7",
43
43
  "source-map": "^0.6.1",