@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
  **/
@@ -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
  },
@@ -4233,6 +4240,7 @@ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
4233
4240
  callHook(hook, [el]);
4234
4241
  },
4235
4242
  enter(el) {
4243
+ if (leavingVNodesCache[key] === vnode) return;
4236
4244
  let hook = onEnter;
4237
4245
  let afterHook = onAfterEnter;
4238
4246
  let cancelHook = onEnterCancelled;
@@ -6160,12 +6168,16 @@ function renderList(source, renderItem, cache, index) {
6160
6168
  );
6161
6169
  }
6162
6170
  } else if (typeof source === "number") {
6163
- if (!Number.isInteger(source)) {
6164
- warn$1(`The v-for range expect an integer value but got ${source}.`);
6165
- }
6166
- ret = new Array(source);
6167
- for (let i = 0; i < source; i++) {
6168
- 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
+ }
6169
6181
  }
6170
6182
  } else if (isObject(source)) {
6171
6183
  if (source[Symbol.iterator]) {
@@ -6868,6 +6880,7 @@ function createPropsRestProxy(props, excludedKeys) {
6868
6880
  }
6869
6881
  function withAsyncContext(getAwaitable) {
6870
6882
  const ctx = getCurrentInstance();
6883
+ const inSSRSetup = isInSSRComponentSetup;
6871
6884
  if (!ctx) {
6872
6885
  warn$1(
6873
6886
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -6875,13 +6888,36 @@ function withAsyncContext(getAwaitable) {
6875
6888
  }
6876
6889
  let awaitable = getAwaitable();
6877
6890
  unsetCurrentInstance();
6891
+ if (inSSRSetup) {
6892
+ setInSSRSetupState(false);
6893
+ }
6894
+ const restore = () => {
6895
+ setCurrentInstance(ctx);
6896
+ if (inSSRSetup) {
6897
+ setInSSRSetupState(true);
6898
+ }
6899
+ };
6900
+ const cleanup = () => {
6901
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
6902
+ unsetCurrentInstance();
6903
+ if (inSSRSetup) {
6904
+ setInSSRSetupState(false);
6905
+ }
6906
+ };
6878
6907
  if (isPromise(awaitable)) {
6879
6908
  awaitable = awaitable.catch((e) => {
6880
- setCurrentInstance(ctx);
6909
+ restore();
6910
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
6881
6911
  throw e;
6882
6912
  });
6883
6913
  }
6884
- return [awaitable, () => setCurrentInstance(ctx)];
6914
+ return [
6915
+ awaitable,
6916
+ () => {
6917
+ restore();
6918
+ Promise.resolve().then(cleanup);
6919
+ }
6920
+ ];
6885
6921
  }
6886
6922
 
6887
6923
  function createDuplicateChecker() {
@@ -7402,7 +7438,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7402
7438
  return vm;
7403
7439
  }
7404
7440
  }
7405
- Vue.version = `2.6.14-compat:${"3.5.28"}`;
7441
+ Vue.version = `2.6.14-compat:${"3.5.30"}`;
7406
7442
  Vue.config = singletonApp.config;
7407
7443
  Vue.use = (plugin, ...options) => {
7408
7444
  if (plugin && isFunction(plugin.install)) {
@@ -9899,7 +9935,10 @@ function baseCreateRenderer(options, createHydrationFns) {
9899
9935
  }
9900
9936
  } else {
9901
9937
  if (root.ce && root.ce._hasShadowRoot()) {
9902
- root.ce._injectChildStyle(type);
9938
+ root.ce._injectChildStyle(
9939
+ type,
9940
+ instance.parent ? instance.parent.type : void 0
9941
+ );
9903
9942
  }
9904
9943
  {
9905
9944
  startMeasure(instance, `render`);
@@ -12490,7 +12529,7 @@ function isMemoSame(cached, memo) {
12490
12529
  return true;
12491
12530
  }
12492
12531
 
12493
- const version = "3.5.28";
12532
+ const version = "3.5.30";
12494
12533
  const warn = warn$1 ;
12495
12534
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12496
12535
  const devtools = devtools$1 ;
@@ -13375,7 +13414,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
13375
13414
  }
13376
13415
  } else if (
13377
13416
  // #11081 force set props for possible async custom element
13378
- 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)))
13379
13420
  ) {
13380
13421
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
13381
13422
  } else {
@@ -13423,6 +13464,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
13423
13464
  }
13424
13465
  return key in el;
13425
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
+ }
13426
13478
 
