@vue/runtime-dom 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/runtime-dom v3.5.29
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
  },
@@ -5398,12 +5405,16 @@ function renderList(source, renderItem, cache, index) {
5398
5405
  );
5399
5406
  }
5400
5407
  } else if (typeof source === "number") {
5401
- if (!Number.isInteger(source)) {
5402
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5403
- }
5404
- ret = new Array(source);
5405
- for (let i = 0; i < source; i++) {
5406
- 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
+ }
5407
5418
  }
5408
5419
  } else if (isObject(source)) {
5409
5420
  if (source[Symbol.iterator]) {
@@ -5854,6 +5865,7 @@ function createPropsRestProxy(props, excludedKeys) {
5854
5865
  }
5855
5866
  function withAsyncContext(getAwaitable) {
5856
5867
  const ctx = getCurrentInstance();
5868
+ const inSSRSetup = isInSSRComponentSetup;
5857
5869
  if (!ctx) {
5858
5870
  warn$1(
5859
5871
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5861,13 +5873,25 @@ function withAsyncContext(getAwaitable) {
5861
5873
  }
5862
5874
  let awaitable = getAwaitable();
5863
5875
  unsetCurrentInstance();
5876
+ if (inSSRSetup) {
5877
+ setInSSRSetupState(false);
5878
+ }
5879
+ const restore = () => {
5880
+ setCurrentInstance(ctx);
5881
+ if (inSSRSetup) {
5882
+ setInSSRSetupState(true);
5883
+ }
5884
+ };
5864
5885
  const cleanup = () => {
5865
5886
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5866
5887
  unsetCurrentInstance();
5888
+ if (inSSRSetup) {
5889
+ setInSSRSetupState(false);
5890
+ }
5867
5891
  };
5868
5892
  if (isPromise(awaitable)) {
5869
5893
  awaitable = awaitable.catch((e) => {
5870
- setCurrentInstance(ctx);
5894
+ restore();
5871
5895
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5872
5896
  throw e;
5873
5897
  });
@@ -5875,7 +5899,7 @@ function withAsyncContext(getAwaitable) {
5875
5899
  return [
5876
5900
  awaitable,
5877
5901
  () => {
5878
- setCurrentInstance(ctx);
5902
+ restore();
5879
5903
  Promise.resolve().then(cleanup);
5880
5904
  }
5881
5905
  ];
@@ -8250,7 +8274,10 @@ function baseCreateRenderer(options, createHydrationFns) {
8250
8274
  }
8251
8275
  } else {
8252
8276
  if (root.ce && root.ce._hasShadowRoot()) {
8253
- root.ce._injectChildStyle(type);
8277
+ root.ce._injectChildStyle(
8278
+ type,
8279
+ instance.parent ? instance.parent.type : void 0
8280
+ );
8254
8281
  }
8255
8282
  {
8256
8283
  startMeasure(instance, `render`);
@@ -10732,7 +10759,7 @@ function isMemoSame(cached, memo) {
10732
10759
  return true;
10733
10760
  }
10734
10761
 
10735
- const version = "3.5.29";
10762
+ const version = "3.5.30";
10736
10763
  const warn = warn$1 ;
10737
10764
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10738
10765
  const devtools = devtools$1 ;
@@ -11529,7 +11556,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
11529
11556
  }
11530
11557
  } else if (
11531
11558
  // #11081 force set props for possible async custom element
11532
- 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)))
11533
11562
  ) {
11534
11563
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11535
11564
  } else {
@@ -11577,6 +11606,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
11577
11606
  }
11578
11607
  return key in el;
11579
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
+ }
11580
11620
 
11581
11621
  const REMOVAL = {};
11582
11622
  // @__NO_SIDE_EFFECTS__
@@ -11621,6 +11661,7 @@ class VueElement extends BaseClass {
11621
11661
  this._dirty = false;
11622
11662
  this._numberProps = null;
11623
11663
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11664
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11624
11665
  this._ob = null;
11625
11666
  if (this.shadowRoot && _createApp !== createApp) {
11626
11667
  this._root = this.shadowRoot;
@@ -11649,7 +11690,8 @@ class VueElement extends BaseClass {
11649
11690
  }
11650
11691
  this._connected = true;
11651
11692
  let parent = this;
11652
- 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)) {
11653
11695
  if (parent instanceof VueElement) {
11654
11696
  this._parent = parent;
11655
11697
  break;
@@ -11871,6 +11913,7 @@ class VueElement extends BaseClass {
11871
11913
  this._styles.forEach((s) => this._root.removeChild(s));
11872
11914
  this._styles.length = 0;
11873
11915
  }
11916
+ this._styleAnchors.delete(this._def);
11874
11917
  this._applyStyles(newStyles);
11875
11918
  this._instance = null;
11876
11919
  this._update();
@@ -11895,7 +11938,7 @@ class VueElement extends BaseClass {
11895
11938
  }
11896
11939
  return vnode;
11897
11940
  }
11898
- _applyStyles(styles, owner) {
11941
+ _applyStyles(styles, owner, parentComp) {
11899
11942
  if (!styles) return;
11900
11943
  if (owner) {
11901
11944
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11904,11 +11947,19 @@ class VueElement extends BaseClass {
11904
11947
  this._styleChildren.add(owner);
11905
11948
  }
11906
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;
11907
11953
  for (let i = styles.length - 1; i >= 0; i--) {
11908
11954
  const s = document.createElement("style");
11909
11955
  if (nonce) s.setAttribute("nonce", nonce);
11910
11956
  s.textContent = styles[i];
11911
- 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
+ }
11912
11963
  {
11913
11964
  if (owner) {
11914
11965
  if (owner.__hmrId) {
@@ -11925,6 +11976,28 @@ class VueElement extends BaseClass {
11925
11976
  }
11926
11977
  }
11927
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
+ }
11928
12001
  /**
11929
12002
  * Only called when shadowRoot is false
11930
12003
  */
@@ -11987,8 +12060,8 @@ class VueElement extends BaseClass {
11987
12060
  /**
11988
12061
  * @internal
11989
12062
  */
11990
- _injectChildStyle(comp) {
11991
- this._applyStyles(comp.styles, comp);
12063
+ _injectChildStyle(comp, parentComp) {
12064
+ this._applyStyles(comp.styles, comp, parentComp);
11992
12065
  }
11993
12066
  /**
11994
12067
  * @internal
@@ -12018,6 +12091,7 @@ class VueElement extends BaseClass {
12018
12091
  _removeChildStyle(comp) {
12019
12092
  {
12020
12093
  this._styleChildren.delete(comp);
12094
+ this._styleAnchors.delete(comp);
12021
12095
  if (this._childStyles && comp.__hmrId) {
12022
12096
  const oldStyles = this._childStyles.get(comp.__hmrId);
12023
12097
  if (oldStyles) {