@vue/compat 3.2.23 → 3.2.24

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/README.md CHANGED
@@ -89,6 +89,7 @@ The following workflow walks through the steps of migrating an actual Vue 2 app
89
89
  }
90
90
  }
91
91
  })
92
+ }
92
93
  }
93
94
  ```
94
95
 
package/dist/vue.cjs.js CHANGED
@@ -4869,7 +4869,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4869
4869
  continue;
4870
4870
  }
4871
4871
  }
4872
- if (value !== attrs[key]) {
4872
+ if (!(key in attrs) || value !== attrs[key]) {
4873
4873
  attrs[key] = value;
4874
4874
  hasAttrsChanged = true;
4875
4875
  }
@@ -5450,7 +5450,7 @@ function createCompatVue(createApp, createSingletonApp) {
5450
5450
  return vm;
5451
5451
  }
5452
5452
  }
5453
- Vue.version = "3.2.23";
5453
+ Vue.version = "3.2.24";
5454
5454
  Vue.config = singletonApp.config;
5455
5455
  Vue.use = (p, ...options) => {
5456
5456
  if (p && isFunction(p.install)) {
@@ -8415,6 +8415,7 @@ function convertLegacyFunctionalComponent(comp) {
8415
8415
  };
8416
8416
  Func.props = comp.props;
8417
8417
  Func.displayName = comp.name;
8418
+ Func.compatConfig = comp.compatConfig;
8418
8419
  // v2 functional components do not inherit attrs
8419
8420
  Func.inheritAttrs = false;
8420
8421
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -11066,7 +11067,7 @@ function isMemoSame(cached, memo) {
11066
11067
  }
11067
11068
 
11068
11069
  // Core API ------------------------------------------------------------------
11069
- const version = "3.2.23";
11070
+ const version = "3.2.24";
11070
11071
  const _ssrUtils = {
11071
11072
  createComponentInstance,
11072
11073
  setupComponent,
@@ -11749,7 +11750,7 @@ class VueElement extends BaseClass {
11749
11750
  // HMR
11750
11751
  {
11751
11752
  instance.ceReload = newStyles => {
11752
- // alawys reset styles
11753
+ // always reset styles
11753
11754
  if (this._styles) {
11754
11755
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11755
11756
  this._styles.length = 0;
@@ -13448,7 +13449,6 @@ function getUnnormalizedProps(props, callPath = []) {
13448
13449
  }
13449
13450
  function injectProp(node, prop, context) {
13450
13451
  let propsWithInjection;
13451
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13452
13452
  /**
13453
13453
  * 1. mergeProps(...)
13454
13454
  * 2. toHandlers(...)
@@ -13457,7 +13457,7 @@ function injectProp(node, prop, context) {
13457
13457
  *
13458
13458
  * we need to get the real props before normalization
13459
13459
  */
13460
- let props = originalProps;
13460
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13461
13461
  let callPath = [];
13462
13462
  let parentCall;
13463
13463
  if (props &&
@@ -14521,15 +14521,6 @@ function isSingleElementRoot(root, child) {
14521
14521
  !isSlotOutlet(child));
14522
14522
  }
14523
14523
  function walk$1(node, context, doNotHoistNode = false) {
14524
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14525
- // static bindings with expressions. These expressions are guaranteed to be
14526
- // constant so they are still eligible for hoisting, but they are only
14527
- // available at runtime and therefore cannot be evaluated ahead of time.
14528
- // This is only a concern for pre-stringification (via transformHoist by
14529
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14530
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14531
- // stringification threshold is met.
14532
- let canStringify = true;
14533
14524
  const { children } = node;
14534
14525
  const originalCount = children.length;
14535
14526
  let hoistedCount = 0;
@@ -14542,9 +14533,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14542
14533
  ? 0 /* NOT_CONSTANT */
14543
14534
  : getConstantType(child, context);
14544
14535
  if (constantType > 0 /* NOT_CONSTANT */) {
14545
- if (constantType < 3 /* CAN_STRINGIFY */) {
14546
- canStringify = false;
14547
- }
14548
14536
  if (constantType >= 2 /* CAN_HOIST */) {
14549
14537
  child.codegenNode.patchFlag =
14550
14538
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -14575,17 +14563,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14575
14563
  }
14576
14564
  }
14577
14565
  }
14578
- else if (child.type === 12 /* TEXT_CALL */) {
14579
- const contentType = getConstantType(child.content, context);
14580
- if (contentType > 0) {
14581
- if (contentType < 3 /* CAN_STRINGIFY */) {
14582
- canStringify = false;
14583
- }
14584
- if (contentType >= 2 /* CAN_HOIST */) {
14585
- child.codegenNode = context.hoist(child.codegenNode);
14586
- hoistedCount++;
14587
- }
14588
- }
14566
+ else if (child.type === 12 /* TEXT_CALL */ &&
14567
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14568
+ child.codegenNode = context.hoist(child.codegenNode);
14569
+ hoistedCount++;
14589
14570
  }
14590
14571
  // walk further
14591
14572
  if (child.type === 1 /* ELEMENT */) {
@@ -14609,7 +14590,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14609
14590
  }
14610
14591
  }
14611
14592
  }
14612
- if (canStringify && hoistedCount && context.transformHoist) {
14593
+ if (hoistedCount && context.transformHoist) {
14613
14594
  context.transformHoist(children, context, node);
14614
14595
  }
14615
14596
  // all children were hoisted - the entire children array is hoistable.
@@ -21298,6 +21279,11 @@ function hasMultipleChildren(node) {
21298
21279
  /**
21299
21280
  * This module is Node-only.
21300
21281
  */
21282
+ /**
21283
+ * Regex for replacing placeholders for embedded constant variables
21284
+ * (e.g. import URL string constants generated by compiler-sfc)
21285
+ */
21286
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
21301
21287
  /**
21302
21288
  * Turn eligible hoisted static trees into stringified static nodes, e.g.
21303
21289
  *
@@ -21334,7 +21320,7 @@ const stringifyStatic = (children, context, parent) => {
21334
21320
  ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
21335
21321
  // combine all currently eligible nodes into a single static vnode call
21336
21322
  const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
21337
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
21323
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
21338
21324
  // the 2nd argument indicates the number of DOM nodes this static vnode
21339
21325
  // will insert / hydrate
21340
21326
  String(currentChunk.length)
@@ -21402,7 +21388,7 @@ const replaceHoist = (node, replacement, context) => {
21402
21388
  const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
21403
21389
  /**
21404
21390
  * for a hoisted node, analyze it and return:
21405
- * - false: bailed (contains runtime constant)
21391
+ * - false: bailed (contains non-stringifiable props or runtime constant)
21406
21392
  * - [nc, ec] where
21407
21393
  * - nc is the number of nodes inside
21408
21394
  * - ec is the number of element with bindings inside
@@ -21440,6 +21426,11 @@ function analyzeNode(node) {
21440
21426
  (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
21441
21427
  return bail();
21442
21428
  }
21429
+ if (p.exp &&
21430
+ (p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
21431
+ p.exp.constType < 3 /* CAN_STRINGIFY */)) {
21432
+ return bail();
21433
+ }
21443
21434
  }
21444
21435
  }
21445
21436
  for (let i = 0; i < node.children.length; i++) {
@@ -21495,8 +21486,15 @@ function stringifyElement(node, context) {
21495
21486
  }
21496
21487
  }
21497
21488
  else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
21489
+ const exp = p.exp;
21490
+ if (exp.content[0] === '_') {
21491
+ // internally generated string constant references
21492
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
21493
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
21494
+ continue;
21495
+ }
21498
21496
  // constant v-bind, e.g. :foo="1"
21499
- let evaluated = evaluateConstant(p.exp);
21497
+ let evaluated = evaluateConstant(exp);
21500
21498
  if (evaluated != null) {
21501
21499
  const arg = p.arg && p.arg.content;
21502
21500
  if (arg === 'class') {
@@ -3879,7 +3879,7 @@ function setFullProps(instance, rawProps, props, attrs) {
3879
3879
  continue;
3880
3880
  }
3881
3881
  }
3882
- if (value !== attrs[key]) {
3882
+ if (!(key in attrs) || value !== attrs[key]) {
3883
3883
  attrs[key] = value;
3884
3884
  hasAttrsChanged = true;
3885
3885
  }
@@ -4269,7 +4269,7 @@ function createCompatVue(createApp, createSingletonApp) {
4269
4269
  return vm;
4270
4270
  }
4271
4271
  }
4272
- Vue.version = "3.2.23";
4272
+ Vue.version = "3.2.24";
4273
4273
  Vue.config = singletonApp.config;
4274
4274
  Vue.use = (p, ...options) => {
4275
4275
  if (p && isFunction(p.install)) {
@@ -6886,6 +6886,7 @@ function convertLegacyFunctionalComponent(comp) {
6886
6886
  };
6887
6887
  Func.props = comp.props;
6888
6888
  Func.displayName = comp.name;
6889
+ Func.compatConfig = comp.compatConfig;
6889
6890
  // v2 functional components do not inherit attrs
6890
6891
  Func.inheritAttrs = false;
6891
6892
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8964,7 +8965,7 @@ function isMemoSame(cached, memo) {
8964
8965
  }
8965
8966
 
8966
8967
  // Core API ------------------------------------------------------------------
8967
- const version = "3.2.23";
8968
+ const version = "3.2.24";
8968
8969
  const _ssrUtils = {
8969
8970
  createComponentInstance,
8970
8971
  setupComponent,
@@ -11220,7 +11221,6 @@ function getUnnormalizedProps(props, callPath = []) {
11220
11221
  }
11221
11222
  function injectProp(node, prop, context) {
11222
11223
  let propsWithInjection;
11223
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11224
11224
  /**
11225
11225
  * 1. mergeProps(...)
11226
11226
  * 2. toHandlers(...)
@@ -11229,7 +11229,7 @@ function injectProp(node, prop, context) {
11229
11229
  *
11230
11230
  * we need to get the real props before normalization
11231
11231
  */
11232
- let props = originalProps;
11232
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11233
11233
  let callPath = [];
11234
11234
  let parentCall;
11235
11235
  if (props &&
@@ -12196,15 +12196,6 @@ function isSingleElementRoot(root, child) {
12196
12196
  !isSlotOutlet(child));
12197
12197
  }
12198
12198
  function walk$1(node, context, doNotHoistNode = false) {
12199
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
12200
- // static bindings with expressions. These expressions are guaranteed to be
12201
- // constant so they are still eligible for hoisting, but they are only
12202
- // available at runtime and therefore cannot be evaluated ahead of time.
12203
- // This is only a concern for pre-stringification (via transformHoist by
12204
- // @vue/compiler-dom), but doing it here allows us to perform only one full
12205
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
12206
- // stringification threshold is met.
12207
- let canStringify = true;
12208
12199
  const { children } = node;
12209
12200
  const originalCount = children.length;
12210
12201
  let hoistedCount = 0;
@@ -12217,9 +12208,6 @@ function walk$1(node, context, doNotHoistNode = false) {
12217
12208
  ? 0 /* NOT_CONSTANT */
12218
12209
  : getConstantType(child, context);
12219
12210
  if (constantType > 0 /* NOT_CONSTANT */) {
12220
- if (constantType < 3 /* CAN_STRINGIFY */) {
12221
- canStringify = false;
12222
- }
12223
12211
  if (constantType >= 2 /* CAN_HOIST */) {
12224
12212
  child.codegenNode.patchFlag =
12225
12213
  -1 /* HOISTED */ + (``);
@@ -12250,17 +12238,10 @@ function walk$1(node, context, doNotHoistNode = false) {
12250
12238
  }
12251
12239
  }
12252
12240
  }
12253
- else if (child.type === 12 /* TEXT_CALL */) {
12254
- const contentType = getConstantType(child.content, context);
12255
- if (contentType > 0) {
12256
- if (contentType < 3 /* CAN_STRINGIFY */) {
12257
- canStringify = false;
12258
- }
12259
- if (contentType >= 2 /* CAN_HOIST */) {
12260
- child.codegenNode = context.hoist(child.codegenNode);
12261
- hoistedCount++;
12262
- }
12263
- }
12241
+ else if (child.type === 12 /* TEXT_CALL */ &&
12242
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
12243
+ child.codegenNode = context.hoist(child.codegenNode);
12244
+ hoistedCount++;
12264
12245
  }
12265
12246
  // walk further
12266
12247
  if (child.type === 1 /* ELEMENT */) {
@@ -12284,7 +12265,7 @@ function walk$1(node, context, doNotHoistNode = false) {
12284
12265
  }
12285
12266
  }
12286
12267
  }
12287
- if (canStringify && hoistedCount && context.transformHoist) {
12268
+ if (hoistedCount && context.transformHoist) {
12288
12269
  context.transformHoist(children, context, node);
12289
12270
  }
12290
12271
  // all children were hoisted - the entire children array is hoistable.
@@ -18830,6 +18811,11 @@ const transformShow = (dir, node, context) => {
18830
18811
  /**
18831
18812
  * This module is Node-only.
18832
18813
  */
18814
+ /**
18815
+ * Regex for replacing placeholders for embedded constant variables
18816
+ * (e.g. import URL string constants generated by compiler-sfc)
18817
+ */
18818
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
18833
18819
  /**
18834
18820
  * Turn eligible hoisted static trees into stringified static nodes, e.g.
18835
18821
  *
@@ -18866,7 +18852,7 @@ const stringifyStatic = (children, context, parent) => {
18866
18852
  ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
18867
18853
  // combine all currently eligible nodes into a single static vnode call
18868
18854
  const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
18869
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
18855
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
18870
18856
  // the 2nd argument indicates the number of DOM nodes this static vnode
18871
18857
  // will insert / hydrate
18872
18858
  String(currentChunk.length)
@@ -18934,7 +18920,7 @@ const replaceHoist = (node, replacement, context) => {
18934
18920
  const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
18935
18921
  /**
18936
18922
  * for a hoisted node, analyze it and return:
18937
- * - false: bailed (contains runtime constant)
18923
+ * - false: bailed (contains non-stringifiable props or runtime constant)
18938
18924
  * - [nc, ec] where
18939
18925
  * - nc is the number of nodes inside
18940
18926
  * - ec is the number of element with bindings inside
@@ -18972,6 +18958,11 @@ function analyzeNode(node) {
18972
18958
  (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
18973
18959
  return bail();
18974
18960
  }
18961
+ if (p.exp &&
18962
+ (p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
18963
+ p.exp.constType < 3 /* CAN_STRINGIFY */)) {
18964
+ return bail();
18965
+ }
18975
18966
  }
18976
18967
  }
18977
18968
  for (let i = 0; i < node.children.length; i++) {
@@ -19027,8 +19018,15 @@ function stringifyElement(node, context) {
19027
19018
  }
19028
19019
  }
19029
19020
  else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
19021
+ const exp = p.exp;
19022
+ if (exp.content[0] === '_') {
19023
+ // internally generated string constant references
19024
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
19025
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
19026
+ continue;
19027
+ }
19030
19028
  // constant v-bind, e.g. :foo="1"
19031
- let evaluated = evaluateConstant(p.exp);
19029
+ let evaluated = evaluateConstant(exp);
19032
19030
  if (evaluated != null) {
19033
19031
  const arg = p.arg && p.arg.content;
19034
19032
  if (arg === 'class') {
@@ -4732,7 +4732,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4732
4732
  continue;
4733
4733
  }
4734
4734
  }
4735
- if (value !== attrs[key]) {
4735
+ if (!(key in attrs) || value !== attrs[key]) {
4736
4736
  attrs[key] = value;
4737
4737
  hasAttrsChanged = true;
4738
4738
  }
@@ -5313,7 +5313,7 @@ function createCompatVue(createApp, createSingletonApp) {
5313
5313
  return vm;
5314
5314
  }
5315
5315
  }
5316
- Vue.version = "3.2.23";
5316
+ Vue.version = "3.2.24";
5317
5317
  Vue.config = singletonApp.config;
5318
5318
  Vue.use = (p, ...options) => {
5319
5319
  if (p && isFunction(p.install)) {
@@ -8278,6 +8278,7 @@ function convertLegacyFunctionalComponent(comp) {
8278
8278
  };
8279
8279
  Func.props = comp.props;
8280
8280
  Func.displayName = comp.name;
8281
+ Func.compatConfig = comp.compatConfig;
8281
8282
  // v2 functional components do not inherit attrs
8282
8283
  Func.inheritAttrs = false;
8283
8284
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -10908,7 +10909,7 @@ function isMemoSame(cached, memo) {
10908
10909
  }
10909
10910
 
10910
10911
  // Core API ------------------------------------------------------------------
10911
- const version = "3.2.23";
10912
+ const version = "3.2.24";
10912
10913
  /**
10913
10914
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10914
10915
  * @internal
@@ -11583,7 +11584,7 @@ class VueElement extends BaseClass {
11583
11584
  // HMR
11584
11585
  {
11585
11586
  instance.ceReload = newStyles => {
11586
- // alawys reset styles
11587
+ // always reset styles
11587
11588
  if (this._styles) {
11588
11589
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11589
11590
  this._styles.length = 0;
@@ -13367,7 +13368,6 @@ function getUnnormalizedProps(props, callPath = []) {
13367
13368
  }
13368
13369
  function injectProp(node, prop, context) {
13369
13370
  let propsWithInjection;
13370
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13371
13371
  /**
13372
13372
  * 1. mergeProps(...)
13373
13373
  * 2. toHandlers(...)
@@ -13376,7 +13376,7 @@ function injectProp(node, prop, context) {
13376
13376
  *
13377
13377
  * we need to get the real props before normalization
13378
13378
  */
13379
- let props = originalProps;
13379
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13380
13380
  let callPath = [];
13381
13381
  let parentCall;
13382
13382
  if (props &&
@@ -14397,15 +14397,6 @@ function isSingleElementRoot(root, child) {
14397
14397
  !isSlotOutlet(child));
14398
14398
  }
14399
14399
  function walk$1(node, context, doNotHoistNode = false) {
14400
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14401
- // static bindings with expressions. These expressions are guaranteed to be
14402
- // constant so they are still eligible for hoisting, but they are only
14403
- // available at runtime and therefore cannot be evaluated ahead of time.
14404
- // This is only a concern for pre-stringification (via transformHoist by
14405
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14406
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14407
- // stringification threshold is met.
14408
- let canStringify = true;
14409
14400
  const { children } = node;
14410
14401
  const originalCount = children.length;
14411
14402
  let hoistedCount = 0;
@@ -14418,9 +14409,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14418
14409
  ? 0 /* NOT_CONSTANT */
14419
14410
  : getConstantType(child, context);
14420
14411
  if (constantType > 0 /* NOT_CONSTANT */) {
14421
- if (constantType < 3 /* CAN_STRINGIFY */) {
14422
- canStringify = false;
14423
- }
14424
14412
  if (constantType >= 2 /* CAN_HOIST */) {
14425
14413
  child.codegenNode.patchFlag =
14426
14414
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -14451,17 +14439,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14451
14439
  }
14452
14440
  }
14453
14441
  }
14454
- else if (child.type === 12 /* TEXT_CALL */) {
14455
- const contentType = getConstantType(child.content, context);
14456
- if (contentType > 0) {
14457
- if (contentType < 3 /* CAN_STRINGIFY */) {
14458
- canStringify = false;
14459
- }
14460
- if (contentType >= 2 /* CAN_HOIST */) {
14461
- child.codegenNode = context.hoist(child.codegenNode);
14462
- hoistedCount++;
14463
- }
14464
- }
14442
+ else if (child.type === 12 /* TEXT_CALL */ &&
14443
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14444
+ child.codegenNode = context.hoist(child.codegenNode);
14445
+ hoistedCount++;
14465
14446
  }
14466
14447
  // walk further
14467
14448
  if (child.type === 1 /* ELEMENT */) {
@@ -14485,7 +14466,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14485
14466
  }
14486
14467
  }
14487
14468
  }
14488
- if (canStringify && hoistedCount && context.transformHoist) {
14469
+ if (hoistedCount && context.transformHoist) {
14489
14470
  context.transformHoist(children, context, node);
14490
14471
  }
14491
14472
  // all children were hoisted - the entire children array is hoistable.