13427
13479
  const REMOVAL = {};
13428
13480
  // @__NO_SIDE_EFFECTS__
@@ -13467,6 +13519,7 @@ class VueElement extends BaseClass {
13467
13519
  this._dirty = false;
13468
13520
  this._numberProps = null;
13469
13521
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13522
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
13470
13523
  this._ob = null;
13471
13524
  if (this.shadowRoot && _createApp !== createApp) {
13472
13525
  this._root = this.shadowRoot;
@@ -13495,7 +13548,8 @@ class VueElement extends BaseClass {
13495
13548
  }
13496
13549
  this._connected = true;
13497
13550
  let parent = this;
13498
- 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)) {
13499
13553
  if (parent instanceof VueElement) {
13500
13554
  this._parent = parent;
13501
13555
  break;
@@ -13717,6 +13771,7 @@ class VueElement extends BaseClass {
13717
13771
  this._styles.forEach((s) => this._root.removeChild(s));
13718
13772
  this._styles.length = 0;
13719
13773
  }
13774
+ this._styleAnchors.delete(this._def);
13720
13775
  this._applyStyles(newStyles);
13721
13776
  this._instance = null;
13722
13777
  this._update();
@@ -13741,7 +13796,7 @@ class VueElement extends BaseClass {
13741
13796
  }
13742
13797
  return vnode;
13743
13798
  }
13744
- _applyStyles(styles, owner) {
13799
+ _applyStyles(styles, owner, parentComp) {
13745
13800
  if (!styles) return;
13746
13801
  if (owner) {
13747
13802
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -13750,11 +13805,19 @@ class VueElement extends BaseClass {
13750
13805
  this._styleChildren.add(owner);
13751
13806
  }
13752
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;
13753
13811
  for (let i = styles.length - 1; i >= 0; i--) {
13754
13812
  const s = document.createElement("style");
13755
13813
  if (nonce) s.setAttribute("nonce", nonce);
13756
13814
  s.textContent = styles[i];
13757
- 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
+ }
13758
13821
  {
13759
13822
  if (owner) {
13760
13823
  if (owner.__hmrId) {
@@ -13771,6 +13834,28 @@ class VueElement extends BaseClass {
13771
13834
  }
13772
13835
  }
13773
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
+ }
13774
13859
  /**
13775
13860
  * Only called when shadowRoot is false
13776
13861
  */
@@ -13833,8 +13918,8 @@ class VueElement extends BaseClass {
13833
13918
  /**
13834
13919
  * @internal
13835
13920
  */
13836
- _injectChildStyle(comp) {
13837
- this._applyStyles(comp.styles, comp);
13921
+ _injectChildStyle(comp, parentComp) {
13922
+ this._applyStyles(comp.styles, comp, parentComp);
13838
13923
  }
13839
13924
  /**
13840
13925
  * @internal
@@ -13864,6 +13949,7 @@ class VueElement extends BaseClass {
13864
13949
  _removeChildStyle(comp) {
13865
13950
  {
13866
13951
  this._styleChildren.delete(comp);
13952
+ this._styleAnchors.delete(comp);
13867
13953
  if (this._childStyles && comp.__hmrId) {
13868
13954
  const oldStyles = this._childStyles.get(comp.__hmrId);
13869
13955
  if (oldStyles) {