vue 3.5.29 → 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.29
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.29
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.29
2
+ * vue v3.5.30
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1278,10 +1278,17 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1278
1278
  }
1279
1279
  function reduce(self, method, fn, args) {
1280
1280
  const arr = shallowReadArray(self);
1281
+ const needsWrap = arr !== self && !isShallow(self);
1281
1282
  let wrappedFn = fn;
1283
+ let wrapInitialAccumulator = false;
1282
1284
  if (arr !== self) {
1283
- if (!isShallow(self)) {
1285
+ if (needsWrap) {
1286
+ wrapInitialAccumulator = args.length === 0;
1284
1287
  wrappedFn = function(acc, item, index) {
1288
+ if (wrapInitialAccumulator) {
1289
+ wrapInitialAccumulator = false;
1290
+ acc = toWrapped(self, acc);
1291
+ }
1285
1292
  return fn.call(this, acc, toWrapped(self, item), index, self);
1286
1293
  };
1287
1294
  } else if (fn.length > 3) {
@@ -1290,7 +1297,8 @@ function reduce(self, method, fn, args) {
1290
1297
  };
1291
1298
  }
1292
1299
  }
1293
- return arr[method](wrappedFn, ...args);
1300
+ const result = arr[method](wrappedFn, ...args);
1301
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1294
1302
  }
1295
1303
  function searchProxy(self, method, args) {
1296
1304
  const arr = toRaw(self);
@@ -1580,15 +1588,14 @@ function createInstrumentations(readonly, shallow) {
1580
1588
  clear: createReadonlyMethod("clear")
1581
1589
  } : {
1582
1590
  add(value) {
1583
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1584
- value = toRaw(value);
1585
- }
1586
1591
  const target = toRaw(this);
1587
1592
  const proto = getProto(target);
1588
- const hadKey = proto.has.call(target, value);
1593
+ const rawValue = toRaw(value);
1594
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1595
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1589
1596
  if (!hadKey) {
1590
- target.add(value);
1591
- trigger(target, "add", value, value);
1597
+ target.add(valueToAdd);
1598
+ trigger(target, "add", valueToAdd, valueToAdd);
1592
1599
  }
1593
1600
  return this;
1594
1601
  },
@@ -5471,12 +5478,16 @@ function renderList(source, renderItem, cache, index) {
5471
5478
  );
5472
5479
  }
5473
5480
  } else if (typeof source === "number") {
5474
- if (!Number.isInteger(source)) {
5475
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5476
- }
5477
- ret = new Array(source);
5478
- for (let i = 0; i < source; i++) {
5479
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5481
+ if (!Number.isInteger(source) || source < 0) {
5482
+ warn$1(
5483
+ `The v-for range expects a positive integer value but got ${source}.`
5484
+ );
5485
+ ret = [];
5486
+ } else {
5487
+ ret = new Array(source);
5488
+ for (let i = 0; i < source; i++) {
5489
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5490
+ }
5480
5491
  }
5481
5492
  } else if (isObject(source)) {
5482
5493
  if (source[Symbol.iterator]) {
@@ -5927,6 +5938,7 @@ function createPropsRestProxy(props, excludedKeys) {
5927
5938
  }
5928
5939
  function withAsyncContext(getAwaitable) {
5929
5940
  const ctx = getCurrentInstance();
5941
+ const inSSRSetup = isInSSRComponentSetup;
5930
5942
  if (!ctx) {
5931
5943
  warn$1(
5932
5944
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5934,13 +5946,25 @@ function withAsyncContext(getAwaitable) {
5934
5946
  }
5935
5947
  let awaitable = getAwaitable();
5936
5948
  unsetCurrentInstance();
5949
+ if (inSSRSetup) {
5950
+ setInSSRSetupState(false);
5951
+ }
5952
+ const restore = () => {
5953
+ setCurrentInstance(ctx);
5954
+ if (inSSRSetup) {
5955
+ setInSSRSetupState(true);
5956
+ }
5957
+ };
5937
5958
  const cleanup = () => {
5938
5959
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5939
5960
  unsetCurrentInstance();
5961
+ if (inSSRSetup) {
5962
+ setInSSRSetupState(false);
5963
+ }
5940
5964
  };
5941
5965
  if (isPromise(awaitable)) {
5942
5966
  awaitable = awaitable.catch((e) => {
5943
- setCurrentInstance(ctx);
5967
+ restore();
5944
5968
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5945
5969
  throw e;
5946
5970
  });
@@ -5948,7 +5972,7 @@ function withAsyncContext(getAwaitable) {
5948
5972
  return [
5949
5973
  awaitable,
5950
5974
  () => {
5951
- setCurrentInstance(ctx);
5975
+ restore();
5952
5976
  Promise.resolve().then(cleanup);
5953
5977
  }
5954
5978
  ];
@@ -8323,7 +8347,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8323
8347
  }
8324
8348
  } else {
8325
8349
  if (root.ce && root.ce._hasShadowRoot()) {
8326
- root.ce._injectChildStyle(type);
8350
+ root.ce._injectChildStyle(
8351
+ type,
8352
+ instance.parent ? instance.parent.type : void 0
8353
+ );
8327
8354
  }
8328
8355
  {
8329
8356
  startMeasure(instance, `render`);
@@ -10805,7 +10832,7 @@ function isMemoSame(cached, memo) {
10805
10832
  return true;
10806
10833
  }
10807
10834
 
10808
- const version = "3.5.29";
10835
+ const version = "3.5.30";
10809
10836
  const warn = warn$1 ;
10810
10837
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10811
10838
  const devtools = devtools$1 ;
@@ -11602,7 +11629,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
11602
11629
  }
11603
11630
  } else if (
11604
11631
  // #11081 force set props for possible async custom element
11605
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11632
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11633
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11634
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11606
11635
  ) {
11607
11636
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11608
11637
  } else {
@@ -11650,6 +11679,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
11650
11679
  }
11651
11680
  return key in el;
11652
11681
  }
11682
+ function shouldSetAsPropForVueCE(el, key) {
11683
+ const props = (
11684
+ // @ts-expect-error _def is private
11685
+ el._def.props
11686
+ );
11687
+ if (!props) {
11688
+ return false;
11689
+ }
11690
+ const camelKey = camelize(key);
11691
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11692
+ }
11653
11693
 
11654
11694
  const REMOVAL = {};
11655
11695
  // @__NO_SIDE_EFFECTS__
@@ -11694,6 +11734,7 @@ class VueElement extends BaseClass {
11694
11734
  this._dirty = false;
11695
11735
  this._numberProps = null;
11696
11736
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11737
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11697
11738
  this._ob = null;
11698
11739
  if (this.shadowRoot && _createApp !== createApp) {
11699
11740
  this._root = this.shadowRoot;
@@ -11722,7 +11763,8 @@ class VueElement extends BaseClass {
11722
11763
  }
11723
11764
  this._connected = true;
11724
11765
  let parent = this;
11725
- while (parent = parent && (parent.parentNode || parent.host)) {
11766
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11767
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11726
11768
  if (parent instanceof VueElement) {
11727
11769
  this._parent = parent;
11728
11770
  break;
@@ -11944,6 +11986,7 @@ class VueElement extends BaseClass {
11944
11986
  this._styles.forEach((s) => this._root.removeChild(s));
11945
11987
  this._styles.length = 0;
11946
11988
  }
11989
+ this._styleAnchors.delete(this._def);
11947
11990
  this._applyStyles(newStyles);
11948
11991
  this._instance = null;
11949
11992
  this._update();
@@ -11968,7 +12011,7 @@ class VueElement extends BaseClass {
11968
12011
  }
11969
12012
  return vnode;
11970
12013
  }
11971
- _applyStyles(styles, owner) {
12014
+ _applyStyles(styles, owner, parentComp) {
11972
12015
  if (!styles) return;
11973
12016
  if (owner) {
11974
12017
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11977,11 +12020,19 @@ class VueElement extends BaseClass {
11977
12020
  this._styleChildren.add(owner);
11978
12021
  }
11979
12022
  const nonce = this._nonce;
12023
+ const root = this.shadowRoot;
12024
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
12025
+ let last = null;
11980
12026
  for (let i = styles.length - 1; i >= 0; i--) {
11981
12027
  const s = document.createElement("style");
11982
12028
  if (nonce) s.setAttribute("nonce", nonce);
11983
12029
  s.textContent = styles[i];
11984
- this.shadowRoot.prepend(s);
12030
+ root.insertBefore(s, last || insertionAnchor);
12031
+ last = s;
12032
+ if (i === 0) {
12033
+ if (!parentComp) this._styleAnchors.set(this._def, s);
12034
+ if (owner) this._styleAnchors.set(owner, s);
12035
+ }
11985
12036
  {
11986
12037
  if (owner) {
11987
12038
  if (owner.__hmrId) {
@@ -11998,6 +12049,28 @@ class VueElement extends BaseClass {
11998
12049
  }
11999
12050
  }
12000
12051
  }
12052
+ _getStyleAnchor(comp) {
12053
+ if (!comp) {
12054
+ return null;
12055
+ }
12056
+ const anchor = this._styleAnchors.get(comp);
12057
+ if (anchor && anchor.parentNode === this.shadowRoot) {
12058
+ return anchor;
12059
+ }
12060
+ if (anchor) {
12061
+ this._styleAnchors.delete(comp);
12062
+ }
12063
+ return null;
12064
+ }
12065
+ _getRootStyleInsertionAnchor(root) {
12066
+ for (let i = 0; i < root.childNodes.length; i++) {
12067
+ const node = root.childNodes[i];
12068
+ if (!(node instanceof HTMLStyleElement)) {
12069
+ return node;
12070
+ }
12071
+ }
12072
+ return null;
12073
+ }
12001
12074
  /**
12002
12075
  * Only called when shadowRoot is false
12003
12076
  */
@@ -12060,8 +12133,8 @@ class VueElement extends BaseClass {
12060
12133
  /**
12061
12134
  * @internal
12062
12135
  */
12063
- _injectChildStyle(comp) {
12064
- this._applyStyles(comp.styles, comp);
12136
+ _injectChildStyle(comp, parentComp) {
12137
+ this._applyStyles(comp.styles, comp, parentComp);
12065
12138
  }
12066
12139
  /**
12067
12140
  * @internal
@@ -12091,6 +12164,7 @@ class VueElement extends BaseClass {
12091
12164
  _removeChildStyle(comp) {
12092
12165
  {
12093
12166
  this._styleChildren.delete(comp);
12167
+ this._styleAnchors.delete(comp);
12094
12168
  if (this._childStyles && comp.__hmrId) {
12095
12169
  const oldStyles = this._childStyles.get(comp.__hmrId);
12096
12170
  if (oldStyles) {