@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
  **/
@@ -782,7 +782,9 @@ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) =>
782
782
  }
783
783
  } else if (
784
784
  // #11081 force set props for possible async custom element
785
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
785
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
786
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
787
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
786
788
  ) {
787
789
  patchDOMProp(el, camelize$1(key), nextValue, parentComponent, key);
788
790
  } else {
@@ -830,6 +832,17 @@ function shouldSetAsProp(el, key, value, isSVG) {
830
832
  }
831
833
  return key in el;
832
834
  }
835
+ function shouldSetAsPropForVueCE(el, key) {
836
+ const props = (
837
+ // @ts-expect-error _def is private
838
+ el._def.props
839
+ );
840
+ if (!props) {
841
+ return false;
842
+ }
843
+ const camelKey = camelize$1(key);
844
+ return Array.isArray(props) ? props.some((prop) => camelize$1(prop) === camelKey) : Object.keys(props).some((prop) => camelize$1(prop) === camelKey);
845
+ }
833
846
 
834
847
  const REMOVAL = {};
835
848
  // @__NO_SIDE_EFFECTS__
@@ -874,6 +887,7 @@ class VueElement extends BaseClass {
874
887
  this._dirty = false;
875
888
  this._numberProps = null;
876
889
  this._styleChildren = /* @__PURE__ */ new WeakSet();
890
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
877
891
  this._ob = null;
878
892
  if (this.shadowRoot && _createApp !== createApp) {
879
893
  this._root = this.shadowRoot;
@@ -902,7 +916,8 @@ class VueElement extends BaseClass {
902
916
  }
903
917
  this._connected = true;
904
918
  let parent = this;
905
- while (parent = parent && (parent.parentNode || parent.host)) {
919
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
920
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
906
921
  if (parent instanceof VueElement) {
907
922
  this._parent = parent;
908
923
  break;
@@ -1124,6 +1139,7 @@ class VueElement extends BaseClass {
1124
1139
  this._styles.forEach((s) => this._root.removeChild(s));
1125
1140
  this._styles.length = 0;
1126
1141
  }
1142
+ this._styleAnchors.delete(this._def);
1127
1143
  this._applyStyles(newStyles);
1128
1144
  this._instance = null;
1129
1145
  this._update();
@@ -1148,7 +1164,7 @@ class VueElement extends BaseClass {
1148
1164
  }
1149
1165
  return vnode;
1150
1166
  }
1151
- _applyStyles(styles, owner) {
1167
+ _applyStyles(styles, owner, parentComp) {
1152
1168
  if (!styles) return;
1153
1169
  if (owner) {
1154
1170
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -1157,11 +1173,19 @@ class VueElement extends BaseClass {
1157
1173
  this._styleChildren.add(owner);
1158
1174
  }
1159
1175
  const nonce = this._nonce;
1176
+ const root = this.shadowRoot;
1177
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
1178
+ let last = null;
1160
1179
  for (let i = styles.length - 1; i >= 0; i--) {
1161
1180
  const s = document.createElement("style");
1162
1181
  if (nonce) s.setAttribute("nonce", nonce);
1163
1182
  s.textContent = styles[i];
1164
- this.shadowRoot.prepend(s);
1183
+ root.insertBefore(s, last || insertionAnchor);
1184
+ last = s;
1185
+ if (i === 0) {
1186
+ if (!parentComp) this._styleAnchors.set(this._def, s);
1187
+ if (owner) this._styleAnchors.set(owner, s);
1188
+ }
1165
1189
  if (!!(process.env.NODE_ENV !== "production")) {
1166
1190
  if (owner) {
1167
1191
  if (owner.__hmrId) {
@@ -1178,6 +1202,28 @@ class VueElement extends BaseClass {
1178
1202
  }
1179
1203
  }
1180
1204
  }
1205
+ _getStyleAnchor(comp) {
1206
+ if (!comp) {
1207
+ return null;
1208
+ }
1209
+ const anchor = this._styleAnchors.get(comp);
1210
+ if (anchor && anchor.parentNode === this.shadowRoot) {
1211
+ return anchor;
1212
+ }
1213
+ if (anchor) {
1214
+ this._styleAnchors.delete(comp);
1215
+ }
1216
+ return null;
1217
+ }
1218
+ _getRootStyleInsertionAnchor(root) {
1219
+ for (let i = 0; i < root.childNodes.length; i++) {
1220
+ const node = root.childNodes[i];
1221
+ if (!(node instanceof HTMLStyleElement)) {
1222
+ return node;
1223
+ }
1224
+ }
1225
+ return null;
1226
+ }
1181
1227
  /**
1182
1228
  * Only called when shadowRoot is false
1183
1229
  */
@@ -1240,8 +1286,8 @@ class VueElement extends BaseClass {
1240
1286
  /**
1241
1287
  * @internal
1242
1288
  */
1243
- _injectChildStyle(comp) {
1244
- this._applyStyles(comp.styles, comp);
1289
+ _injectChildStyle(comp, parentComp) {
1290
+ this._applyStyles(comp.styles, comp, parentComp);
1245
1291
  }
1246
1292
  /**
1247
1293
  * @internal
@@ -1271,6 +1317,7 @@ class VueElement extends BaseClass {
1271
1317
  _removeChildStyle(comp) {
1272
1318
  if (!!(process.env.NODE_ENV !== "production")) {
1273
1319
  this._styleChildren.delete(comp);
1320
+ this._styleAnchors.delete(comp);
1274
1321
  if (this._childStyles && comp.__hmrId) {
1275
1322
  const oldStyles = this._childStyles.get(comp.__hmrId);
1276
1323
  if (oldStyles) {
@@ -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
  **/
@@ -1208,10 +1208,17 @@ var VueRuntimeDOM = (function (exports) {
1208
1208
  }
1209
1209
  function reduce(self, method, fn, args) {
1210
1210
  const arr = shallowReadArray(self);
1211
+ const needsWrap = arr !== self && !isShallow(self);
1211
1212
  let wrappedFn = fn;
1213
+ let wrapInitialAccumulator = false;
1212
1214
  if (arr !== self) {
1213
- if (!isShallow(self)) {
1215
+ if (needsWrap) {
1216
+ wrapInitialAccumulator = args.length === 0;
1214
1217
  wrappedFn = function(acc, item, index) {
1218
+ if (wrapInitialAccumulator) {
1219
+ wrapInitialAccumulator = false;
1220
+ acc = toWrapped(self, acc);
1221
+ }
1215
1222
  return fn.call(this, acc, toWrapped(self, item), index, self);
1216
1223
  };
1217
1224
  } else if (fn.length > 3) {
@@ -1220,7 +1227,8 @@ var VueRuntimeDOM = (function (exports) {
1220
1227
  };
1221
1228
  }
1222
1229
  }
1223
- return arr[method](wrappedFn, ...args);
1230
+ const result = arr[method](wrappedFn, ...args);
1231
+ return wrapInitialAccumulator ? toWrapped(self, result) : result;
1224
1232
  }
1225
1233
  function searchProxy(self, method, args) {
1226
1234
  const arr = toRaw(self);
@@ -1510,15 +1518,14 @@ var VueRuntimeDOM = (function (exports) {
1510
1518
  clear: createReadonlyMethod("clear")
1511
1519
  } : {
1512
1520
  add(value) {
1513
- if (!shallow && !isShallow(value) && !isReadonly(value)) {
1514
- value = toRaw(value);
1515
- }
1516
1521
  const target = toRaw(this);
1517
1522
  const proto = getProto(target);
1518
- const hadKey = proto.has.call(target, value);
1523
+ const rawValue = toRaw(value);
1524
+ const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
1525
+ const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
1519
1526
  if (!hadKey) {
1520
- target.add(value);
1521
- trigger(target, "add", value, value);
1527
+ target.add(valueToAdd);
1528
+ trigger(target, "add", valueToAdd, valueToAdd);
1522
1529
  }
1523
1530
  return this;
1524
1531
  },
@@ -3736,6 +3743,7 @@ var VueRuntimeDOM = (function (exports) {
3736
3743
  callHook(hook, [el]);
3737
3744
  },
3738
3745
  enter(el) {
3746
+ if (leavingVNodesCache[key] === vnode) return;
3739
3747
  let hook = onEnter;
3740
3748
  let afterHook = onAfterEnter;
3741
3749
  let cancelHook = onEnterCancelled;
@@ -5366,12 +5374,16 @@ If this is a native custom element, make sure to exclude it from component resol
5366
5374
  );
5367
5375
  }
5368
5376
  } else if (typeof source === "number") {
5369
- if (!Number.isInteger(source)) {
5370
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5371
- }
5372
- ret = new Array(source);
5373
- for (let i = 0; i < source; i++) {
5374
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5377
+ if (!Number.isInteger(source) || source < 0) {
5378
+ warn$1(
5379
+ `The v-for range expects a positive integer value but got ${source}.`
5380
+ );
5381
+ ret = [];
5382
+ } else {
5383
+ ret = new Array(source);
5384
+ for (let i = 0; i < source; i++) {
5385
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5386
+ }
5375
5387
  }
5376
5388
  } else if (isObject(source)) {
5377
5389
  if (source[Symbol.iterator]) {
@@ -5822,6 +5834,7 @@ If this is a native custom element, make sure to exclude it from component resol
5822
5834
  }
5823
5835
  function withAsyncContext(getAwaitable) {
5824
5836
  const ctx = getCurrentInstance();
5837
+ const inSSRSetup = isInSSRComponentSetup;
5825
5838
  if (!ctx) {
5826
5839
  warn$1(
5827
5840
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5829,13 +5842,36 @@ If this is a native custom element, make sure to exclude it from component resol
5829
5842
  }
5830
5843
  let awaitable = getAwaitable();
5831
5844
  unsetCurrentInstance();
5845
+ if (inSSRSetup) {
5846
+ setInSSRSetupState(false);
5847
+ }
5848
+ const restore = () => {
5849
+ setCurrentInstance(ctx);
5850
+ if (inSSRSetup) {
5851
+ setInSSRSetupState(true);
5852
+ }
5853
+ };
5854
+ const cleanup = () => {
5855
+ if (getCurrentInstance() !== ctx) ctx.scope.off();
5856
+ unsetCurrentInstance();
5857
+ if (inSSRSetup) {
5858
+ setInSSRSetupState(false);
5859
+ }
5860
+ };
5832
5861
  if (isPromise(awaitable)) {
5833
5862
  awaitable = awaitable.catch((e) => {
5834
- setCurrentInstance(ctx);
5863
+ restore();
5864
+ Promise.resolve().then(() => Promise.resolve().then(cleanup));
5835
5865
  throw e;
5836
5866
  });
5837
5867
  }
5838
- return [awaitable, () => setCurrentInstance(ctx)];
5868
+ return [
5869
+ awaitable,
5870
+ () => {
5871
+ restore();
5872
+ Promise.resolve().then(cleanup);
5873
+ }
5874
+ ];
5839
5875
  }
5840
5876
 
5841
5877
  function createDuplicateChecker() {
@@ -8204,7 +8240,10 @@ If you want to remount the same app, move your app creation logic into a factory
8204
8240
  }
8205
8241
  } else {
8206
8242
  if (root.ce && root.ce._hasShadowRoot()) {
8207
- root.ce._injectChildStyle(type);
8243
+ root.ce._injectChildStyle(
8244
+ type,
8245
+ instance.parent ? instance.parent.type : void 0
8246
+ );
8208
8247
  }
8209
8248
  {
8210
8249
  startMeasure(instance, `render`);
@@ -10672,7 +10711,7 @@ Component that was made reactive: `,
10672
10711
  return true;
10673
10712
  }
10674
10713
 
10675
- const version = "3.5.28";
10714
+ const version = "3.5.30";
10676
10715
  const warn = warn$1 ;
10677
10716
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10678
10717
  const devtools = devtools$1 ;
@@ -11450,7 +11489,9 @@ Expected function or array of functions, received type ${typeof value}.`
11450
11489
  }
11451
11490
  } else if (
11452
11491
  // #11081 force set props for possible async custom element
11453
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11492
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11493
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11494
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11454
11495
  ) {
11455
11496
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11456
11497
  } else {
@@ -11498,6 +11539,17 @@ Expected function or array of functions, received type ${typeof value}.`
11498
11539
  }
11499
11540
  return key in el;
11500
11541
  }
11542
+ function shouldSetAsPropForVueCE(el, key) {
11543
+ const props = (
11544
+ // @ts-expect-error _def is private
11545
+ el._def.props
11546
+ );
11547
+ if (!props) {
11548
+ return false;
11549
+ }
11550
+ const camelKey = camelize(key);
11551
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11552
+ }
11501
11553
 
11502
11554
  const REMOVAL = {};
11503
11555
  // @__NO_SIDE_EFFECTS__
@@ -11542,6 +11594,7 @@ Expected function or array of functions, received type ${typeof value}.`
11542
11594
  this._dirty = false;
11543
11595
  this._numberProps = null;
11544
11596
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11597
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11545
11598
  this._ob = null;
11546
11599
  if (this.shadowRoot && _createApp !== createApp) {
11547
11600
  this._root = this.shadowRoot;
@@ -11570,7 +11623,8 @@ Expected function or array of functions, received type ${typeof value}.`
11570
11623
  }
11571
11624
  this._connected = true;
11572
11625
  let parent = this;
11573
- while (parent = parent && (parent.parentNode || parent.host)) {
11626
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11627
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11574
11628
  if (parent instanceof VueElement) {
11575
11629
  this._parent = parent;
11576
11630
  break;
@@ -11792,6 +11846,7 @@ Expected function or array of functions, received type ${typeof value}.`
11792
11846
  this._styles.forEach((s) => this._root.removeChild(s));
11793
11847
  this._styles.length = 0;
11794
11848
  }
11849
+ this._styleAnchors.delete(this._def);
11795
11850
  this._applyStyles(newStyles);
11796
11851
  this._instance = null;
11797
11852
  this._update();
@@ -11816,7 +11871,7 @@ Expected function or array of functions, received type ${typeof value}.`
11816
11871
  }
11817
11872
  return vnode;
11818
11873
  }
11819
- _applyStyles(styles, owner) {
11874
+ _applyStyles(styles, owner, parentComp) {
11820
11875
  if (!styles) return;
11821
11876
  if (owner) {
11822
11877
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11825,11 +11880,19 @@ Expected function or array of functions, received type ${typeof value}.`
11825
11880
  this._styleChildren.add(owner);
11826
11881
  }
11827
11882
  const nonce = this._nonce;
11883
+ const root = this.shadowRoot;
11884
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11885
+ let last = null;
11828
11886
  for (let i = styles.length - 1; i >= 0; i--) {
11829
11887
  const s = document.createElement("style");
11830
11888
  if (nonce) s.setAttribute("nonce", nonce);
11831
11889
  s.textContent = styles[i];
11832
- this.shadowRoot.prepend(s);
11890
+ root.insertBefore(s, last || insertionAnchor);
11891
+ last = s;
11892
+ if (i === 0) {
11893
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11894
+ if (owner) this._styleAnchors.set(owner, s);
11895
+ }
11833
11896
  {
11834
11897
  if (owner) {
11835
11898
  if (owner.__hmrId) {
@@ -11846,6 +11909,28 @@ Expected function or array of functions, received type ${typeof value}.`
11846
11909
  }
11847
11910
  }
11848
11911
  }
11912
+ _getStyleAnchor(comp) {
11913
+ if (!comp) {
11914
+ return null;
11915
+ }
11916
+ const anchor = this._styleAnchors.get(comp);
11917
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11918
+ return anchor;
11919
+ }
11920
+ if (anchor) {
11921
+ this._styleAnchors.delete(comp);
11922
+ }
11923
+ return null;
11924
+ }
11925
+ _getRootStyleInsertionAnchor(root) {
11926
+ for (let i = 0; i < root.childNodes.length; i++) {
11927
+ const node = root.childNodes[i];
11928
+ if (!(node instanceof HTMLStyleElement)) {
11929
+ return node;
11930
+ }
11931
+ }
11932
+ return null;
11933
+ }
11849
11934
  /**
11850
11935
  * Only called when shadowRoot is false
11851
11936
  */
@@ -11908,8 +11993,8 @@ Expected function or array of functions, received type ${typeof value}.`
11908
11993
  /**
11909
11994
  * @internal
11910
11995
  */
11911
- _injectChildStyle(comp) {
11912
- this._applyStyles(comp.styles, comp);
11996
+ _injectChildStyle(comp, parentComp) {
11997
+ this._applyStyles(comp.styles, comp, parentComp);
11913
11998
  }
11914
11999
  /**
11915
12000
  * @internal
@@ -11939,6 +12024,7 @@ Expected function or array of functions, received type ${typeof value}.`
11939
12024
  _removeChildStyle(comp) {
11940
12025
  {
11941
12026
  this._styleChildren.delete(comp);
12027
+ this._styleAnchors.delete(comp);
11942
12028
  if (this._childStyles && comp.__hmrId) {
11943
12029
  const oldStyles = this._childStyles.get(comp.__hmrId);
11944
12030
  if (oldStyles) {