@vue/compat 3.5.29 → 3.5.31

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.29
2
+ * @vue/compat v3.5.31
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1176,10 +1176,17 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1176
1176
  }
1177
1177
  function reduce(self, method, fn, args) {
1178
1178
  const arr = shallowReadArray(self);
1179
+ const needsWrap = arr !== self && !isShallow(self);
1179
1180
  let wrappedFn = fn;
1181
+ let wrapInitialAccumulator = false;
1180
1182
  if (arr !== self) {
1181
- if (!isShallow(self)) {
1183
+ if (needsWrap) {
1184
+ wrapInitialAccumulator = args.length === 0;
1182
1185
  wrappedFn = function(acc, item, index) {
1186
+ if (wrapInitialAccumulator) {
1187
+ wrapInitialAccumulator = false;
1188
+ acc = toWrapped(self, acc);
1189
+ }
1183
1190
  return fn.call(this, acc, toWrapped(self, item), index, self);
1184
1191
  };
1185
1192
  } else if (fn.length > 3) {
@@ -1188,7 +1195,8 @@ function reduce(self, method, fn, args) {
1188
1195
  };
1189
1196
  }
1190
1197
  }
1191
- return arr[method](wrappedFn, ...args);
1198
+ const result = arr[method](wrappedFn, ...args);
1199
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1192
1200
  }
1193
1201
  function searchProxy(self, method, args) {
1194
1202
  const arr = toRaw(self);
@@ -1453,15 +1461,14 @@ function createInstrumentations(readonly, shallow) {
1453
1461
  clear: createReadonlyMethod("clear")
1454
1462
  } : {
1455
1463
  add(value) {
1456
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1457
- value = toRaw(value);
1458
- }
1459
1464
  const target = toRaw(this);
1460
1465
  const proto = getProto(target);
1461
- const hadKey = proto.has.call(target, value);
1466
+ const rawValue = toRaw(value);
1467
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1468
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1462
1469
  if (!hadKey) {
1463
- target.add(value);
1464
- trigger(target, "add", value, value);
1470
+ target.add(valueToAdd);
1471
+ trigger(target, "add", valueToAdd, valueToAdd);
1465
1472
  }
1466
1473
  return this;
1467
1474
  },
@@ -1777,16 +1784,16 @@ function toRefs(object) {
1777
1784
  return ret;
1778
1785
  }
1779
1786
  class ObjectRefImpl {
1780
- constructor(_object, _key, _defaultValue) {
1787
+ constructor(_object, key, _defaultValue) {
1781
1788
  this._object = _object;
1782
- this._key = _key;
1783
1789
  this._defaultValue = _defaultValue;
1784
1790
  this["__v_isRef"] = true;
1785
1791
  this._value = void 0;
1792
+ this._key = isSymbol(key) ? key : String(key);
1786
1793
  this._raw = toRaw(_object);
1787
1794
  let shallow = true;
1788
1795
  let obj = _object;
1789
- if (!isArray(_object) || !isIntegerKey(String(_key))) {
1796
+ if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
1790
1797
  do {
1791
1798
  shallow = !isProxy(obj) || isShallow(obj);
1792
1799
  } while (shallow && (obj = obj["__v_raw"]));
@@ -2903,9 +2910,10 @@ const TeleportImpl = {
2903
2910
  mount(container, mainAnchor);
2904
2911
  updateCssVars(n2, true);
2905
2912
  }
2906
- if (isTeleportDeferred(n2.props)) {
2913
+ if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
2907
2914
  n2.el.__isMounted = false;
2908
2915
  queuePostRenderEffect(() => {
2916
+ if (n2.el.__isMounted !== false) return;
2909
2917
  mountToTarget();
2910
2918
  delete n2.el.__isMounted;
2911
2919
  }, parentSuspense);
@@ -2913,7 +2921,12 @@ const TeleportImpl = {
2913
2921
  mountToTarget();
2914
2922
  }
2915
2923
  } else {
2916
- if (isTeleportDeferred(n2.props) && n1.el.__isMounted === false) {
2924
+ n2.el = n1.el;
2925
+ n2.targetStart = n1.targetStart;
2926
+ const mainAnchor = n2.anchor = n1.anchor;
2927
+ const target = n2.target = n1.target;
2928
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
2929
+ if (n1.el.__isMounted === false) {
2917
2930
  queuePostRenderEffect(() => {
2918
2931
  TeleportImpl.process(
2919
2932
  n1,
@@ -2930,11 +2943,6 @@ const TeleportImpl = {
2930
2943
  }, parentSuspense);
2931
2944
  return;
2932
2945
  }
2933
- n2.el = n1.el;
2934
- n2.targetStart = n1.targetStart;
2935
- const mainAnchor = n2.anchor = n1.anchor;
2936
- const target = n2.target = n1.target;
2937
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
2938
2946
  const wasDisabled = isTeleportDisabled(n1.props);
2939
2947
  const currentContainer = wasDisabled ? container : target;
2940
2948
  const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
@@ -5062,9 +5070,11 @@ function renderList(source, renderItem, cache, index) {
5062
5070
  );
5063
5071
  }
5064
5072
  } else if (typeof source === "number") {
5065
- ret = new Array(source);
5066
- for (let i = 0; i < source; i++) {
5067
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5073
+ {
5074
+ ret = new Array(source);
5075
+ for (let i = 0; i < source; i++) {
5076
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5077
+ }
5068
5078
  }
5069
5079
  } else if (isObject(source)) {
5070
5080
  if (source[Symbol.iterator]) {
@@ -5616,15 +5626,28 @@ function createPropsRestProxy(props, excludedKeys) {
5616
5626
  }
5617
5627
  function withAsyncContext(getAwaitable) {
5618
5628
  const ctx = getCurrentInstance();
5629
+ const inSSRSetup = isInSSRComponentSetup;
5619
5630
  let awaitable = getAwaitable();
5620
5631
  unsetCurrentInstance();
5632
+ if (inSSRSetup) {
5633
+ setInSSRSetupState(false);
5634
+ }
5635
+ const restore = () => {
5636
+ setCurrentInstance(ctx);
5637
+ if (inSSRSetup) {
5638
+ setInSSRSetupState(true);
5639
+ }
5640
+ };
5621
5641
  const cleanup = () => {
5622
5642
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5623
5643
  unsetCurrentInstance();
5644
+ if (inSSRSetup) {
5645
+ setInSSRSetupState(false);
5646
+ }
5624
5647
  };
5625
5648
  if (isPromise(awaitable)) {
5626
5649
  awaitable = awaitable.catch((e) => {
5627
- setCurrentInstance(ctx);
5650
+ restore();
5628
5651
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5629
5652
  throw e;
5630
5653
  });
@@ -5632,7 +5655,7 @@ function withAsyncContext(getAwaitable) {
5632
5655
  return [
5633
5656
  awaitable,
5634
5657
  () => {
5635
- setCurrentInstance(ctx);
5658
+ restore();
5636
5659
  Promise.resolve().then(cleanup);
5637
5660
  }
5638
5661
  ];
@@ -6053,7 +6076,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6053
6076
  return vm;
6054
6077
  }
6055
6078
  }
6056
- Vue.version = `2.6.14-compat:${"3.5.29"}`;
6079
+ Vue.version = `2.6.14-compat:${"3.5.31"}`;
6057
6080
  Vue.config = singletonApp.config;
6058
6081
  Vue.use = (plugin, ...options) => {
6059
6082
  if (plugin && isFunction(plugin.install)) {
@@ -6953,11 +6976,12 @@ function hasPropValueChanged(nextProps, prevProps, key) {
6953
6976
  }
6954
6977
  return nextProp !== prevProp;
6955
6978
  }
6956
- function updateHOCHostEl({ vnode, parent }, el) {
6979
+ function updateHOCHostEl({ vnode, parent, suspense }, el) {
6957
6980
  while (parent) {
6958
6981
  const root = parent.subTree;
6959
6982
  if (root.suspense && root.suspense.activeBranch === vnode) {
6960
- root.el = vnode.el;
6983
+ root.suspense.vnode.el = root.el = el;
6984
+ vnode = root;
6961
6985
  }
6962
6986
  if (root === vnode) {
6963
6987
  (vnode = parent.vnode).el = el;
@@ -6966,6 +6990,9 @@ function updateHOCHostEl({ vnode, parent }, el) {
6966
6990
  break;
6967
6991
  }
6968
6992
  }
6993
+ if (suspense && suspense.activeBranch === vnode) {
6994
+ suspense.vnode.el = el;
6995
+ }
6969
6996
  }
6970
6997
 
6971
6998
  function createPropsDefaultThis(instance, rawProps, propKey) {
@@ -7663,9 +7690,12 @@ function baseCreateRenderer(options, createHydrationFns) {
7663
7690
  hostInsert(el, container, anchor);
7664
7691
  if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
7665
7692
  queuePostRenderEffect(() => {
7666
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7667
- needCallTransitionHooks && transition.enter(el);
7668
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7693
+ try {
7694
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7695
+ needCallTransitionHooks && transition.enter(el);
7696
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7697
+ } finally {
7698
+ }
7669
7699
  }, parentSuspense);
7670
7700
  }
7671
7701
  };
@@ -8027,7 +8057,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8027
8057
  }
8028
8058
  } else {
8029
8059
  if (root.ce && root.ce._hasShadowRoot()) {
8030
- root.ce._injectChildStyle(type);
8060
+ root.ce._injectChildStyle(
8061
+ type,
8062
+ instance.parent ? instance.parent.type : void 0
8063
+ );
8031
8064
  }
8032
8065
  const subTree = instance.subTree = renderComponentRoot(instance);
8033
8066
  patch(
@@ -8514,7 +8547,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8514
8547
  shapeFlag,
8515
8548
  patchFlag,
8516
8549
  dirs,
8517
- cacheIndex
8550
+ cacheIndex,
8551
+ memo
8518
8552
  } = vnode;
8519
8553
  if (patchFlag === -2) {
8520
8554
  optimized = false;
@@ -8576,10 +8610,14 @@ function baseCreateRenderer(options, createHydrationFns) {
8576
8610
  remove(vnode);
8577
8611
  }
8578
8612
  }
8579
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
8613
+ const shouldInvalidateMemo = memo != null && cacheIndex == null;
8614
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) {
8580
8615
  queuePostRenderEffect(() => {
8581
8616
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
8582
8617
  shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
8618
+ if (shouldInvalidateMemo) {
8619
+ vnode.el = null;
8620
+ }
8583
8621
  }, parentSuspense);
8584
8622
  }
8585
8623
  };
@@ -9115,6 +9153,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9115
9153
  pendingId: suspenseId++,
9116
9154
  timeout: typeof timeout === "number" ? timeout : -1,
9117
9155
  activeBranch: null,
9156
+ isFallbackMountPending: false,
9118
9157
  pendingBranch: null,
9119
9158
  isInFallback: !isHydrating,
9120
9159
  isHydrating,
@@ -9152,7 +9191,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9152
9191
  }
9153
9192
  };
9154
9193
  }
9155
- if (activeBranch) {
9194
+ if (activeBranch && !suspense.isFallbackMountPending) {
9156
9195
  if (parentNode(activeBranch.el) === container2) {
9157
9196
  anchor = next(activeBranch);
9158
9197
  }
@@ -9165,6 +9204,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9165
9204
  move(pendingBranch, container2, anchor, 0);
9166
9205
  }
9167
9206
  }
9207
+ suspense.isFallbackMountPending = false;
9168
9208
  setActiveBranch(suspense, pendingBranch);
9169
9209
  suspense.pendingBranch = null;
9170
9210
  suspense.isInFallback = false;
@@ -9200,6 +9240,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9200
9240
  triggerEvent(vnode2, "onFallback");
9201
9241
  const anchor2 = next(activeBranch);
9202
9242
  const mountFallback = () => {
9243
+ suspense.isFallbackMountPending = false;
9203
9244
  if (!suspense.isInFallback) {
9204
9245
  return;
9205
9246
  }
@@ -9219,6 +9260,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9219
9260
  };
9220
9261
  const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
9221
9262
  if (delayEnter) {
9263
+ suspense.isFallbackMountPending = true;
9222
9264
  activeBranch.transition.afterLeave = mountFallback;
9223
9265
  }
9224
9266
  suspense.isInFallback = true;
@@ -9790,6 +9832,10 @@ function mergeProps(...args) {
9790
9832
  const incoming = toMerge[key];
9791
9833
  if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
9792
9834
  ret[key] = existing ? [].concat(existing, incoming) : incoming;
9835
+ } else if (incoming == null && existing == null && // mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
9836
+ // the model listener.
9837
+ !isModelListener(key)) {
9838
+ ret[key] = incoming;
9793
9839
  }
9794
9840
  } else if (key !== "") {
9795
9841
  ret[key] = toMerge[key];
@@ -10165,7 +10211,7 @@ function isMemoSame(cached, memo) {
10165
10211
  return true;
10166
10212
  }
10167
10213
 
10168
- const version = "3.5.29";
10214
+ const version = "3.5.31";
10169
10215
  const warn$1 = NOOP;
10170
10216
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10171
10217
  const devtools = void 0;
@@ -10949,7 +10995,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
10949
10995
  }
10950
10996
  } else if (
10951
10997
  // #11081 force set props for possible async custom element
10952
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
10998
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
10999
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11000
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
10953
11001
  ) {
10954
11002
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
10955
11003
  } else {
@@ -10997,6 +11045,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
10997
11045
  }
10998
11046
  return key in el;
10999
11047
  }
11048
+ function shouldSetAsPropForVueCE(el, key) {
11049
+ const props = (
11050
+ // @ts-expect-error _def is private
11051
+ el._def.props
11052
+ );
11053
+ if (!props) {
11054
+ return false;
11055
+ }
11056
+ const camelKey = camelize(key);
11057
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11058
+ }
11000
11059
 
11001
11060
  const REMOVAL = {};
11002
11061
  // @__NO_SIDE_EFFECTS__
@@ -11041,6 +11100,7 @@ class VueElement extends BaseClass {
11041
11100
  this._dirty = false;
11042
11101
  this._numberProps = null;
11043
11102
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11103
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11044
11104
  this._ob = null;
11045
11105
  if (this.shadowRoot && _createApp !== createApp) {
11046
11106
  this._root = this.shadowRoot;
@@ -11064,7 +11124,8 @@ class VueElement extends BaseClass {
11064
11124
  }
11065
11125
  this._connected = true;
11066
11126
  let parent = this;
11067
- while (parent = parent && (parent.parentNode || parent.host)) {
11127
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11128
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11068
11129
  if (parent instanceof VueElement) {
11069
11130
  this._parent = parent;
11070
11131
  break;
@@ -11290,7 +11351,7 @@ class VueElement extends BaseClass {
11290
11351
  }
11291
11352
  return vnode;
11292
11353
  }
11293
- _applyStyles(styles, owner) {
11354
+ _applyStyles(styles, owner, parentComp) {
11294
11355
  if (!styles) return;
11295
11356
  if (owner) {
11296
11357
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11299,13 +11360,43 @@ class VueElement extends BaseClass {
11299
11360
  this._styleChildren.add(owner);
11300
11361
  }
11301
11362
  const nonce = this._nonce;
11363
+ const root = this.shadowRoot;
11364
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11365
+ let last = null;
11302
11366
  for (let i = styles.length - 1; i >= 0; i--) {
11303
11367
  const s = document.createElement("style");
11304
11368
  if (nonce) s.setAttribute("nonce", nonce);
11305
11369
  s.textContent = styles[i];
11306
- this.shadowRoot.prepend(s);
11370
+ root.insertBefore(s, last || insertionAnchor);
11371
+ last = s;
11372
+ if (i === 0) {
11373
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11374
+ if (owner) this._styleAnchors.set(owner, s);
11375
+ }
11307
11376
  }
11308
11377
  }
11378
+ _getStyleAnchor(comp) {
11379
+ if (!comp) {
11380
+ return null;
11381
+ }
11382
+ const anchor = this._styleAnchors.get(comp);
11383
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11384
+ return anchor;
11385
+ }
11386
+ if (anchor) {
11387
+ this._styleAnchors.delete(comp);
11388
+ }
11389
+ return null;
11390
+ }
11391
+ _getRootStyleInsertionAnchor(root) {
11392
+ for (let i = 0; i < root.childNodes.length; i++) {
11393
+ const node = root.childNodes[i];
11394
+ if (!(node instanceof HTMLStyleElement)) {
11395
+ return node;
11396
+ }
11397
+ }
11398
+ return null;
11399
+ }
11309
11400
  /**
11310
11401
  * Only called when shadowRoot is false
11311
11402
  */
@@ -11368,8 +11459,8 @@ class VueElement extends BaseClass {
11368
11459
  /**
11369
11460
  * @internal
11370
11461
  */
11371
- _injectChildStyle(comp) {
11372
- this._applyStyles(comp.styles, comp);
11462
+ _injectChildStyle(comp, parentComp) {
11463
+ this._applyStyles(comp.styles, comp, parentComp);
11373
11464
  }
11374
11465
  /**
11375
11466
  * @internal
@@ -11641,7 +11732,8 @@ const vModelText = {
11641
11732
  if (elValue === newValue) {
11642
11733
  return;
11643
11734
  }
11644
- if (document.activeElement === el && el.type !== "range") {
11735
+ const rootNode = el.getRootNode();
11736
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
11645
11737
  if (lazy && value === oldValue) {
11646
11738
  return;
11647
11739
  }
@@ -16761,7 +16853,7 @@ const transformFor = createStructuralDirectiveTransform(
16761
16853
  loop.body = createBlockStatement([
16762
16854
  createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
16763
16855
  createCompoundExpression([
16764
- `if (_cached`,
16856
+ `if (_cached && _cached.el`,
16765
16857
  ...keyExp ? [` && _cached.key === `, keyExp] : [],
16766
16858
  ` && ${context.helperString(
16767
16859
  IS_MEMO_SAME