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
  **/
@@ -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
  **/
@@ -1281,10 +1281,17 @@ var Vue = (function (exports) {
1281
1281
  }
1282
1282
  function reduce(self, method, fn, args) {
1283
1283
  const arr = shallowReadArray(self);
1284
+ const needsWrap = arr !== self && !isShallow(self);
1284
1285
  let wrappedFn = fn;
1286
+ let wrapInitialAccumulator = false;
1285
1287
  if (arr !== self) {
1286
- if (!isShallow(self)) {
1288
+ if (needsWrap) {
1289
+ wrapInitialAccumulator = args.length === 0;
1287
1290
  wrappedFn = function(acc, item, index) {
1291
+ if (wrapInitialAccumulator) {
1292
+ wrapInitialAccumulator = false;
1293
+ acc = toWrapped(self, acc);
1294
+ }
1288
1295
  return fn.call(this, acc, toWrapped(self, item), index, self);
1289
1296
  };
1290
1297
  } else if (fn.length > 3) {
@@ -1293,7 +1300,8 @@ var Vue = (function (exports) {
1293
1300
  };
1294
1301
  }
1295
1302
  }
1296
- return arr[method](wrappedFn, ...args);
1303
+ const result = arr[method](wrappedFn, ...args);
1304
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1297
1305
  }
1298
1306
  function searchProxy(self, method, args) {
1299
1307
  const arr = toRaw(self);
@@ -1583,15 +1591,14 @@ var Vue = (function (exports) {
1583
1591
  clear: createReadonlyMethod("clear")
1584
1592
  } : {
1585
1593
  add(value) {
1586
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1587
- value = toRaw(value);
1588
- }
1589
1594
  const target = toRaw(this);
1590
1595
  const proto = getProto(target);
1591
- const hadKey = proto.has.call(target, value);
1596
+ const rawValue = toRaw(value);
1597
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1598
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1592
1599
  if (!hadKey) {
1593
- target.add(value);
1594
- trigger(target, "add", value, value);
1600
+ target.add(valueToAdd);
1601
+ trigger(target, "add", valueToAdd, valueToAdd);
1595
1602
  }
1596
1603
  return this;
1597
1604
  },
@@ -3809,6 +3816,7 @@ var Vue = (function (exports) {
3809
3816
  callHook(hook, [el]);
3810
3817
  },
3811
3818
  enter(el) {
3819
+ if (leavingVNodesCache[key] === vnode) return;
3812
3820
  let hook = onEnter;
3813
3821
  let afterHook = onAfterEnter;
3814
3822
  let cancelHook = onEnterCancelled;
@@ -5439,12 +5447,16 @@ If this is a native custom element, make sure to exclude it from component resol
5439
5447
  );
5440
5448
  }
5441
5449
  } else if (typeof source === "number") {
5442
- if (!Number.isInteger(source)) {
5443
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5444
- }
5445
- ret = new Array(source);
5446
- for (let i = 0; i < source; i++) {
5447
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5450
+ if (!Number.isInteger(source) || source < 0) {
5451
+ warn$1(
5452
+ `The v-for range expects a positive integer value but got ${source}.`
5453
+ );
5454
+ ret = [];
5455
+ } else {
5456
+ ret = new Array(source);
5457
+ for (let i = 0; i < source; i++) {
5458
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5459
+ }
5448
5460
  }
5449
5461
  } else if (isObject(source)) {
5450
5462
  if (source[Symbol.iterator]) {
@@ -5895,6 +5907,7 @@ If this is a native custom element, make sure to exclude it from component resol
5895
5907
  }
5896
5908
  function withAsyncContext(getAwaitable) {
5897
5909
  const ctx = getCurrentInstance();
5910
+ const inSSRSetup = isInSSRComponentSetup;
5898
5911
  if (!ctx) {
5899
5912
  warn$1(
5900
5913
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5902,13 +5915,36 @@ If this is a native custom element, make sure to exclude it from component resol
5902
5915
  }
5903
5916
  let awaitable = getAwaitable();
5904
5917
  unsetCurrentInstance();
5918
+ if (inSSRSetup) {
5919
+ setInSSRSetupState(false);
5920
+ }
5921
+ const restore = () => {
5922
+ setCurrentInstance(ctx);
5923
+ if (inSSRSetup) {
5924
+ setInSSRSetupState(true);
5925
+ }
5926
+ };
5927
+ const cleanup = () => {
5928
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
5929
+ unsetCurrentInstance();
5930
+ if (inSSRSetup) {
5931
+ setInSSRSetupState(false);
5932
+ }
5933
+ };
5905
5934
  if (isPromise(awaitable)) {
5906
5935
  awaitable = awaitable.catch((e) => {
5907
- setCurrentInstance(ctx);
5936
+ restore();
5937
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
5908
5938
  throw e;
5909
5939
  });
5910
5940
  }
5911
- return [awaitable, () => setCurrentInstance(ctx)];
5941
+ return [
5942
+ awaitable,
5943
+ () => {
5944
+ restore();
5945
+ Promise.resolve().then(cleanup);
5946
+ }
5947
+ ];
5912
5948
  }
5913
5949
 
5914
5950
  function createDuplicateChecker() {
@@ -8277,7 +8313,10 @@ If you want to remount the same app, move your app creation logic into a factory
8277
8313
  }
8278
8314
  } else {
8279
8315
  if (root.ce && root.ce._hasShadowRoot()) {
8280
- root.ce._injectChildStyle(type);
8316
+ root.ce._injectChildStyle(
8317
+ type,
8318
+ instance.parent ? instance.parent.type : void 0
8319
+ );
8281
8320
  }
8282
8321
  {
8283
8322
  startMeasure(instance, `render`);
@@ -10745,7 +10784,7 @@ Component that was made reactive: `,
10745
10784
  return true;
10746
10785
  }
10747
10786
 
10748
- const version = "3.5.28";
10787
+ const version = "3.5.30";
10749
10788
  const warn = warn$1 ;
10750
10789
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10751
10790
  const devtools = devtools$1 ;
@@ -11523,7 +11562,9 @@ Expected function or array of functions, received type ${typeof value}.`
11523
11562
  }
11524
11563
  } else if (
11525
11564
  // #11081 force set props for possible async custom element
11526
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11565
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11566
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11567
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11527
11568
  ) {
11528
11569
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11529
11570
  } else {
@@ -11571,6 +11612,17 @@ Expected function or array of functions, received type ${typeof value}.`
11571
11612
  }
11572
11613
  return key in el;
11573
11614
  }
11615
+ function shouldSetAsPropForVueCE(el, key) {
11616
+ const props = (
11617
+ // @ts-expect-error _def is private
11618
+ el._def.props
11619
+ );
11620
+ if (!props) {
11621
+ return false;
11622
+ }
11623
+ const camelKey = camelize(key);
11624
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11625
+ }
11574
11626
 
11575
11627
  const REMOVAL = {};
11576
11628
  // @__NO_SIDE_EFFECTS__
@@ -11615,6 +11667,7 @@ Expected function or array of functions, received type ${typeof value}.`
11615
11667
  this._dirty = false;
11616
11668
  this._numberProps = null;
11617
11669
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11670
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11618
11671
  this._ob = null;
11619
11672
  if (this.shadowRoot && _createApp !== createApp) {
11620
11673
  this._root = this.shadowRoot;
@@ -11643,7 +11696,8 @@ Expected function or array of functions, received type ${typeof value}.`
11643
11696
  }
11644
11697
  this._connected = true;
11645
11698
  let parent = this;
11646
- while (parent = parent && (parent.parentNode || parent.host)) {
11699
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11700
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11647
11701
  if (parent instanceof VueElement) {
11648
11702
  this._parent = parent;
11649
11703
  break;
@@ -11865,6 +11919,7 @@ Expected function or array of functions, received type ${typeof value}.`
11865
11919
  this._styles.forEach((s) => this._root.removeChild(s));
11866
11920
  this._styles.length = 0;
11867
11921
  }
11922
+ this._styleAnchors.delete(this._def);
11868
11923
  this._applyStyles(newStyles);
11869
11924
  this._instance = null;
11870
11925
  this._update();
@@ -11889,7 +11944,7 @@ Expected function or array of functions, received type ${typeof value}.`
11889
11944
  }
11890
11945
  return vnode;
11891
11946
  }
11892
- _applyStyles(styles, owner) {
11947
+ _applyStyles(styles, owner, parentComp) {
11893
11948
  if (!styles) return;
11894
11949
  if (owner) {
11895
11950
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11898,11 +11953,19 @@ Expected function or array of functions, received type ${typeof value}.`
11898
11953
  this._styleChildren.add(owner);
11899
11954
  }
11900
11955
  const nonce = this._nonce;
11956
+ const root = this.shadowRoot;
11957
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11958
+ let last = null;
11901
11959
  for (let i = styles.length - 1; i >= 0; i--) {
11902
11960
  const s = document.createElement("style");
11903
11961
  if (nonce) s.setAttribute("nonce", nonce);
11904
11962
  s.textContent = styles[i];
11905
- this.shadowRoot.prepend(s);
11963
+ root.insertBefore(s, last || insertionAnchor);
11964
+ last = s;
11965
+ if (i === 0) {
11966
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11967
+ if (owner) this._styleAnchors.set(owner, s);
11968
+ }
11906
11969
  {
11907
11970
  if (owner) {
11908
11971
  if (owner.__hmrId) {
@@ -11919,6 +11982,28 @@ Expected function or array of functions, received type ${typeof value}.`
11919
11982
  }
11920
11983
  }
11921
11984
  }
11985
+ _getStyleAnchor(comp) {
11986
+ if (!comp) {
11987
+ return null;
11988
+ }
11989
+ const anchor = this._styleAnchors.get(comp);
11990
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11991
+ return anchor;
11992
+ }
11993
+ if (anchor) {
11994
+ this._styleAnchors.delete(comp);
11995
+ }
11996
+ return null;
11997
+ }
11998
+ _getRootStyleInsertionAnchor(root) {
11999
+ for (let i = 0; i < root.childNodes.length; i++) {
12000
+ const node = root.childNodes[i];
12001
+ if (!(node instanceof HTMLStyleElement)) {
12002
+ return node;
12003
+ }
12004
+ }
12005
+ return null;
12006
+ }
11922
12007
  /**
11923
12008
  * Only called when shadowRoot is false
11924
12009
  */
@@ -11981,8 +12066,8 @@ Expected function or array of functions, received type ${typeof value}.`
11981
12066
  /**
11982
12067
  * @internal
11983
12068
  */
11984
- _injectChildStyle(comp) {
11985
- this._applyStyles(comp.styles, comp);
12069
+ _injectChildStyle(comp, parentComp) {
12070
+ this._applyStyles(comp.styles, comp, parentComp);
11986
12071
  }
11987
12072
  /**
11988
12073
  * @internal
@@ -12012,6 +12097,7 @@ Expected function or array of functions, received type ${typeof value}.`
12012
12097
  _removeChildStyle(comp) {
12013
12098
  {
12014
12099
  this._styleChildren.delete(comp);
12100
+ this._styleAnchors.delete(comp);
12015
12101
  if (this._childStyles && comp.__hmrId) {
12016
12102
  const oldStyles = this._childStyles.get(comp.__hmrId);
12017
12103
  if (oldStyles) {