@vue/compat 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/compat v3.5.28
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
  },
@@ -4306,6 +4313,7 @@ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
4306
4313
  callHook(hook, [el]);
4307
4314
  },
4308
4315
  enter(el) {
4316
+ if (leavingVNodesCache[key] === vnode) return;
4309
4317
  let hook = onEnter;
4310
4318
  let afterHook = onAfterEnter;
4311
4319
  let cancelHook = onEnterCancelled;
@@ -6233,12 +6241,16 @@ function renderList(source, renderItem, cache, index) {
6233
6241
  );
6234
6242
  }
6235
6243
  } else if (typeof source === "number") {
6236
- if (!Number.isInteger(source)) {
6237
- warn$1(`The v-for range expect an integer value but got ${source}.`);
6238
- }
6239
- ret = new Array(source);
6240
- for (let i = 0; i < source; i++) {
6241
- 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
+ }
6242
6254
  }
6243
6255
  } else if (isObject(source)) {
6244
6256
  if (source[Symbol.iterator]) {
@@ -6941,6 +6953,7 @@ function createPropsRestProxy(props, excludedKeys) {
6941
6953
  }
6942
6954
  function withAsyncContext(getAwaitable) {
6943
6955
  const ctx = getCurrentInstance();
6956
+ const inSSRSetup = isInSSRComponentSetup;
6944
6957
  if (!ctx) {
6945
6958
  warn$1(
6946
6959
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -6948,13 +6961,36 @@ function withAsyncContext(getAwaitable) {
6948
6961
  }
6949
6962
  let awaitable = getAwaitable();
6950
6963
  unsetCurrentInstance();
6964
+ if (inSSRSetup) {
6965
+ setInSSRSetupState(false);
6966
+ }
6967
+ const restore = () => {
6968
+ setCurrentInstance(ctx);
6969
+ if (inSSRSetup) {
6970
+ setInSSRSetupState(true);
6971
+ }
6972
+ };
6973
+ const cleanup = () => {
6974
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
6975
+ unsetCurrentInstance();
6976
+ if (inSSRSetup) {
6977
+ setInSSRSetupState(false);
6978
+ }
6979
+ };
6951
6980
  if (isPromise(awaitable)) {
6952
6981
  awaitable = awaitable.catch((e) => {
6953
- setCurrentInstance(ctx);
6982
+ restore();
6983
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
6954
6984
  throw e;
6955
6985
  });
6956
6986
  }
6957
- return [awaitable, () => setCurrentInstance(ctx)];
6987
+ return [
6988
+ awaitable,
6989
+ () => {
6990
+ restore();
6991
+ Promise.resolve().then(cleanup);
6992
+ }
6993
+ ];
6958
6994
  }
6959
6995
 
6960
6996
  function createDuplicateChecker() {
@@ -7475,7 +7511,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7475
7511
  return vm;
7476
7512
  }
7477
7513
  }
7478
- Vue.version = `2.6.14-compat:${"3.5.28"}`;
7514
+ Vue.version = `2.6.14-compat:${"3.5.30"}`;
7479
7515
  Vue.config = singletonApp.config;
7480
7516
  Vue.use = (plugin, ...options) => {
7481
7517
  if (plugin && isFunction(plugin.install)) {
@@ -9972,7 +10008,10 @@ function baseCreateRenderer(options, createHydrationFns) {
9972
10008
  }
9973
10009
  } else {
9974
10010
  if (root.ce && root.ce._hasShadowRoot()) {
9975
- root.ce._injectChildStyle(type);
10011
+ root.ce._injectChildStyle(
10012
+ type,
10013
+ instance.parent ? instance.parent.type : void 0
10014
+ );
9976
10015
  }
9977
10016
  {
9978
10017
  startMeasure(instance, `render`);
@@ -12563,7 +12602,7 @@ function isMemoSame(cached, memo) {
12563
12602
  return true;
12564
12603
  }
12565
12604
 
12566
- const version = "3.5.28";
12605
+ const version = "3.5.30";
12567
12606
  const warn = warn$1 ;
12568
12607
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12569
12608
  const devtools = devtools$1 ;
@@ -13448,7 +13487,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
13448
13487
  }
13449
13488
  } else if (
13450
13489
  // #11081 force set props for possible async custom element
13451
- 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)))
13452
13493
  ) {
13453
13494
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
13454
13495
  } else {
@@ -13496,6 +13537,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
13496
13537
  }
13497
13538
  return key in el;
13498
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
+ }
13499
13551
 
