@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
  **/
@@ -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
  },
@@ -6234,12 +6241,16 @@ function renderList(source, renderItem, cache, index) {
6234
6241
  );
6235
6242
  }
6236
6243
  } else if (typeof source === "number") {
6237
- if (!Number.isInteger(source)) {
6238
- warn$1(`The v-for range expect an integer value but got ${source}.`);
6239
- }
6240
- ret = new Array(source);
6241
- for (let i = 0; i < source; i++) {
6242
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
6244
+ if (!Number.isInteger(source) || source < 0) {
6245
+ warn$1(
6246
+ `The v-for range expects a positive integer value but got ${source}.`
6247
+ );
6248
+ ret = [];
6249
+ } else {
6250
+ ret = new Array(source);
6251
+ for (let i = 0; i < source; i++) {
6252
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
6253
+ }
6243
6254
  }
6244
6255
  } else if (isObject(source)) {
6245
6256
  if (source[Symbol.iterator]) {
@@ -6942,6 +6953,7 @@ function createPropsRestProxy(props, excludedKeys) {
6942
6953
  }
6943
6954
  function withAsyncContext(getAwaitable) {
6944
6955
  const ctx = getCurrentInstance();
6956
+ const inSSRSetup = isInSSRComponentSetup;
6945
6957
  if (!ctx) {
6946
6958
  warn$1(
6947
6959
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -6949,13 +6961,25 @@ function withAsyncContext(getAwaitable) {
6949
6961
  }
6950
6962
  let awaitable = getAwaitable();
6951
6963
  unsetCurrentInstance();
6964
+ if (inSSRSetup) {
6965
+ setInSSRSetupState(false);
6966
+ }
6967
+ const restore = () => {
6968
+ setCurrentInstance(ctx);
6969
+ if (inSSRSetup) {
6970
+ setInSSRSetupState(true);
6971
+ }
6972
+ };
6952
6973
  const cleanup = () => {
6953
6974
  if (getCurrentInstance() !== ctx) ctx.scope.off();
6954
6975
  unsetCurrentInstance();
6976
+ if (inSSRSetup) {
6977
+ setInSSRSetupState(false);
6978
+ }
6955
6979
  };
6956
6980
  if (isPromise(awaitable)) {
6957
6981
  awaitable = awaitable.catch((e) => {
6958
- setCurrentInstance(ctx);
6982
+ restore();
6959
6983
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
6960
6984
  throw e;
6961
6985
  });
@@ -6963,7 +6987,7 @@ function withAsyncContext(getAwaitable) {
6963
6987
  return [
6964
6988
  awaitable,
6965
6989
  () => {
6966
- setCurrentInstance(ctx);
6990
+ restore();
6967
6991
  Promise.resolve().then(cleanup);
6968
6992
  }
6969
6993
  ];
@@ -7487,7 +7511,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7487
7511
  return vm;
7488
7512
  }
7489
7513
  }
7490
- Vue.version = `2.6.14-compat:${"3.5.29"}`;
7514
+ Vue.version = `2.6.14-compat:${"3.5.30"}`;
7491
7515
  Vue.config = singletonApp.config;
7492
7516
  Vue.use = (plugin, ...options) => {
7493
7517
  if (plugin && isFunction(plugin.install)) {
@@ -9984,7 +10008,10 @@ function baseCreateRenderer(options, createHydrationFns) {
9984
10008
  }
9985
10009
  } else {
9986
10010
  if (root.ce && root.ce._hasShadowRoot()) {
9987
- root.ce._injectChildStyle(type);
10011
+ root.ce._injectChildStyle(
10012
+ type,
10013
+ instance.parent ? instance.parent.type : void 0
10014
+ );
9988
10015
  }
9989
10016
  {
9990
10017
  startMeasure(instance, `render`);
@@ -12575,7 +12602,7 @@ function isMemoSame(cached, memo) {
12575
12602
  return true;
12576
12603
  }
12577
12604
 
12578
- const version = "3.5.29";
12605
+ const version = "3.5.30";
12579
12606
  const warn = warn$1 ;
12580
12607
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12581
12608
  const devtools = devtools$1 ;
@@ -13460,7 +13487,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
13460
13487
  }
13461
13488
  } else if (
13462
13489
  // #11081 force set props for possible async custom element
13463
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
13490
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
13491
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
13492
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
13464
13493
  ) {
13465
13494
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
13466
13495
  } else {
@@ -13508,6 +13537,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
13508
13537
  }
13509
13538
  return key in el;
13510
13539
  }
13540
+ function shouldSetAsPropForVueCE(el, key) {
13541
+ const props = (
13542
+ // @ts-expect-error _def is private
13543
+ el._def.props
13544
+ );
13545
+ if (!props) {
13546
+ return false;
13547
+ }
13548
+ const camelKey = camelize(key);
13549
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
13550
+ }
13511
13551
 
13512
13552
  const REMOVAL = {};
13513
13553
  // @__NO_SIDE_EFFECTS__
@@ -13552,6 +13592,7 @@ class VueElement extends BaseClass {
13552
13592
  this._dirty = false;
13553
13593
  this._numberProps = null;
13554
13594
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13595
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
13555
13596
  this._ob = null;
13556
13597
  if (this.shadowRoot && _createApp !== createApp) {
13557
13598
  this._root = this.shadowRoot;
@@ -13580,7 +13621,8 @@ class VueElement extends BaseClass {
13580
13621
  }
13581
13622
  this._connected = true;
13582
13623
  let parent = this;
13583
- while (parent = parent && (parent.parentNode || parent.host)) {
13624
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
13625
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
13584
13626
  if (parent instanceof VueElement) {
13585
13627
  this._parent = parent;
13586
13628
  break;
@@ -13802,6 +13844,7 @@ class VueElement extends BaseClass {
13802
13844
  this._styles.forEach((s) => this._root.removeChild(s));
13803
13845
  this._styles.length = 0;
13804
13846
  }
13847
+ this._styleAnchors.delete(this._def);
13805
13848
  this._applyStyles(newStyles);
13806
13849
  this._instance = null;
13807
13850
  this._update();
@@ -13826,7 +13869,7 @@ class VueElement extends BaseClass {
13826
13869
  }
13827
13870
  return vnode;
13828
13871
  }
13829
- _applyStyles(styles, owner) {
13872
+ _applyStyles(styles, owner, parentComp) {
13830
13873
  if (!styles) return;
13831
13874
  if (owner) {
13832
13875
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -13835,11 +13878,19 @@ class VueElement extends BaseClass {
13835
13878
  this._styleChildren.add(owner);
13836
13879
  }
13837
13880
  const nonce = this._nonce;
13881
+ const root = this.shadowRoot;
13882
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
13883
+ let last = null;
13838
13884
  for (let i = styles.length - 1; i >= 0; i--) {
13839
13885
  const s = document.createElement("style");
13840
13886
  if (nonce) s.setAttribute("nonce", nonce);
13841
13887
  s.textContent = styles[i];
13842
- this.shadowRoot.prepend(s);
13888
+ root.insertBefore(s, last || insertionAnchor);
13889
+ last = s;
13890
+ if (i === 0) {
13891
+ if (!parentComp) this._styleAnchors.set(this._def, s);
13892
+ if (owner) this._styleAnchors.set(owner, s);
13893
+ }
13843
13894
  {
13844
13895
  if (owner) {
13845
13896
  if (owner.__hmrId) {
@@ -13856,6 +13907,28 @@ class VueElement extends BaseClass {
13856
13907
  }
13857
13908
  }
13858
13909
  }
13910
+ _getStyleAnchor(comp) {
13911
+ if (!comp) {
13912
+ return null;
13913
+ }
13914
+ const anchor = this._styleAnchors.get(comp);
13915
+ if (anchor && anchor.parentNode === this.shadowRoot) {
13916
+ return anchor;
13917
+ }
13918
+ if (anchor) {
13919
+ this._styleAnchors.delete(comp);
13920
+ }
13921
+ return null;
13922
+ }
13923
+ _getRootStyleInsertionAnchor(root) {
13924
+ for (let i = 0; i < root.childNodes.length; i++) {
13925
+ const node = root.childNodes[i];
13926
+ if (!(node instanceof HTMLStyleElement)) {
13927
+ return node;
13928
+ }
13929
+ }
13930
+ return null;
13931
+ }
13859
13932
  /**
13860
13933
  * Only called when shadowRoot is false
13861
13934
  */
@@ -13918,8 +13991,8 @@ class VueElement extends BaseClass {
13918
13991
  /**
13919
13992
  * @internal
13920
13993
  */
13921
- _injectChildStyle(comp) {
13922
- this._applyStyles(comp.styles, comp);
13994
+ _injectChildStyle(comp, parentComp) {
13995
+ this._applyStyles(comp.styles, comp, parentComp);
13923
13996
  }
13924
13997
  /**
13925
13998
  * @internal
@@ -13949,6 +14022,7 @@ class VueElement extends BaseClass {
13949
14022
  _removeChildStyle(comp) {
13950
14023
  {
13951
14024
  this._styleChildren.delete(comp);
14025
+ this._styleAnchors.delete(comp);
13952
14026
  if (this._childStyles && comp.__hmrId) {
13953
14027
  const oldStyles = this._childStyles.get(comp.__hmrId);
13954
14028
  if (oldStyles) {