@vue/compat 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.29
2
+ * @vue/compat v3.5.30
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
  },
@@ -6161,12 +6168,16 @@ function renderList(source, renderItem, cache, index) {
6161
6168
  );
6162
6169
  }
6163
6170
  } else if (typeof source === "number") {
6164
- if (!Number.isInteger(source)) {
6165
- warn$1(`The v-for range expect an integer value but got ${source}.`);
6166
- }
6167
- ret = new Array(source);
6168
- for (let i = 0; i < source; i++) {
6169
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
6171
+ if (!Number.isInteger(source) || source < 0) {
6172
+ warn$1(
6173
+ `The v-for range expects a positive integer value but got ${source}.`
6174
+ );
6175
+ ret = [];
6176
+ } else {
6177
+ ret = new Array(source);
6178
+ for (let i = 0; i < source; i++) {
6179
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
6180
+ }
6170
6181
  }
6171
6182
  } else if (isObject(source)) {
6172
6183
  if (source[Symbol.iterator]) {
@@ -6869,6 +6880,7 @@ function createPropsRestProxy(props, excludedKeys) {
6869
6880
  }
6870
6881
  function withAsyncContext(getAwaitable) {
6871
6882
  const ctx = getCurrentInstance();
6883
+ const inSSRSetup = isInSSRComponentSetup;
6872
6884
  if (!ctx) {
6873
6885
  warn$1(
6874
6886
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -6876,13 +6888,25 @@ function withAsyncContext(getAwaitable) {
6876
6888
  }
6877
6889
  let awaitable = getAwaitable();
6878
6890
  unsetCurrentInstance();
6891
+ if (inSSRSetup) {
6892
+ setInSSRSetupState(false);
6893
+ }
6894
+ const restore = () => {
6895
+ setCurrentInstance(ctx);
6896
+ if (inSSRSetup) {
6897
+ setInSSRSetupState(true);
6898
+ }
6899
+ };
6879
6900
  const cleanup = () => {
6880
6901
  if (getCurrentInstance() !== ctx) ctx.scope.off();
6881
6902
  unsetCurrentInstance();
6903
+ if (inSSRSetup) {
6904
+ setInSSRSetupState(false);
6905
+ }
6882
6906
  };
6883
6907
  if (isPromise(awaitable)) {
6884
6908
  awaitable = awaitable.catch((e) => {
6885
- setCurrentInstance(ctx);
6909
+ restore();
6886
6910
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
6887
6911
  throw e;
6888
6912
  });
@@ -6890,7 +6914,7 @@ function withAsyncContext(getAwaitable) {
6890
6914
  return [
6891
6915
  awaitable,
6892
6916
  () => {
6893
- setCurrentInstance(ctx);
6917
+ restore();
6894
6918
  Promise.resolve().then(cleanup);
6895
6919
  }
6896
6920
  ];
@@ -7414,7 +7438,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7414
7438
  return vm;
7415
7439
  }
7416
7440
  }
7417
- Vue.version = `2.6.14-compat:${"3.5.29"}`;
7441
+ Vue.version = `2.6.14-compat:${"3.5.30"}`;
7418
7442
  Vue.config = singletonApp.config;
7419
7443
  Vue.use = (plugin, ...options) => {
7420
7444
  if (plugin && isFunction(plugin.install)) {
@@ -9911,7 +9935,10 @@ function baseCreateRenderer(options, createHydrationFns) {
9911
9935
  }
9912
9936
  } else {
9913
9937
  if (root.ce && root.ce._hasShadowRoot()) {
9914
- root.ce._injectChildStyle(type);
9938
+ root.ce._injectChildStyle(
9939
+ type,
9940
+ instance.parent ? instance.parent.type : void 0
9941
+ );
9915
9942
  }
9916
9943
  {
9917
9944
  startMeasure(instance, `render`);
@@ -12502,7 +12529,7 @@ function isMemoSame(cached, memo) {
12502
12529
  return true;
12503
12530
  }
12504
12531
 
12505
- const version = "3.5.29";
12532
+ const version = "3.5.30";
12506
12533
  const warn = warn$1 ;
12507
12534
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12508
12535
  const devtools = devtools$1 ;
@@ -13387,7 +13414,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
13387
13414
  }
13388
13415
  } else if (
13389
13416
  // #11081 force set props for possible async custom element
13390
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
13417
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
13418
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
13419
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
13391
13420
  ) {
13392
13421
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
13393
13422
  } else {
@@ -13435,6 +13464,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
13435
13464
  }
13436
13465
  return key in el;
13437
13466
  }
13467
+ function shouldSetAsPropForVueCE(el, key) {
13468
+ const props = (
13469
+ // @ts-expect-error _def is private
13470
+ el._def.props
13471
+ );
13472
+ if (!props) {
13473
+ return false;
13474
+ }
13475
+ const camelKey = camelize(key);
13476
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
13477
+ }
13438
13478
 
13439
13479
  const REMOVAL = {};
13440
13480
  // @__NO_SIDE_EFFECTS__
@@ -13479,6 +13519,7 @@ class VueElement extends BaseClass {
13479
13519
  this._dirty = false;
13480
13520
  this._numberProps = null;
13481
13521
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13522
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
13482
13523
  this._ob = null;
13483
13524
  if (this.shadowRoot && _createApp !== createApp) {
13484
13525
  this._root = this.shadowRoot;
@@ -13507,7 +13548,8 @@ class VueElement extends BaseClass {
13507
13548
  }
13508
13549
  this._connected = true;
13509
13550
  let parent = this;
13510
- while (parent = parent && (parent.parentNode || parent.host)) {
13551
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
13552
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
13511
13553
  if (parent instanceof VueElement) {
13512
13554
  this._parent = parent;
13513
13555
  break;
@@ -13729,6 +13771,7 @@ class VueElement extends BaseClass {
13729
13771
  this._styles.forEach((s) => this._root.removeChild(s));
13730
13772
  this._styles.length = 0;
13731
13773
  }
13774
+ this._styleAnchors.delete(this._def);
13732
13775
  this._applyStyles(newStyles);
13733
13776
  this._instance = null;
13734
13777
  this._update();
@@ -13753,7 +13796,7 @@ class VueElement extends BaseClass {
13753
13796
  }
13754
13797
  return vnode;
13755
13798
  }
13756
- _applyStyles(styles, owner) {
13799
+ _applyStyles(styles, owner, parentComp) {
13757
13800
  if (!styles) return;
13758
13801
  if (owner) {
13759
13802
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -13762,11 +13805,19 @@ class VueElement extends BaseClass {
13762
13805
  this._styleChildren.add(owner);
13763
13806
  }
13764
13807
  const nonce = this._nonce;
13808
+ const root = this.shadowRoot;
13809
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
13810
+ let last = null;
13765
13811
  for (let i = styles.length - 1; i >= 0; i--) {
13766
13812
  const s = document.createElement("style");
13767
13813
  if (nonce) s.setAttribute("nonce", nonce);
13768
13814
  s.textContent = styles[i];
13769
- this.shadowRoot.prepend(s);
13815
+ root.insertBefore(s, last || insertionAnchor);
13816
+ last = s;
13817
+ if (i === 0) {
13818
+ if (!parentComp) this._styleAnchors.set(this._def, s);
13819
+ if (owner) this._styleAnchors.set(owner, s);
13820
+ }
13770
13821
  {
13771
13822
  if (owner) {
13772
13823
  if (owner.__hmrId) {
@@ -13783,6 +13834,28 @@ class VueElement extends BaseClass {
13783
13834
  }
13784
13835
  }
13785
13836
  }
13837
+ _getStyleAnchor(comp) {
13838
+ if (!comp) {
13839
+ return null;
13840
+ }
13841
+ const anchor = this._styleAnchors.get(comp);
13842
+ if (anchor && anchor.parentNode === this.shadowRoot) {
13843
+ return anchor;
13844
+ }
13845
+ if (anchor) {
13846
+ this._styleAnchors.delete(comp);
13847
+ }
13848
+ return null;
13849
+ }
13850
+ _getRootStyleInsertionAnchor(root) {
13851
+ for (let i = 0; i < root.childNodes.length; i++) {
13852
+ const node = root.childNodes[i];
13853
+ if (!(node instanceof HTMLStyleElement)) {
13854
+ return node;
13855
+ }
13856
+ }
13857
+ return null;
13858
+ }
13786
13859
  /**
13787
13860
  * Only called when shadowRoot is false
13788
13861
  */
@@ -13845,8 +13918,8 @@ class VueElement extends BaseClass {
13845
13918
  /**
13846
13919
  * @internal
13847
13920
  */
13848
- _injectChildStyle(comp) {
13849
- this._applyStyles(comp.styles, comp);
13921
+ _injectChildStyle(comp, parentComp) {
13922
+ this._applyStyles(comp.styles, comp, parentComp);
13850
13923
  }
13851
13924
  /**
13852
13925
  * @internal
@@ -13876,6 +13949,7 @@ class VueElement extends BaseClass {
13876
13949
  _removeChildStyle(comp) {
13877
13950
  {
13878
13951
  this._styleChildren.delete(comp);
13952
+ this._styleAnchors.delete(comp);
13879
13953
  if (this._childStyles && comp.__hmrId) {
13880
13954
  const oldStyles = this._childStyles.get(comp.__hmrId);
13881
13955
  if (oldStyles) {