@vue/runtime-dom 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/runtime-dom v3.5.29
2
+ * @vue/runtime-dom v3.5.31
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1205,10 +1205,17 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1205
1205
  }
1206
1206
  function reduce(self, method, fn, args) {
1207
1207
  const arr = shallowReadArray(self);
1208
+ const needsWrap = arr !== self && !isShallow(self);
1208
1209
  let wrappedFn = fn;
1210
+ let wrapInitialAccumulator = false;
1209
1211
  if (arr !== self) {
1210
- if (!isShallow(self)) {
1212
+ if (needsWrap) {
1213
+ wrapInitialAccumulator = args.length === 0;
1211
1214
  wrappedFn = function(acc, item, index) {
1215
+ if (wrapInitialAccumulator) {
1216
+ wrapInitialAccumulator = false;
1217
+ acc = toWrapped(self, acc);
1218
+ }
1212
1219
  return fn.call(this, acc, toWrapped(self, item), index, self);
1213
1220
  };
1214
1221
  } else if (fn.length > 3) {
@@ -1217,7 +1224,8 @@ function reduce(self, method, fn, args) {
1217
1224
  };
1218
1225
  }
1219
1226
  }
1220
- return arr[method](wrappedFn, ...args);
1227
+ const result = arr[method](wrappedFn, ...args);
1228
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1221
1229
  }
1222
1230
  function searchProxy(self, method, args) {
1223
1231
  const arr = toRaw(self);
@@ -1507,15 +1515,14 @@ function createInstrumentations(readonly, shallow) {
1507
1515
  clear: createReadonlyMethod("clear")
1508
1516
  } : {
1509
1517
  add(value) {
1510
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1511
- value = toRaw(value);
1512
- }
1513
1518
  const target = toRaw(this);
1514
1519
  const proto = getProto(target);
1515
- const hadKey = proto.has.call(target, value);
1520
+ const rawValue = toRaw(value);
1521
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1522
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1516
1523
  if (!hadKey) {
1517
- target.add(value);
1518
- trigger(target, "add", value, value);
1524
+ target.add(valueToAdd);
1525
+ trigger(target, "add", valueToAdd, valueToAdd);
1519
1526
  }
1520
1527
  return this;
1521
1528
  },
@@ -1872,16 +1879,16 @@ function toRefs(object) {
1872
1879
  return ret;
1873
1880
  }
1874
1881
  class ObjectRefImpl {
1875
- constructor(_object, _key, _defaultValue) {
1882
+ constructor(_object, key, _defaultValue) {
1876
1883
  this._object = _object;
1877
- this._key = _key;
1878
1884
  this._defaultValue = _defaultValue;
1879
1885
  this["__v_isRef"] = true;
1880
1886
  this._value = void 0;
1887
+ this._key = isSymbol(key) ? key : String(key);
1881
1888
  this._raw = toRaw(_object);
1882
1889
  let shallow = true;
1883
1890
  let obj = _object;
1884
- if (!isArray(_object) || !isIntegerKey(String(_key))) {
1891
+ if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
1885
1892
  do {
1886
1893
  shallow = !isProxy(obj) || isShallow(obj);
1887
1894
  } while (shallow && (obj = obj["__v_raw"]));
@@ -2681,6 +2688,13 @@ function checkRecursiveUpdates(seen, fn) {
2681
2688
  }
2682
2689
 
2683
2690
  let isHmrUpdating = false;
2691
+ const setHmrUpdating = (v) => {
2692
+ try {
2693
+ return isHmrUpdating;
2694
+ } finally {
2695
+ isHmrUpdating = v;
2696
+ }
2697
+ };
2684
2698
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
2685
2699
  {
2686
2700
  getGlobalThis().__VUE_HMR_RUNTIME__ = {
@@ -3267,9 +3281,10 @@ const TeleportImpl = {
3267
3281
  mount(container, mainAnchor);
3268
3282
  updateCssVars(n2, true);
3269
3283
  }
3270
- if (isTeleportDeferred(n2.props)) {
3284
+ if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
3271
3285
  n2.el.__isMounted = false;
3272
3286
  queuePostRenderEffect(() => {
3287
+ if (n2.el.__isMounted !== false) return;
3273
3288
  mountToTarget();
3274
3289
  delete n2.el.__isMounted;
3275
3290
  }, parentSuspense);
@@ -3277,7 +3292,12 @@ const TeleportImpl = {
3277
3292
  mountToTarget();
3278
3293
  }
3279
3294
  } else {
3280
- if (isTeleportDeferred(n2.props) && n1.el.__isMounted === false) {
3295
+ n2.el = n1.el;
3296
+ n2.targetStart = n1.targetStart;
3297
+ const mainAnchor = n2.anchor = n1.anchor;
3298
+ const target = n2.target = n1.target;
3299
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
3300
+ if (n1.el.__isMounted === false) {
3281
3301
  queuePostRenderEffect(() => {
3282
3302
  TeleportImpl.process(
3283
3303
  n1,
@@ -3294,11 +3314,6 @@ const TeleportImpl = {
3294
3314
  }, parentSuspense);
3295
3315
  return;
3296
3316
  }
3297
- n2.el = n1.el;
3298
- n2.targetStart = n1.targetStart;
3299
- const mainAnchor = n2.anchor = n1.anchor;
3300
- const target = n2.target = n1.target;
3301
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
3302
3317
  const wasDisabled = isTeleportDisabled(n1.props);
3303
3318
  const currentContainer = wasDisabled ? container : target;
3304
3319
  const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
@@ -3761,7 +3776,7 @@ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
3761
3776
  callHook(hook, [el]);
3762
3777
  },
3763
3778
  enter(el) {
3764
- if (leavingVNodesCache[key] === vnode) return;
3779
+ if (!isHmrUpdating && leavingVNodesCache[key] === vnode) return;
3765
3780
  let hook = onEnter;
3766
3781
  let afterHook = onAfterEnter;
3767
3782
  let cancelHook = onEnterCancelled;
@@ -5398,12 +5413,16 @@ function renderList(source, renderItem, cache, index) {
5398
5413
  );
5399
5414
  }
5400
5415
  } else if (typeof source === "number") {
5401
- if (!Number.isInteger(source)) {
5402
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5403
- }
5404
- ret = new Array(source);
5405
- for (let i = 0; i < source; i++) {
5406
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5416
+ if (!Number.isInteger(source) || source < 0) {
5417
+ warn$1(
5418
+ `The v-for range expects a positive integer value but got ${source}.`
5419
+ );
5420
+ ret = [];
5421
+ } else {
5422
+ ret = new Array(source);
5423
+ for (let i = 0; i < source; i++) {
5424
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5425
+ }
5407
5426
  }
5408
5427
  } else if (isObject(source)) {
5409
5428
  if (source[Symbol.iterator]) {
@@ -5854,6 +5873,7 @@ function createPropsRestProxy(props, excludedKeys) {
5854
5873
  }
5855
5874
  function withAsyncContext(getAwaitable) {
5856
5875
  const ctx = getCurrentInstance();
5876
+ const inSSRSetup = isInSSRComponentSetup;
5857
5877
  if (!ctx) {
5858
5878
  warn$1(
5859
5879
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5861,13 +5881,25 @@ function withAsyncContext(getAwaitable) {
5861
5881
  }
5862
5882
  let awaitable = getAwaitable();
5863
5883
  unsetCurrentInstance();
5884
+ if (inSSRSetup) {
5885
+ setInSSRSetupState(false);
5886
+ }
5887
+ const restore = () => {
5888
+ setCurrentInstance(ctx);
5889
+ if (inSSRSetup) {
5890
+ setInSSRSetupState(true);
5891
+ }
5892
+ };
5864
5893
  const cleanup = () => {
5865
5894
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5866
5895
  unsetCurrentInstance();
5896
+ if (inSSRSetup) {
5897
+ setInSSRSetupState(false);
5898
+ }
5867
5899
  };
5868
5900
  if (isPromise(awaitable)) {
5869
5901
  awaitable = awaitable.catch((e) => {
5870
- setCurrentInstance(ctx);
5902
+ restore();
5871
5903
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5872
5904
  throw e;
5873
5905
  });
@@ -5875,7 +5907,7 @@ function withAsyncContext(getAwaitable) {
5875
5907
  return [
5876
5908
  awaitable,
5877
5909
  () => {
5878
- setCurrentInstance(ctx);
5910
+ restore();
5879
5911
  Promise.resolve().then(cleanup);
5880
5912
  }
5881
5913
  ];
@@ -6988,11 +7020,12 @@ function hasPropValueChanged(nextProps, prevProps, key) {
6988
7020
  }
6989
7021
  return nextProp !== prevProp;
6990
7022
  }
6991
- function updateHOCHostEl({ vnode, parent }, el) {
7023
+ function updateHOCHostEl({ vnode, parent, suspense }, el) {
6992
7024
  while (parent) {
6993
7025
  const root = parent.subTree;
6994
7026
  if (root.suspense && root.suspense.activeBranch === vnode) {
6995
- root.el = vnode.el;
7027
+ root.suspense.vnode.el = root.el = el;
7028
+ vnode = root;
6996
7029
  }
6997
7030
  if (root === vnode) {
6998
7031
  (vnode = parent.vnode).el = el;
@@ -7001,6 +7034,9 @@ function updateHOCHostEl({ vnode, parent }, el) {
7001
7034
  break;
7002
7035
  }
7003
7036
  }
7037
+ if (suspense && suspense.activeBranch === vnode) {
7038
+ suspense.vnode.el = el;
7039
+ }
7004
7040
  }
7005
7041
 
7006
7042
  const internalObjectProto = {};
@@ -7842,10 +7878,17 @@ function baseCreateRenderer(options, createHydrationFns) {
7842
7878
  }
7843
7879
  hostInsert(el, container, anchor);
7844
7880
  if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
7881
+ const isHmr = isHmrUpdating;
7845
7882
  queuePostRenderEffect(() => {
7846
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7847
- needCallTransitionHooks && transition.enter(el);
7848
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7883
+ let prev;
7884
+ prev = setHmrUpdating(isHmr);
7885
+ try {
7886
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7887
+ needCallTransitionHooks && transition.enter(el);
7888
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7889
+ } finally {
7890
+ setHmrUpdating(prev);
7891
+ }
7849
7892
  }, parentSuspense);
7850
7893
  }
7851
7894
  };
@@ -8250,7 +8293,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8250
8293
  }
8251
8294
  } else {
8252
8295
  if (root.ce && root.ce._hasShadowRoot()) {
8253
- root.ce._injectChildStyle(type);
8296
+ root.ce._injectChildStyle(
8297
+ type,
8298
+ instance.parent ? instance.parent.type : void 0
8299
+ );
8254
8300
  }
8255
8301
  {
8256
8302
  startMeasure(instance, `render`);
@@ -8763,7 +8809,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8763
8809
  shapeFlag,
8764
8810
  patchFlag,
8765
8811
  dirs,
8766
- cacheIndex
8812
+ cacheIndex,
8813
+ memo
8767
8814
  } = vnode;
8768
8815
  if (patchFlag === -2) {
8769
8816
  optimized = false;
@@ -8825,10 +8872,14 @@ function baseCreateRenderer(options, createHydrationFns) {
8825
8872
  remove(vnode);
8826
8873
  }
8827
8874
  }
8828
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
8875
+ const shouldInvalidateMemo = memo != null && cacheIndex == null;
8876
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) {
8829
8877
  queuePostRenderEffect(() => {
8830
8878
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
8831
8879
  shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
8880
+ if (shouldInvalidateMemo) {
8881
+ vnode.el = null;
8882
+ }
8832
8883
  }, parentSuspense);
8833
8884
  }
8834
8885
  };
@@ -9382,6 +9433,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9382
9433
  pendingId: suspenseId++,
9383
9434
  timeout: typeof timeout === "number" ? timeout : -1,
9384
9435
  activeBranch: null,
9436
+ isFallbackMountPending: false,
9385
9437
  pendingBranch: null,
9386
9438
  isInFallback: !isHydrating,
9387
9439
  isHydrating,
@@ -9431,7 +9483,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9431
9483
  }
9432
9484
  };
9433
9485
  }
9434
- if (activeBranch) {
9486
+ if (activeBranch && !suspense.isFallbackMountPending) {
9435
9487
  if (parentNode(activeBranch.el) === container2) {
9436
9488
  anchor = next(activeBranch);
9437
9489
  }
@@ -9444,6 +9496,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9444
9496
  move(pendingBranch, container2, anchor, 0);
9445
9497
  }
9446
9498
  }
9499
+ suspense.isFallbackMountPending = false;
9447
9500
  setActiveBranch(suspense, pendingBranch);
9448
9501
  suspense.pendingBranch = null;
9449
9502
  suspense.isInFallback = false;
@@ -9479,6 +9532,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9479
9532
  triggerEvent(vnode2, "onFallback");
9480
9533
  const anchor2 = next(activeBranch);
9481
9534
  const mountFallback = () => {
9535
+ suspense.isFallbackMountPending = false;
9482
9536
  if (!suspense.isInFallback) {
9483
9537
  return;
9484
9538
  }
@@ -9498,6 +9552,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9498
9552
  };
9499
9553
  const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
9500
9554
  if (delayEnter) {
9555
+ suspense.isFallbackMountPending = true;
9501
9556
  activeBranch.transition.afterLeave = mountFallback;
9502
9557
  }
9503
9558
  suspense.isInFallback = true;
@@ -10048,6 +10103,10 @@ function mergeProps(...args) {
10048
10103
  const incoming = toMerge[key];
10049
10104
  if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
10050
10105
  ret[key] = existing ? [].concat(existing, incoming) : incoming;
10106
+ } else if (incoming == null && existing == null && // mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
10107
+ // the model listener.
10108
+ !isModelListener(key)) {
10109
+ ret[key] = incoming;
10051
10110
  }
10052
10111
  } else if (key !== "") {
10053
10112
  ret[key] = toMerge[key];
@@ -10732,7 +10791,7 @@ function isMemoSame(cached, memo) {
10732
10791
  return true;
10733
10792
  }
10734
10793
 
10735
- const version = "3.5.29";
10794
+ const version = "3.5.31";
10736
10795
  const warn = warn$1 ;
10737
10796
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10738
10797
  const devtools = devtools$1 ;
@@ -11529,7 +11588,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
11529
11588
  }
11530
11589
  } else if (
11531
11590
  // #11081 force set props for possible async custom element
11532
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11591
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11592
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11593
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11533
11594
  ) {
11534
11595
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11535
11596
  } else {
@@ -11577,6 +11638,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
11577
11638
  }
11578
11639
  return key in el;
11579
11640
  }
11641
+ function shouldSetAsPropForVueCE(el, key) {
11642
+ const props = (
11643
+ // @ts-expect-error _def is private
11644
+ el._def.props
11645
+ );
11646
+ if (!props) {
11647
+ return false;
11648
+ }
11649
+ const camelKey = camelize(key);
11650
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11651
+ }
11580
11652
 
11581
11653
  const REMOVAL = {};
11582
11654
  // @__NO_SIDE_EFFECTS__
@@ -11621,6 +11693,7 @@ class VueElement extends BaseClass {
11621
11693
  this._dirty = false;
11622
11694
  this._numberProps = null;
11623
11695
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11696
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11624
11697
  this._ob = null;
11625
11698
  if (this.shadowRoot && _createApp !== createApp) {
11626
11699
  this._root = this.shadowRoot;
@@ -11649,7 +11722,8 @@ class VueElement extends BaseClass {
11649
11722
  }
11650
11723
  this._connected = true;
11651
11724
  let parent = this;
11652
- while (parent = parent && (parent.parentNode || parent.host)) {
11725
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11726
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11653
11727
  if (parent instanceof VueElement) {
11654
11728
  this._parent = parent;
11655
11729
  break;
@@ -11871,6 +11945,7 @@ class VueElement extends BaseClass {
11871
11945
  this._styles.forEach((s) => this._root.removeChild(s));
11872
11946
  this._styles.length = 0;
11873
11947
  }
11948
+ this._styleAnchors.delete(this._def);
11874
11949
  this._applyStyles(newStyles);
11875
11950
  this._instance = null;
11876
11951
  this._update();
@@ -11895,7 +11970,7 @@ class VueElement extends BaseClass {
11895
11970
  }
11896
11971
  return vnode;
11897
11972
  }
11898
- _applyStyles(styles, owner) {
11973
+ _applyStyles(styles, owner, parentComp) {
11899
11974
  if (!styles) return;
11900
11975
  if (owner) {
11901
11976
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11904,11 +11979,19 @@ class VueElement extends BaseClass {
11904
11979
  this._styleChildren.add(owner);
11905
11980
  }
11906
11981
  const nonce = this._nonce;
11982
+ const root = this.shadowRoot;
11983
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11984
+ let last = null;
11907
11985
  for (let i = styles.length - 1; i >= 0; i--) {
11908
11986
  const s = document.createElement("style");
11909
11987
  if (nonce) s.setAttribute("nonce", nonce);
11910
11988
  s.textContent = styles[i];
11911
- this.shadowRoot.prepend(s);
11989
+ root.insertBefore(s, last || insertionAnchor);
11990
+ last = s;
11991
+ if (i === 0) {
11992
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11993
+ if (owner) this._styleAnchors.set(owner, s);
11994
+ }
11912
11995
  {
11913
11996
  if (owner) {
11914
11997
  if (owner.__hmrId) {
@@ -11925,6 +12008,28 @@ class VueElement extends BaseClass {
11925
12008
  }
11926
12009
  }
11927
12010
  }
12011
+ _getStyleAnchor(comp) {
12012
+ if (!comp) {
12013
+ return null;
12014
+ }
12015
+ const anchor = this._styleAnchors.get(comp);
12016
+ if (anchor && anchor.parentNode === this.shadowRoot) {
12017
+ return anchor;
12018
+ }
12019
+ if (anchor) {
12020
+ this._styleAnchors.delete(comp);
12021
+ }
12022
+ return null;
12023
+ }
12024
+ _getRootStyleInsertionAnchor(root) {
12025
+ for (let i = 0; i < root.childNodes.length; i++) {
12026
+ const node = root.childNodes[i];
12027
+ if (!(node instanceof HTMLStyleElement)) {
12028
+ return node;
12029
+ }
12030
+ }
12031
+ return null;
12032
+ }
11928
12033
  /**
11929
12034
  * Only called when shadowRoot is false
11930
12035
  */
@@ -11987,8 +12092,8 @@ class VueElement extends BaseClass {
11987
12092
  /**
11988
12093
  * @internal
11989
12094
  */
11990
- _injectChildStyle(comp) {
11991
- this._applyStyles(comp.styles, comp);
12095
+ _injectChildStyle(comp, parentComp) {
12096
+ this._applyStyles(comp.styles, comp, parentComp);
11992
12097
  }
11993
12098
  /**
11994
12099
  * @internal
@@ -12018,6 +12123,7 @@ class VueElement extends BaseClass {
12018
12123
  _removeChildStyle(comp) {
12019
12124
  {
12020
12125
  this._styleChildren.delete(comp);
12126
+ this._styleAnchors.delete(comp);
12021
12127
  if (this._childStyles && comp.__hmrId) {
12022
12128
  const oldStyles = this._childStyles.get(comp.__hmrId);
12023
12129
  if (oldStyles) {
@@ -12276,7 +12382,8 @@ const vModelText = {
12276
12382
  if (elValue === newValue) {
12277
12383
  return;
12278
12384
  }
12279
- if (document.activeElement === el && el.type !== "range") {
12385
+ const rootNode = el.getRootNode();
12386
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
12280
12387
  if (lazy && value === oldValue) {
12281
12388
  return;
12282
12389
  }