13500
13552
  const REMOVAL = {};
13501
13553
  // @__NO_SIDE_EFFECTS__
@@ -13540,6 +13592,7 @@ class VueElement extends BaseClass {
13540
13592
  this._dirty = false;
13541
13593
  this._numberProps = null;
13542
13594
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13595
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
13543
13596
  this._ob = null;
13544
13597
  if (this.shadowRoot && _createApp !== createApp) {
13545
13598
  this._root = this.shadowRoot;
@@ -13568,7 +13621,8 @@ class VueElement extends BaseClass {
13568
13621
  }
13569
13622
  this._connected = true;
13570
13623
  let parent = this;
13571
- 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)) {
13572
13626
  if (parent instanceof VueElement) {
13573
13627
  this._parent = parent;
13574
13628
  break;
@@ -13790,6 +13844,7 @@ class VueElement extends BaseClass {
13790
13844
  this._styles.forEach((s) => this._root.removeChild(s));
13791
13845
  this._styles.length = 0;
13792
13846
  }
13847
+ this._styleAnchors.delete(this._def);
13793
13848
  this._applyStyles(newStyles);
13794
13849
  this._instance = null;
13795
13850
  this._update();
@@ -13814,7 +13869,7 @@ class VueElement extends BaseClass {
13814
13869
  }
13815
13870
  return vnode;
13816
13871
  }
13817
- _applyStyles(styles, owner) {
13872
+ _applyStyles(styles, owner, parentComp) {
13818
13873
  if (!styles) return;
13819
13874
  if (owner) {
13820
13875
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -13823,11 +13878,19 @@ class VueElement extends BaseClass {
13823
13878
  this._styleChildren.add(owner);
13824
13879
  }
13825
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;
13826
13884
  for (let i = styles.length - 1; i >= 0; i--) {
13827
13885
  const s = document.createElement("style");
13828
13886
  if (nonce) s.setAttribute("nonce", nonce);
13829
13887
  s.textContent = styles[i];
13830
- 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
+ }
13831
13894
  {
13832
13895
  if (owner) {
13833
13896
  if (owner.__hmrId) {
@@ -13844,6 +13907,28 @@ class VueElement extends BaseClass {
13844
13907
  }
13845
13908
  }
13846
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
+ }
13847
13932
  /**
13848
13933
  * Only called when shadowRoot is false
13849
13934
  */
@@ -13906,8 +13991,8 @@ class VueElement extends BaseClass {
13906
13991
  /**
13907
13992
  * @internal
13908
13993
  */
13909
- _injectChildStyle(comp) {
13910
- this._applyStyles(comp.styles, comp);
13994
+ _injectChildStyle(comp, parentComp) {
13995
+ this._applyStyles(comp.styles, comp, parentComp);
13911
13996
  }
13912
13997
  /**
13913
13998
  * @internal
@@ -13937,6 +14022,7 @@ class VueElement extends BaseClass {
13937
14022
  _removeChildStyle(comp) {
13938
14023
  {
13939
14024
  this._styleChildren.delete(comp);
14025
+ this._styleAnchors.delete(comp);
13940
14026
  if (this._childStyles && comp.__hmrId) {
13941
14027
  const oldStyles = this._childStyles.get(comp.__hmrId);
13942
14028
  if (oldStyles) {