@vue/compat 3.5.34 → 3.5.36

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
@@ -18,7 +18,7 @@ While we've tried hard to make the migration build mimic Vue 2 behavior as much
18
18
 
19
19
  - Internet Explorer 11 support: [Vue 3 has officially dropped the plan for IE11 support](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0038-vue3-ie11-support.md). If you still need to support IE11 or below, you will have to stay on Vue 2.
20
20
 
21
- - Server-side rendering: the migration build can be used for SSR, but migrating a custom SSR setup is much more involved. The general idea is replacing `vue-server-renderer` with [`@vue/server-renderer`](https://github.com/vuejs/core/tree/main/packages/server-renderer). Vue 3 no longer provides a bundle renderer and it is recommended to use Vue 3 SSR with [Vite](https://vitejs.dev/guide/ssr.html). If you are using [Nuxt.js](https://nuxtjs.org/), it is probably better to wait for Nuxt 3.
21
+ - Server-side rendering: the migration build can be used for SSR, but migrating a custom SSR setup is much more involved. The general idea is replacing `vue-server-renderer` with [`@vue/server-renderer`](https://github.com/vuejs/core/tree/main/packages/server-renderer). Vue 3 no longer provides a bundle renderer and it is recommended to use Vue 3 SSR with [Vite](https://vite.dev/guide/ssr). If you are using [Nuxt.js](https://nuxtjs.org/), it is probably better to wait for Nuxt 3.
22
22
 
23
23
  ### Expectations
24
24
 
@@ -43,7 +43,7 @@ The following workflow walks through the steps of migrating an actual Vue 2 app
43
43
  1. Upgrade tooling if applicable.
44
44
  - If using custom webpack setup: Upgrade `vue-loader` to `^16.0.0`.
45
45
  - If using `vue-cli`: upgrade to the latest `@vue/cli-service` with `vue upgrade`
46
- - (Alternative) migrate to [Vite](https://vitejs.dev/) + [vite-plugin-vue2](https://github.com/underfin/vite-plugin-vue2). [[Example commit](https://github.com/vuejs/vue-hackernews-2.0/commit/565b948919eb58f22a32afca7e321b490cb3b074)]
46
+ - (Alternative) migrate to [Vite](https://vite.dev/) + [vite-plugin-vue2](https://github.com/underfin/vite-plugin-vue2). [[Example commit](https://github.com/vuejs/vue-hackernews-2.0/commit/565b948919eb58f22a32afca7e321b490cb3b074)]
47
47
 
48
48
  2. In `package.json`, update `vue` to 3.1, install `@vue/compat` of the same version, and replace `vue-template-compiler` (if present) with `@vue/compiler-sfc`:
49
49
 
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.34
2
+ * @vue/compat v3.5.36
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1798,9 +1798,6 @@ function targetTypeMap(rawType) {
1798
1798
  return 0 /* INVALID */;
1799
1799
  }
1800
1800
  }
1801
- function getTargetType(value) {
1802
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
1803
- }
1804
1801
  // @__NO_SIDE_EFFECTS__
1805
1802
  function reactive(target) {
1806
1803
  if (/* @__PURE__ */ isReadonly(target)) {
@@ -1858,14 +1855,17 @@ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandl
1858
1855
  if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1859
1856
  return target;
1860
1857
  }
1861
- const targetType = getTargetType(target);
1862
- if (targetType === 0 /* INVALID */) {
1858
+ if (target["__v_skip"] || !Object.isExtensible(target)) {
1863
1859
  return target;
1864
1860
  }
1865
1861
  const existingProxy = proxyMap.get(target);
1866
1862
  if (existingProxy) {
1867
1863
  return existingProxy;
1868
1864
  }
1865
+ const targetType = targetTypeMap(toRawType(target));
1866
+ if (targetType === 0 /* INVALID */) {
1867
+ return target;
1868
+ }
1869
1869
  const proxy = new Proxy(
1870
1870
  target,
1871
1871
  targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
@@ -2293,8 +2293,9 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2293
2293
  if (once && cb) {
2294
2294
  const _cb = cb;
2295
2295
  cb = (...args) => {
2296
- _cb(...args);
2296
+ const res = _cb(...args);
2297
2297
  watchHandle();
2298
+ return res;
2298
2299
  };
2299
2300
  }
2300
2301
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -2304,7 +2305,7 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2304
2305
  }
2305
2306
  if (cb) {
2306
2307
  const newValue = effect.run();
2307
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2308
+ if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2308
2309
  if (cleanup) {
2309
2310
  cleanup();
2310
2311
  }
@@ -4017,19 +4018,18 @@ const TeleportImpl = {
4017
4018
  target,
4018
4019
  props
4019
4020
  } = vnode;
4020
- let shouldRemove = doRemove || !isTeleportDisabled(props);
4021
+ const shouldRemove = doRemove || !isTeleportDisabled(props);
4021
4022
  const pendingMount = pendingMounts.get(vnode);
4022
4023
  if (pendingMount) {
4023
4024
  pendingMount.flags |= 8;
4024
4025
  pendingMounts.delete(vnode);
4025
- shouldRemove = false;
4026
4026
  }
4027
4027
  if (target) {
4028
4028
  hostRemove(targetStart);
4029
4029
  hostRemove(targetAnchor);
4030
4030
  }
4031
4031
  doRemove && hostRemove(anchor);
4032
- if (shapeFlag & 16) {
4032
+ if (!pendingMount && shapeFlag & 16) {
4033
4033
  for (let i = 0; i < children.length; i++) {
4034
4034
  const child = children[i];
4035
4035
  unmount(
@@ -5000,20 +5000,16 @@ function createHydrationFunctions(rendererInternals) {
5000
5000
  slotScopeIds,
5001
5001
  optimized
5002
5002
  );
5003
- let hasWarned = false;
5004
- while (next) {
5005
- if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
5006
- if (!hasWarned) {
5007
- warn$1(
5008
- `Hydration children mismatch on`,
5009
- el,
5010
- `
5003
+ if (next && !isMismatchAllowed(el, 1 /* CHILDREN */)) {
5004
+ warn$1(
5005
+ `Hydration children mismatch on`,
5006
+ el,
5007
+ `
5011
5008
  Server rendered element contains more child nodes than client vdom.`
5012
- );
5013
- hasWarned = true;
5014
- }
5015
- logMismatchError();
5016
- }
5009
+ );
5010
+ logMismatchError();
5011
+ }
5012
+ while (next) {
5017
5013
  const cur = next;
5018
5014
  next = next.nextSibling;
5019
5015
  remove(cur);
@@ -5076,7 +5072,7 @@ Server rendered element contains more child nodes than client vdom.`
5076
5072
  optimized = optimized || !!parentVNode.dynamicChildren;
5077
5073
  const children = parentVNode.children;
5078
5074
  const l = children.length;
5079
- let hasWarned = false;
5075
+ let hasCheckedMismatch = false;
5080
5076
  for (let i = 0; i < l; i++) {
5081
5077
  const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
5082
5078
  const isText = vnode.type === Text;
@@ -5104,17 +5100,17 @@ Server rendered element contains more child nodes than client vdom.`
5104
5100
  } else if (isText && !vnode.children) {
5105
5101
  insert(vnode.el = createText(""), container);
5106
5102
  } else {
5107
- if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
5108
- if (!hasWarned) {
5103
+ if (!hasCheckedMismatch) {
5104
+ hasCheckedMismatch = true;
5105
+ if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
5109
5106
  warn$1(
5110
5107
  `Hydration children mismatch on`,
5111
5108
  container,
5112
5109
  `
5113
5110
  Server rendered element contains fewer child nodes than client vdom.`
5114
5111
  );
5115
- hasWarned = true;
5112
+ logMismatchError();
5116
5113
  }
5117
- logMismatchError();
5118
5114
  }
5119
5115
  patch(
5120
5116
  null,
@@ -5594,13 +5590,21 @@ function defineAsyncComponent(source) {
5594
5590
  const loaded = ref(false);
5595
5591
  const error = ref();
5596
5592
  const delayed = ref(!!delay);
5593
+ let timeoutTimer;
5594
+ let delayTimer;
5595
+ onUnmounted(() => {
5596
+ if (timeoutTimer != null) clearTimeout(timeoutTimer);
5597
+ if (delayTimer != null) clearTimeout(delayTimer);
5598
+ });
5597
5599
  if (delay) {
5598
- setTimeout(() => {
5600
+ delayTimer = setTimeout(() => {
5601
+ if (instance.isUnmounted) return;
5599
5602
  delayed.value = false;
5600
5603
  }, delay);
5601
5604
  }
5602
5605
  if (timeout != null) {
5603
- setTimeout(() => {
5606
+ timeoutTimer = setTimeout(() => {
5607
+ if (instance.isUnmounted) return;
5604
5608
  if (!loaded.value && !error.value) {
5605
5609
  const err = new Error(
5606
5610
  `Async component timed out after ${timeout}ms.`
@@ -5611,11 +5615,16 @@ function defineAsyncComponent(source) {
5611
5615
  }, timeout);
5612
5616
  }
5613
5617
  load().then(() => {
5618
+ if (instance.isUnmounted) return;
5614
5619
  loaded.value = true;
5615
5620
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
5616
5621
  instance.parent.update();
5617
5622
  }
5618
5623
  }).catch((err) => {
5624
+ if (instance.isUnmounted) {
5625
+ pendingRequest = null;
5626
+ return;
5627
+ }
5619
5628
  onError(err);
5620
5629
  error.value = err;
5621
5630
  });
@@ -7597,7 +7606,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7597
7606
  return vm;
7598
7607
  }
7599
7608
  }
7600
- Vue.version = `2.6.14-compat:${"3.5.34"}`;
7609
+ Vue.version = `2.6.14-compat:${"3.5.36"}`;
7601
7610
  Vue.config = singletonApp.config;
7602
7611
  Vue.use = (plugin, ...options) => {
7603
7612
  if (plugin && isFunction(plugin.install)) {
@@ -7937,6 +7946,9 @@ function defineReactive(obj, key, val) {
7937
7946
  try {
7938
7947
  defineReactiveSimple(val, key2, val[key2]);
7939
7948
  } catch (e) {
7949
+ {
7950
+ warn$1(`Failed making property "${key2}" reactive:`, e);
7951
+ }
7940
7952
  }
7941
7953
  });
7942
7954
  }
@@ -8275,13 +8287,20 @@ function useModel(props, name, options = EMPTY_OBJ) {
8275
8287
  return;
8276
8288
  }
8277
8289
  const rawProps = i.vnode.props;
8278
- if (!(rawProps && // check if parent has passed v-model
8279
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
8290
+ const hasVModel = !!(rawProps && // check if parent has passed v-model
8291
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps));
8292
+ if (!hasVModel) {
8280
8293
  localValue = value;
8281
8294
  trigger();
8282
8295
  }
8283
8296
  i.emit(`update:${name}`, emittedValue);
8284
- if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
8297
+ if (hasChanged(value, prevSetValue) && (hasChanged(value, emittedValue) && !hasChanged(emittedValue, prevEmittedValue) || // #13524: browsers differ in when they flush microtasks between
8298
+ // event listeners. If a v-model listener emits an intermediate value
8299
+ // and a following listener restores the model to its previous prop
8300
+ // value before parent updates are flushed, the parent render can be
8301
+ // deduped as having no prop change. Force a local update so DOM state
8302
+ // such as an input's value is synchronized back to the current model.
8303
+ hasVModel && prevSetValue !== EMPTY_OBJ && !hasChanged(emittedValue, localValue))) {
8285
8304
  trigger();
8286
8305
  }
8287
8306
  prevSetValue = value;
@@ -10603,9 +10622,13 @@ function baseCreateRenderer(options, createHydrationFns) {
10603
10622
  const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
10604
10623
  if (needTransition2) {
10605
10624
  if (moveType === 0) {
10606
- transition.beforeEnter(el);
10607
- hostInsert(el, container, anchor);
10608
- queuePostRenderEffect(() => transition.enter(el), parentSuspense);
10625
+ if (transition.persisted && !el[leaveCbKey]) {
10626
+ hostInsert(el, container, anchor);
10627
+ } else {
10628
+ transition.beforeEnter(el);
10629
+ hostInsert(el, container, anchor);
10630
+ queuePostRenderEffect(() => transition.enter(el), parentSuspense);
10631
+ }
10609
10632
  } else {
10610
10633
  const { leave, delayLeave, afterLeave } = transition;
10611
10634
  const remove2 = () => {
@@ -10616,16 +10639,21 @@ function baseCreateRenderer(options, createHydrationFns) {
10616
10639
  }
10617
10640
  };
10618
10641
  const performLeave = () => {
10642
+ const wasLeaving = el._isLeaving || !!el[leaveCbKey];
10619
10643
  if (el._isLeaving) {
10620
10644
  el[leaveCbKey](
10621
10645
  true
10622
10646
  /* cancelled */
10623
10647
  );
10624
10648
  }
10625
- leave(el, () => {
10649
+ if (transition.persisted && !wasLeaving) {
10626
10650
  remove2();
10627
- afterLeave && afterLeave();
10628
- });
10651
+ } else {
10652
+ leave(el, () => {
10653
+ remove2();
10654
+ afterLeave && afterLeave();
10655
+ });
10656
+ }
10629
10657
  };
10630
10658
  if (delayLeave) {
10631
10659
  delayLeave(el, remove2, performLeave);
@@ -12720,7 +12748,7 @@ function isMemoSame(cached, memo) {
12720
12748
  return true;
12721
12749
  }
12722
12750
 
12723
- const version = "3.5.34";
12751
+ const version = "3.5.36";
12724
12752
  const warn = warn$1 ;
12725
12753
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12726
12754
  const devtools = devtools$1 ;
@@ -13497,12 +13525,37 @@ function createInvoker(initialValue, instance) {
13497
13525
  } else if (e._vts <= invoker.attached) {
13498
13526
  return;
13499
13527
  }
13500
- callWithAsyncErrorHandling(
13501
- patchStopImmediatePropagation(e, invoker.value),
13502
- instance,
13503
- 5,
13504
- [e]
13505
- );
13528
+ const value = invoker.value;
13529
+ if (isArray(value)) {
13530
+ const originalStop = e.stopImmediatePropagation;
13531
+ e.stopImmediatePropagation = () => {
13532
+ originalStop.call(e);
13533
+ e._stopped = true;
13534
+ };
13535
+ const handlers = value.slice();
13536
+ const args = [e];
13537
+ for (let i = 0; i < handlers.length; i++) {
13538
+ if (e._stopped) {
13539
+ break;
13540
+ }
13541
+ const handler = handlers[i];
13542
+ if (handler) {
13543
+ callWithAsyncErrorHandling(
13544
+ handler,
13545
+ instance,
13546
+ 5,
13547
+ args
13548
+ );
13549
+ }
13550
+ }
13551
+ } else {
13552
+ callWithAsyncErrorHandling(
13553
+ value,
13554
+ instance,
13555
+ 5,
13556
+ [e]
13557
+ );
13558
+ }
13506
13559
  };
13507
13560
  invoker.value = initialValue;
13508
13561
  invoker.attached = getNow();
@@ -13518,20 +13571,6 @@ Expected function or array of functions, received type ${typeof value}.`
13518
13571
  );
13519
13572
  return NOOP;
13520
13573
  }
13521
- function patchStopImmediatePropagation(e, value) {
13522
- if (isArray(value)) {
13523
- const originalStop = e.stopImmediatePropagation;
13524
- e.stopImmediatePropagation = () => {
13525
- originalStop.call(e);
13526
- e._stopped = true;
13527
- };
13528
- return value.map(
13529
- (fn) => (e2) => !e2._stopped && fn && fn(e2)
13530
- );
13531
- } else {
13532
- return value;
13533
- }
13534
- }
13535
13574
 
13536
13575
  const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
13537
13576
  key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
@@ -14214,7 +14253,8 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
14214
14253
  if (children) {
14215
14254
  for (let i = 0; i < children.length; i++) {
14216
14255
  const child = children[i];
14217
- if (child.el && child.el instanceof Element) {
14256
+ if (child.el && child.el instanceof Element && // Hidden v-show nodes have no previous layout box to animate from.
14257
+ !child.el[vShowHidden]) {
14218
14258
  prevChildren.push(child);
14219
14259
  setTransitionHooks(
14220
14260
  child,
@@ -17287,7 +17327,7 @@ const tokenizer = new Tokenizer(stack, {
17287
17327
  }
17288
17328
  },
17289
17329
  oncdata(start, end) {
17290
- if (stack[0].ns !== 0) {
17330
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) {
17291
17331
  onText(getSlice(start, end), start, end);
17292
17332
  } else {
17293
17333
  emitError(1, start - 9);
@@ -18074,6 +18114,7 @@ function createTransformContext(root, {
18074
18114
  imports: [],
18075
18115
  cached: [],
18076
18116
  constantCache: /* @__PURE__ */ new WeakMap(),
18117
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
18077
18118
  temps: 0,
18078
18119
  identifiers: /* @__PURE__ */ Object.create(null),
18079
18120
  scopes: {
@@ -19133,7 +19174,7 @@ const transformExpression = (node, context) => {
19133
19174
  const exp = dir.exp;
19134
19175
  const arg = dir.arg;
19135
19176
  if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
19136
- !(memo && arg && arg.type === 4 && arg.content === "key")) {
19177
+ !(memo && context.vForMemoKeyedNodes.has(node) && arg && arg.type === 4 && arg.content === "key")) {
19137
19178
  dir.exp = processExpression(
19138
19179
  exp,
19139
19180
  context,
@@ -19577,27 +19618,22 @@ const transformFor = createStructuralDirectiveTransform(
19577
19618
  const keyProp = findProp(node, `key`, false, true);
19578
19619
  const isDirKey = keyProp && keyProp.type === 7;
19579
19620
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
19580
- if (memo && keyExp && isDirKey) {
19581
- {
19582
- keyProp.exp = keyExp = processExpression(
19583
- keyExp,
19584
- context
19585
- );
19586
- }
19587
- }
19588
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
19589
- if (isTemplate) {
19590
- if (memo) {
19621
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
19622
+ {
19623
+ if (isTemplate && memo) {
19591
19624
  memo.exp = processExpression(
19592
19625
  memo.exp,
19593
19626
  context
19594
19627
  );
19595
19628
  }
19596
- if (keyProperty && keyProp.type !== 6) {
19597
- keyProperty.value = processExpression(
19629
+ if ((isTemplate || memo) && keyProperty && isDirKey) {
19630
+ keyExp = keyProp.exp = keyProperty.value = processExpression(
19598
19631
  keyProperty.value,
19599
19632
  context
19600
19633
  );
19634
+ if (memo) {
19635
+ context.vForMemoKeyedNodes.add(node);
19636
+ }
19601
19637
  }
19602
19638
  }
19603
19639
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;