@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
  **/
@@ -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.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
  **/
@@ -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
  },
@@ -5367,12 +5374,16 @@ If this is a native custom element, make sure to exclude it from component resol
5367
5374
  );
5368
5375
  }
5369
5376
  } else if (typeof source === "number") {
5370
- if (!Number.isInteger(source)) {
5371
- warn$1(`The v-for range expect an integer value but got ${source}.`);
5372
- }
5373
- ret = new Array(source);
5374
- for (let i = 0; i < source; i++) {
5375
- 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
+ }
5376
5387
  }
5377
5388
  } else if (isObject(source)) {
5378
5389
  if (source[Symbol.iterator]) {
@@ -5823,6 +5834,7 @@ If this is a native custom element, make sure to exclude it from component resol
5823
5834
  }
5824
5835
  function withAsyncContext(getAwaitable) {
5825
5836
  const ctx = getCurrentInstance();
5837
+ const inSSRSetup = isInSSRComponentSetup;
5826
5838
  if (!ctx) {
5827
5839
  warn$1(
5828
5840
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5830,13 +5842,25 @@ If this is a native custom element, make sure to exclude it from component resol
5830
5842
  }
5831
5843
  let awaitable = getAwaitable();
5832
5844
  unsetCurrentInstance();
5845
+ if (inSSRSetup) {
5846
+ setInSSRSetupState(false);
5847
+ }
5848
+ const restore = () => {
5849
+ setCurrentInstance(ctx);
5850
+ if (inSSRSetup) {
5851
+ setInSSRSetupState(true);
5852
+ }
5853
+ };
5833
5854
  const cleanup = () => {
5834
5855
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5835
5856
  unsetCurrentInstance();
5857
+ if (inSSRSetup) {
5858
+ setInSSRSetupState(false);
5859
+ }
5836
5860
  };
5837
5861
  if (isPromise(awaitable)) {
5838
5862
  awaitable = awaitable.catch((e) => {
5839
- setCurrentInstance(ctx);
5863
+ restore();
5840
5864
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5841
5865
  throw e;
5842
5866
  });
@@ -5844,7 +5868,7 @@ If this is a native custom element, make sure to exclude it from component resol
5844
5868
  return [
5845
5869
  awaitable,
5846
5870
  () => {
5847
- setCurrentInstance(ctx);
5871
+ restore();
5848
5872
  Promise.resolve().then(cleanup);
5849
5873
  }
5850
5874
  ];
@@ -8216,7 +8240,10 @@ If you want to remount the same app, move your app creation logic into a factory
8216
8240
  }
8217
8241
  } else {
8218
8242
  if (root.ce && root.ce._hasShadowRoot()) {
8219
- root.ce._injectChildStyle(type);
8243
+ root.ce._injectChildStyle(
8244
+ type,
8245
+ instance.parent ? instance.parent.type : void 0
8246
+ );
8220
8247
  }
8221
8248
  {
8222
8249
  startMeasure(instance, `render`);
@@ -10684,7 +10711,7 @@ Component that was made reactive: `,
10684
10711
  return true;
10685
10712
  }
10686
10713
 
10687
- const version = "3.5.29";
10714
+ const version = "3.5.30";
10688
10715
  const warn = warn$1 ;
10689
10716
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10690
10717
  const devtools = devtools$1 ;
@@ -11462,7 +11489,9 @@ Expected function or array of functions, received type ${typeof value}.`
11462
11489
  }
11463
11490
  } else if (
11464
11491
  // #11081 force set props for possible async custom element
11465
- 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)))
11466
11495
  ) {
11467
11496
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11468
11497
  } else {
@@ -11510,6 +11539,17 @@ Expected function or array of functions, received type ${typeof value}.`
11510
11539
  }
11511
11540
  return key in el;
11512
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
+ }
11513
11553
 
11514
11554
  const REMOVAL = {};
11515
11555
  // @__NO_SIDE_EFFECTS__
@@ -11554,6 +11594,7 @@ Expected function or array of functions, received type ${typeof value}.`
11554
11594
  this._dirty = false;
11555
11595
  this._numberProps = null;
11556
11596
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11597
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11557
11598
  this._ob = null;
11558
11599
  if (this.shadowRoot && _createApp !== createApp) {
11559
11600
  this._root = this.shadowRoot;
@@ -11582,7 +11623,8 @@ Expected function or array of functions, received type ${typeof value}.`
11582
11623
  }
11583
11624
  this._connected = true;
11584
11625
  let parent = this;
11585
- 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)) {
11586
11628
  if (parent instanceof VueElement) {
11587
11629
  this._parent = parent;
11588
11630
  break;
@@ -11804,6 +11846,7 @@ Expected function or array of functions, received type ${typeof value}.`
11804
11846
  this._styles.forEach((s) => this._root.removeChild(s));
11805
11847
  this._styles.length = 0;
11806
11848
  }
11849
+ this._styleAnchors.delete(this._def);
11807
11850
  this._applyStyles(newStyles);
11808
11851
  this._instance = null;
11809
11852
  this._update();
@@ -11828,7 +11871,7 @@ Expected function or array of functions, received type ${typeof value}.`
11828
11871
  }
11829
11872
  return vnode;
11830
11873
  }
11831
- _applyStyles(styles, owner) {
11874
+ _applyStyles(styles, owner, parentComp) {
11832
11875
  if (!styles) return;
11833
11876
  if (owner) {
11834
11877
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11837,11 +11880,19 @@ Expected function or array of functions, received type ${typeof value}.`
11837
11880
  this._styleChildren.add(owner);
11838
11881
  }
11839
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;
11840
11886
  for (let i = styles.length - 1; i >= 0; i--) {
11841
11887
  const s = document.createElement("style");
11842
11888
  if (nonce) s.setAttribute("nonce", nonce);
11843
11889
  s.textContent = styles[i];
11844
- 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
+ }
11845
11896
  {
11846
11897
  if (owner) {
11847
11898
  if (owner.__hmrId) {
@@ -11858,6 +11909,28 @@ Expected function or array of functions, received type ${typeof value}.`
11858
11909
  }
11859
11910
  }
11860
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
+ }
11861
11934
  /**
11862
11935
  * Only called when shadowRoot is false
11863
11936
  */
@@ -11920,8 +11993,8 @@ Expected function or array of functions, received type ${typeof value}.`
11920
11993
  /**
11921
11994
  * @internal
11922
11995
  */
11923
- _injectChildStyle(comp) {
11924
- this._applyStyles(comp.styles, comp);
11996
+ _injectChildStyle(comp, parentComp) {
11997
+ this._applyStyles(comp.styles, comp, parentComp);
11925
11998
  }
11926
11999
  /**
11927
12000
  * @internal
@@ -11951,6 +12024,7 @@ Expected function or array of functions, received type ${typeof value}.`
11951
12024
  _removeChildStyle(comp) {
11952
12025
  {
11953
12026
  this._styleChildren.delete(comp);
12027
+ this._styleAnchors.delete(comp);
11954
12028
  if (this._childStyles && comp.__hmrId) {
11955
12029
  const oldStyles = this._childStyles.get(comp.__hmrId);
11956
12030
  if (oldStyles) {