vue 3.5.28 → 3.5.30

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 v3.5.28
2
+ * vue v3.5.30
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1208,10 +1208,17 @@ var Vue = (function (exports) {
1208
1208
  }
1209
1209
  function reduce(self, method, fn, args) {
1210
1210
  const arr = shallowReadArray(self);
1211
+ const needsWrap = arr !== self && !isShallow(self);
1211
1212
  let wrappedFn = fn;
1213
+ let wrapInitialAccumulator = false;
1212
1214
  if (arr !== self) {
1213
- if (!isShallow(self)) {
1215
+ if (needsWrap) {
1216
+ wrapInitialAccumulator = args.length === 0;
1214
1217
  wrappedFn = function(acc, item, index) {
1218
+ if (wrapInitialAccumulator) {
1219
+ wrapInitialAccumulator = false;
1220
+ acc = toWrapped(self, acc);
1221
+ }
1215
1222
  return fn.call(this, acc, toWrapped(self, item), index, self);
1216
1223
  };
1217
1224
  } else if (fn.length > 3) {
@@ -1220,7 +1227,8 @@ var Vue = (function (exports) {
1220
1227
  };
1221
1228
  }
1222
1229
  }
1223
- return arr[method](wrappedFn, ...args);
1230
+ const result = arr[method](wrappedFn, ...args);
1231
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1224
1232
  }
1225
1233
  function searchProxy(self, method, args) {
1226
1234
  const arr = toRaw(self);
@@ -1510,15 +1518,14 @@ var Vue = (function (exports) {
1510
1518
  clear: createReadonlyMethod("clear")
1511
1519
  } : {
1512
1520
  add(value) {
1513
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1514
- value = toRaw(value);
1515
- }
1516
1521
  const target = toRaw(this);
1517
1522
  const proto = getProto(target);
1518
- const hadKey = proto.has.call(target, value);
1523
+ const rawValue = toRaw(value);
1524
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1525
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1519
1526
  if (!hadKey) {
1520
- target.add(value);
1521
- trigger(target, "add", value, value);
1527
+ target.add(valueToAdd);
1528
+ trigger(target, "add", valueToAdd, valueToAdd);
1522
1529
  }
1523
1530
  return this;
1524
1531
  },
@@ -3736,6 +3743,7 @@ var Vue = (function (exports) {
3736
3743
  callHook(hook, [el]);
3737
3744
  },
3738
3745
  enter(el) {
3746
+ if (leavingVNodesCache[key] === vnode) return;
3739
3747
  let hook = onEnter;
3740
3748
  let afterHook = onAfterEnter;
3741
3749
  let cancelHook = onEnterCancelled;
@@ -5366,12 +5374,16 @@ If this is a native custom element, make sure to exclude it from component resol
5366
5374
  );
5367
5375
  }
5368
5376
  } else if (typeof source === "number") {
5369
- if (!Number.isInteger(source)) {
5370
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5371
- }
5372
- ret = new Array(source);
5373
- for (let i = 0; i < source; i++) {
5374
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5377
+ if (!Number.isInteger(source) || source < 0) {
5378
+ warn$1(
5379
+ `The v-for range expects a positive integer value but got ${source}.`
5380
+ );
5381
+ ret = [];
5382
+ } else {
5383
+ ret = new Array(source);
5384
+ for (let i = 0; i < source; i++) {
5385
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5386
+ }
5375
5387
  }
5376
5388
  } else if (isObject(source)) {
5377
5389
  if (source[Symbol.iterator]) {
@@ -5822,6 +5834,7 @@ If this is a native custom element, make sure to exclude it from component resol
5822
5834
  }
5823
5835
  function withAsyncContext(getAwaitable) {
5824
5836
  const ctx = getCurrentInstance();
5837
+ const inSSRSetup = isInSSRComponentSetup;
5825
5838
  if (!ctx) {
5826
5839
  warn$1(
5827
5840
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5829,13 +5842,36 @@ If this is a native custom element, make sure to exclude it from component resol
5829
5842
  }
5830
5843
  let awaitable = getAwaitable();
5831
5844
  unsetCurrentInstance();
5845
+ if (inSSRSetup) {
5846
+ setInSSRSetupState(false);
5847
+ }
5848
+ const restore = () => {
5849
+ setCurrentInstance(ctx);
5850
+ if (inSSRSetup) {
5851
+ setInSSRSetupState(true);
5852
+ }
5853
+ };
5854
+ const cleanup = () => {
5855
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
5856
+ unsetCurrentInstance();
5857
+ if (inSSRSetup) {
5858
+ setInSSRSetupState(false);
5859
+ }
5860
+ };
5832
5861
  if (isPromise(awaitable)) {
5833
5862
  awaitable = awaitable.catch((e) => {
5834
- setCurrentInstance(ctx);
5863
+ restore();
5864
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
5835
5865
  throw e;
5836
5866
  });
5837
5867
  }
5838
- return [awaitable, () => setCurrentInstance(ctx)];
5868
+ return [
5869
+ awaitable,
5870
+ () => {
5871
+ restore();
5872
+ Promise.resolve().then(cleanup);
5873
+ }
5874
+ ];
5839
5875
  }
5840
5876
 
5841
5877
  function createDuplicateChecker() {
@@ -8204,7 +8240,10 @@ If you want to remount the same app, move your app creation logic into a factory
8204
8240
  }
8205
8241
  } else {
8206
8242
  if (root.ce && root.ce._hasShadowRoot()) {
8207
- root.ce._injectChildStyle(type);
8243
+ root.ce._injectChildStyle(
8244
+ type,
8245
+ instance.parent ? instance.parent.type : void 0
8246
+ );
8208
8247
  }
8209
8248
  {
8210
8249
  startMeasure(instance, `render`);
@@ -10672,7 +10711,7 @@ Component that was made reactive: `,
10672
10711
  return true;
10673
10712
  }
10674
10713
 
10675
- const version = "3.5.28";
10714
+ const version = "3.5.30";
10676
10715
  const warn = warn$1 ;
10677
10716
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10678
10717
  const devtools = devtools$1 ;
@@ -11450,7 +11489,9 @@ Expected function or array of functions, received type ${typeof value}.`
11450
11489
  }
11451
11490
  } else if (
11452
11491
  // #11081 force set props for possible async custom element
11453
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11492
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11493
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11494
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11454
11495
  ) {
11455
11496
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11456
11497
  } else {
@@ -11498,6 +11539,17 @@ Expected function or array of functions, received type ${typeof value}.`
11498
11539
  }
11499
11540
  return key in el;
11500
11541
  }
11542
+ function shouldSetAsPropForVueCE(el, key) {
11543
+ const props = (
11544
+ // @ts-expect-error _def is private
11545
+ el._def.props
11546
+ );
11547
+ if (!props) {
11548
+ return false;
11549
+ }
11550
+ const camelKey = camelize(key);
11551
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11552
+ }
11501
11553
 
11502
11554
  const REMOVAL = {};
11503
11555
  // @__NO_SIDE_EFFECTS__
@@ -11542,6 +11594,7 @@ Expected function or array of functions, received type ${typeof value}.`
11542
11594
  this._dirty = false;
11543
11595
  this._numberProps = null;
11544
11596
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11597
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11545
11598
  this._ob = null;
11546
11599
  if (this.shadowRoot && _createApp !== createApp) {
11547
11600
  this._root = this.shadowRoot;
@@ -11570,7 +11623,8 @@ Expected function or array of functions, received type ${typeof value}.`
11570
11623
  }
11571
11624
  this._connected = true;
11572
11625
  let parent = this;
11573
- while (parent = parent && (parent.parentNode || parent.host)) {
11626
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11627
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11574
11628
  if (parent instanceof VueElement) {
11575
11629
  this._parent = parent;
11576
11630
  break;
@@ -11792,6 +11846,7 @@ Expected function or array of functions, received type ${typeof value}.`
11792
11846
  this._styles.forEach((s) => this._root.removeChild(s));
11793
11847
  this._styles.length = 0;
11794
11848
  }
11849
+ this._styleAnchors.delete(this._def);
11795
11850
  this._applyStyles(newStyles);
11796
11851
  this._instance = null;
11797
11852
  this._update();
@@ -11816,7 +11871,7 @@ Expected function or array of functions, received type ${typeof value}.`
11816
11871
  }
11817
11872
  return vnode;
11818
11873
  }
11819
- _applyStyles(styles, owner) {
11874
+ _applyStyles(styles, owner, parentComp) {
11820
11875
  if (!styles) return;
11821
11876
  if (owner) {
11822
11877
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11825,11 +11880,19 @@ Expected function or array of functions, received type ${typeof value}.`
11825
11880
  this._styleChildren.add(owner);
11826
11881
  }
11827
11882
  const nonce = this._nonce;
11883
+ const root = this.shadowRoot;
11884
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11885
+ let last = null;
11828
11886
  for (let i = styles.length - 1; i >= 0; i--) {
11829
11887
  const s = document.createElement("style");
11830
11888
  if (nonce) s.setAttribute("nonce", nonce);
11831
11889
  s.textContent = styles[i];
11832
- this.shadowRoot.prepend(s);
11890
+ root.insertBefore(s, last || insertionAnchor);
11891
+ last = s;
11892
+ if (i === 0) {
11893
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11894
+ if (owner) this._styleAnchors.set(owner, s);
11895
+ }
11833
11896
  {
11834
11897
  if (owner) {
11835
11898
  if (owner.__hmrId) {
@@ -11846,6 +11909,28 @@ Expected function or array of functions, received type ${typeof value}.`
11846
11909
  }
11847
11910
  }
11848
11911
  }
11912
+ _getStyleAnchor(comp) {
11913
+ if (!comp) {
11914
+ return null;
11915
+ }
11916
+ const anchor = this._styleAnchors.get(comp);
11917
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11918
+ return anchor;
11919
+ }
11920
+ if (anchor) {
11921
+ this._styleAnchors.delete(comp);
11922
+ }
11923
+ return null;
11924
+ }
11925
+ _getRootStyleInsertionAnchor(root) {
11926
+ for (let i = 0; i < root.childNodes.length; i++) {
11927
+ const node = root.childNodes[i];
11928
+ if (!(node instanceof HTMLStyleElement)) {
11929
+ return node;
11930
+ }
11931
+ }
11932
+ return null;
11933
+ }
11849
11934
  /**
11850
11935
  * Only called when shadowRoot is false
11851
11936
  */
@@ -11908,8 +11993,8 @@ Expected function or array of functions, received type ${typeof value}.`
11908
11993
  /**
11909
11994
  * @internal
11910
11995
  */
11911
- _injectChildStyle(comp) {
11912
- this._applyStyles(comp.styles, comp);
11996
+ _injectChildStyle(comp, parentComp) {
11997
+ this._applyStyles(comp.styles, comp, parentComp);
11913
11998
  }
11914
11999
  /**
11915
12000
  * @internal
@@ -11939,6 +12024,7 @@ Expected function or array of functions, received type ${typeof value}.`
11939
12024
  _removeChildStyle(comp) {
11940
12025
  {
11941
12026
  this._styleChildren.delete(comp);
12027
+ this._styleAnchors.delete(comp);
11942
12028
  if (this._childStyles && comp.__hmrId) {
11943
12029
  const oldStyles = this._childStyles.get(comp.__hmrId);
11944
12030
  if (oldStyles) {