@vue/compiler-sfc 3.2.21 → 3.2.22

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.
@@ -1211,14 +1211,20 @@ function hasSrc(node) {
1211
1211
  * once the empty text nodes (trimmed content) have been filtered out.
1212
1212
  */
1213
1213
  function isEmpty(node) {
1214
- return (node.children.filter(child => child.type !== 2 /* TEXT */ || child.content.trim() !== '').length === 0);
1214
+ for (let i = 0; i < node.children.length; i++) {
1215
+ const child = node.children[i];
1216
+ if (child.type !== 2 /* TEXT */ || child.content.trim() !== '') {
1217
+ return false;
1218
+ }
1219
+ }
1220
+ return true;
1215
1221
  }
1216
1222
 
1217
1223
  function isRelativeUrl(url) {
1218
1224
  const firstChar = url.charAt(0);
1219
1225
  return firstChar === '.' || firstChar === '~' || firstChar === '@';
1220
1226
  }
1221
- const externalRE = /^https?:\/\//;
1227
+ const externalRE = /^(https?:)?\/\//;
1222
1228
  function isExternalUrl(url) {
1223
1229
  return externalRE.test(url);
1224
1230
  }
@@ -16174,10 +16180,14 @@ function compileScript(sfc, options) {
16174
16180
  }
16175
16181
  }
16176
16182
  }
16183
+ const { type, required } = props[key];
16177
16184
  if (!isProd) {
16178
- const { type, required } = props[key];
16179
16185
  return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
16180
16186
  }
16187
+ else if (type.some(el => el === 'Boolean' || (defaultString && el === 'Function'))) {
16188
+ // #4783 production: if boolean or defaultString and function exists, should keep the type.
16189
+ return `${key}: { type: ${toRuntimeTypeString(type)}${defaultString ? `, ${defaultString}` : ``} }`;
16190
+ }
16181
16191
  else {
16182
16192
  // production: checks are useless
16183
16193
  return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`;
@@ -16481,7 +16491,7 @@ function compileScript(sfc, options) {
16481
16491
  }
16482
16492
  // 4. extract runtime props/emits code from setup context type
16483
16493
  if (propsTypeDecl) {
16484
- extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes, isProd);
16494
+ extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
16485
16495
  }
16486
16496
  if (emitsTypeDecl) {
16487
16497
  extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
@@ -16697,7 +16707,7 @@ function compileScript(sfc, options) {
16697
16707
  }
16698
16708
  // <script setup> components are closed by default. If the user did not
16699
16709
  // explicitly call `defineExpose`, call expose() with no args.
16700
- const exposeCall = hasDefineExposeCall || options.inlineTemplate ? `` : ` expose()\n`;
16710
+ const exposeCall = hasDefineExposeCall || options.inlineTemplate ? `` : ` expose();\n`;
16701
16711
  if (isTS) {
16702
16712
  // for TS, make sure the exported type is still valid type with
16703
16713
  // correct props information
@@ -16882,13 +16892,11 @@ function extractRuntimeProps(node, props, declaredTypes, isProd) {
16882
16892
  if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
16883
16893
  m.key.type === 'Identifier') {
16884
16894
  let type;
16885
- if (!isProd) {
16886
- if (m.type === 'TSMethodSignature') {
16887
- type = ['Function'];
16888
- }
16889
- else if (m.typeAnnotation) {
16890
- type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
16891
- }
16895
+ if (m.type === 'TSMethodSignature') {
16896
+ type = ['Function'];
16897
+ }
16898
+ else if (m.typeAnnotation) {
16899
+ type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
16892
16900
  }
16893
16901
  props[m.key.name] = {
16894
16902
  key: m.key.name,
@@ -23589,7 +23589,7 @@ function stringifyDynamicPropNames(props) {
23589
23589
  return propsNamesString + `]`;
23590
23590
  }
23591
23591
  function isComponentTag(tag) {
23592
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
23592
+ return tag === 'component' || tag === 'Component';
23593
23593
  }
23594
23594
  function processInlineRef(context, raw) {
23595
23595
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
@@ -27736,7 +27736,13 @@ function hasSrc(node) {
27736
27736
  * once the empty text nodes (trimmed content) have been filtered out.
27737
27737
  */
27738
27738
  function isEmpty(node) {
27739
- return (node.children.filter(child => child.type !== 2 /* TEXT */ || child.content.trim() !== '').length === 0);
27739
+ for (let i = 0; i < node.children.length; i++) {
27740
+ const child = node.children[i];
27741
+ if (child.type !== 2 /* TEXT */ || child.content.trim() !== '') {
27742
+ return false;
27743
+ }
27744
+ }
27745
+ return true;
27740
27746
  }
27741
27747
 
27742
27748
  // Copyright Joyent, Inc. and other Node contributors.
@@ -31947,7 +31953,7 @@ function isRelativeUrl(url) {
31947
31953
  const firstChar = url.charAt(0);
31948
31954
  return firstChar === '.' || firstChar === '~' || firstChar === '@';
31949
31955
  }
31950
- const externalRE = /^https?:\/\//;
31956
+ const externalRE = /^(https?:)?\/\//;
31951
31957
  function isExternalUrl(url) {
31952
31958
  return externalRE.test(url);
31953
31959
  }
@@ -47243,10 +47249,14 @@ function compileScript(sfc, options) {
47243
47249
  }
47244
47250
  }
47245
47251
  }
47252
+ const { type, required } = props[key];
47246
47253
  if (!isProd) {
47247
- const { type, required } = props[key];
47248
47254
  return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
47249
47255
  }
47256
+ else if (type.some(el => el === 'Boolean' || (defaultString && el === 'Function'))) {
47257
+ // #4783 production: if boolean or defaultString and function exists, should keep the type.
47258
+ return `${key}: { type: ${toRuntimeTypeString(type)}${defaultString ? `, ${defaultString}` : ``} }`;
47259
+ }
47250
47260
  else {
47251
47261
  // production: checks are useless
47252
47262
  return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`;
