@vue/runtime-dom 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/runtime-dom v3.5.28
2
+ * @vue/runtime-dom 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
  },
@@ -3761,6 +3768,7 @@ function resolveTransitionHooks(vnode, props, state, instance, postClone) {
3761
3768
  callHook(hook, [el]);
3762
3769
  },
3763
3770
  enter(el) {
3771
+ if (leavingVNodesCache[key] === vnode) return;
3764
3772
  let hook = onEnter;
3765
3773
  let afterHook = onAfterEnter;
3766
3774
  let cancelHook = onEnterCancelled;
@@ -5397,12 +5405,16 @@ function renderList(source, renderItem, cache, index) {
5397
5405
  );
5398
5406
  }
5399
5407
  } else if (typeof source === "number") {
5400
- if (!Number.isInteger(source)) {
5401
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5402
- }
5403
- ret = new Array(source);
5404
- for (let i = 0; i < source; i++) {
5405
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5408
+ if (!Number.isInteger(source) || source < 0) {
5409
+ warn$1(
5410
+ `The v-for range expects a positive integer value but got ${source}.`
5411
+ );
5412
+ ret = [];
5413
+ } else {
5414
+ ret = new Array(source);
5415
+ for (let i = 0; i < source; i++) {
5416
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5417
+ }
5406
5418
  }
5407
5419
  } else if (isObject(source)) {
5408
5420
  if (source[Symbol.iterator]) {
@@ -5853,6 +5865,7 @@ function createPropsRestProxy(props, excludedKeys) {
5853
5865
  }
5854
5866
  function withAsyncContext(getAwaitable) {
5855
5867
  const ctx = getCurrentInstance();
5868
+ const inSSRSetup = isInSSRComponentSetup;
5856
5869
  if (!ctx) {
5857
5870
  warn$1(
5858
5871
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5860,13 +5873,36 @@ function withAsyncContext(getAwaitable) {
5860
5873
  }
5861
5874
  let awaitable = getAwaitable();
5862
5875
  unsetCurrentInstance();
5876
+ if (inSSRSetup) {
5877
+ setInSSRSetupState(false);
5878
+ }
5879
+ const restore = () => {
5880
+ setCurrentInstance(ctx);
5881
+ if (inSSRSetup) {
5882
+ setInSSRSetupState(true);
5883
+ }
5884
+ };
5885
+ const cleanup = () => {
5886
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
5887
+ unsetCurrentInstance();
5888
+ if (inSSRSetup) {
5889
+ setInSSRSetupState(false);
5890
+ }
5891
+ };
5863
5892
  if (isPromise(awaitable)) {
5864
5893
  awaitable = awaitable.catch((e) => {
5865
- setCurrentInstance(ctx);
5894
+ restore();
5895
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
5866
5896
  throw e;
5867
5897
  });
5868
5898
  }
5869
- return [awaitable, () => setCurrentInstance(ctx)];
5899
+ return [
5900
+ awaitable,
5901
+ () => {
5902
+ restore();
5903
+ Promise.resolve().then(cleanup);
5904
+ }
5905
+ ];
5870
5906
  }
5871
5907
 
5872
5908
  function createDuplicateChecker() {
@@ -8238,7 +8274,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8238
8274
  }
8239
8275
  } else {
8240
8276
  if (root.ce && root.ce._hasShadowRoot()) {
8241
- root.ce._injectChildStyle(type);
8277
+ root.ce._injectChildStyle(
8278
+ type,
8279
+ instance.parent ? instance.parent.type : void 0
8280
+ );
8242
8281
  }
8243
8282
  {
8244
8283
  startMeasure(instance, `render`);
@@ -10720,7 +10759,7 @@ function isMemoSame(cached, memo) {
10720
10759
  return true;
10721
10760
  }
10722
10761
 
10723
- const version = "3.5.28";
10762
+ const version = "3.5.30";
10724
10763
  const warn = warn$1 ;
10725
10764
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10726
10765
  const devtools = devtools$1 ;
@@ -11517,7 +11556,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
11517
11556
  }
11518
11557
  } else if (
11519
11558
  // #11081 force set props for possible async custom element
11520
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11559
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11560
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11561
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11521
11562
  ) {
11522
11563
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11523
11564
  } else {
@@ -11565,6 +11606,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
11565
11606
  }
11566
11607
  return key in el;
11567
11608
  }
11609
+ function shouldSetAsPropForVueCE(el, key) {
11610
+ const props = (
11611
+ // @ts-expect-error _def is private
11612
+ el._def.props
11613
+ );
11614
+ if (!props) {
11615
+ return false;
11616
+ }
11617
+ const camelKey = camelize(key);
11618
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11619
+ }
11568
11620
 
11569
11621
  const REMOVAL = {};
11570
11622
  // @__NO_SIDE_EFFECTS__
@@ -11609,6 +11661,7 @@ class VueElement extends BaseClass {
11609
11661
  this._dirty = false;
11610
11662
  this._numberProps = null;
11611
11663
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11664
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11612
11665
  this._ob = null;
11613
11666
  if (this.shadowRoot && _createApp !== createApp) {
11614
11667
  this._root = this.shadowRoot;
@@ -11637,7 +11690,8 @@ class VueElement extends BaseClass {
11637
11690
  }
11638
11691
  this._connected = true;
11639
11692
  let parent = this;
11640
- while (parent = parent && (parent.parentNode || parent.host)) {
11693
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11694
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11641
11695
  if (parent instanceof VueElement) {
11642
11696
  this._parent = parent;
11643
11697
  break;
@@ -11859,6 +11913,7 @@ class VueElement extends BaseClass {
11859
11913
  this._styles.forEach((s) => this._root.removeChild(s));
11860
11914
  this._styles.length = 0;
11861
11915
  }
11916
+ this._styleAnchors.delete(this._def);
11862
11917
  this._applyStyles(newStyles);
11863
11918
  this._instance = null;
11864
11919
  this._update();
@@ -11883,7 +11938,7 @@ class VueElement extends BaseClass {
11883
11938
  }
11884
11939
  return vnode;
11885
11940
  }
11886
- _applyStyles(styles, owner) {
11941
+ _applyStyles(styles, owner, parentComp) {
11887
11942
  if (!styles) return;
11888
11943
  if (owner) {
11889
11944
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11892,11 +11947,19 @@ class VueElement extends BaseClass {
11892
11947
  this._styleChildren.add(owner);
11893
11948
  }
11894
11949
  const nonce = this._nonce;
11950
+ const root = this.shadowRoot;
11951
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11952
+ let last = null;
11895
11953
  for (let i = styles.length - 1; i >= 0; i--) {
11896
11954
  const s = document.createElement("style");
11897
11955
  if (nonce) s.setAttribute("nonce", nonce);
11898
11956
  s.textContent = styles[i];
11899
- this.shadowRoot.prepend(s);
11957
+ root.insertBefore(s, last || insertionAnchor);
11958
+ last = s;
11959
+ if (i === 0) {
11960
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11961
+ if (owner) this._styleAnchors.set(owner, s);
11962
+ }
11900
11963
  {
11901
11964
  if (owner) {
11902
11965
  if (owner.__hmrId) {
@@ -11913,6 +11976,28 @@ class VueElement extends BaseClass {
11913
11976
  }
11914
11977
  }
11915
11978
  }
11979
+ _getStyleAnchor(comp) {
11980
+ if (!comp) {
11981
+ return null;
11982
+ }
11983
+ const anchor = this._styleAnchors.get(comp);
11984
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11985
+ return anchor;
11986
+ }
11987
+ if (anchor) {
11988
+ this._styleAnchors.delete(comp);
11989
+ }
11990
+ return null;
11991
+ }
11992
+ _getRootStyleInsertionAnchor(root) {
11993
+ for (let i = 0; i < root.childNodes.length; i++) {
11994
+ const node = root.childNodes[i];
11995
+ if (!(node instanceof HTMLStyleElement)) {
11996
+ return node;
11997
+ }
11998
+ }
11999
+ return null;
12000
+ }
11916
12001
  /**
11917
12002
  * Only called when shadowRoot is false
11918
12003
  */
@@ -11975,8 +12060,8 @@ class VueElement extends BaseClass {
11975
12060
  /**
11976
12061
  * @internal
11977
12062
  */
11978
- _injectChildStyle(comp) {
11979
- this._applyStyles(comp.styles, comp);
12063
+ _injectChildStyle(comp, parentComp) {
12064
+ this._applyStyles(comp.styles, comp, parentComp);
11980
12065
  }
11981
12066
  /**
11982
12067
  * @internal
@@ -12006,6 +12091,7 @@ class VueElement extends BaseClass {
12006
12091
  _removeChildStyle(comp) {
12007
12092
  {
12008
12093
  this._styleChildren.delete(comp);
12094
+ this._styleAnchors.delete(comp);
12009
12095
  if (this._childStyles && comp.__hmrId) {
12010
12096
  const oldStyles = this._childStyles.get(comp.__hmrId);
12011
12097
  if (oldStyles) {