@@ -47550,7 +47560,7 @@ function compileScript(sfc, options) {
47550
47560
  }
47551
47561
  // 4. extract runtime props/emits code from setup context type
47552
47562
  if (propsTypeDecl) {
47553
- extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes, isProd);
47563
+ extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
47554
47564
  }
47555
47565
  if (emitsTypeDecl) {
47556
47566
  extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
@@ -47766,7 +47776,7 @@ function compileScript(sfc, options) {
47766
47776
  }
47767
47777
  // <script setup> components are closed by default. If the user did not
47768
47778
  // explicitly call `defineExpose`, call expose() with no args.
47769
- const exposeCall = hasDefineExposeCall || options.inlineTemplate ? `` : ` expose()\n`;
47779
+ const exposeCall = hasDefineExposeCall || options.inlineTemplate ? `` : ` expose();\n`;
47770
47780
  if (isTS) {
47771
47781
  // for TS, make sure the exported type is still valid type with
47772
47782
  // correct props information
@@ -47951,13 +47961,11 @@ function extractRuntimeProps(node, props, declaredTypes, isProd) {
47951
47961
  if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
47952
47962
  m.key.type === 'Identifier') {
47953
47963
  let type;
47954
- if (!isProd) {
47955
- if (m.type === 'TSMethodSignature') {
47956
- type = ['Function'];
47957
- }
47958
- else if (m.typeAnnotation) {
47959
- type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
47960
- }
47964
+ if (m.type === 'TSMethodSignature') {
47965
+ type = ['Function'];
47966
+ }
47967
+ else if (m.typeAnnotation) {
47968
+ type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
47961
47969
  }
47962
47970
  props[m.key.name] = {
47963
47971
  key: m.key.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.21",
3
+ "version": "3.2.22",
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/vue-next/tree/master/packages/compiler-sfc#readme",
34
34
  "dependencies": {
35
35
  "@babel/parser": "^7.15.0",
36
- "@vue/compiler-core": "3.2.21",
37
- "@vue/compiler-dom": "3.2.21",
38
- "@vue/compiler-ssr": "3.2.21",
39
- "@vue/ref-transform": "3.2.21",
40
- "@vue/shared": "3.2.21",
36
+ "@vue/compiler-core": "3.2.22",
37
+ "@vue/compiler-dom": "3.2.22",
38
+ "@vue/compiler-ssr": "3.2.22",
39
+ "@vue/ref-transform": "3.2.22",
40
+ "@vue/shared": "3.2.22",
41
41
  "estree-walker": "^2.0.2",
42
42
  "magic-string": "^0.25.7",
43
43
  "source-map": "^0.6.1",