@vue/runtime-dom 3.5.29 → 3.5.31

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.31
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) {
@@ -1529,7 +1576,8 @@ const vModelText = {
1529
1576
  if (elValue === newValue) {
1530
1577
  return;
1531
1578
  }
1532
- if (document.activeElement === el && el.type !== "range") {
1579
+ const rootNode = el.getRootNode();
1580
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
1533
1581
  if (lazy && value === oldValue) {
1534
1582
  return;
1535
1583
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.29
2
+ * @vue/runtime-dom v3.5.31
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
  },
@@ -1875,16 +1882,16 @@ var VueRuntimeDOM = (function (exports) {
1875
1882
  return ret;
1876
1883
  }
1877
1884
  class ObjectRefImpl {
1878
- constructor(_object, _key, _defaultValue) {
1885
+ constructor(_object, key, _defaultValue) {
1879
1886
  this._object = _object;
1880
- this._key = _key;
1881
1887
  this._defaultValue = _defaultValue;
1882
1888
  this["__v_isRef"] = true;
1883
1889
  this._value = void 0;
1890
+ this._key = isSymbol(key) ? key : String(key);
1884
1891
  this._raw = toRaw(_object);
1885
1892
  let shallow = true;
1886
1893
  let obj = _object;
1887
- if (!isArray(_object) || !isIntegerKey(String(_key))) {
1894
+ if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
1888
1895
  do {
1889
1896
  shallow = !isProxy(obj) || isShallow(obj);
1890
1897
  } while (shallow && (obj = obj["__v_raw"]));
@@ -2684,6 +2691,13 @@ var VueRuntimeDOM = (function (exports) {
2684
2691
  }
2685
2692
 
2686
2693
  let isHmrUpdating = false;
2694
+ const setHmrUpdating = (v) => {
2695
+ try {
2696
+ return isHmrUpdating;
2697
+ } finally {
2698
+ isHmrUpdating = v;
2699
+ }
2700
+ };
2687
2701
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
2688
2702
  {
2689
2703
  getGlobalThis().__VUE_HMR_RUNTIME__ = {
@@ -3242,9 +3256,10 @@ var VueRuntimeDOM = (function (exports) {
3242
3256
  mount(container, mainAnchor);
3243
3257
  updateCssVars(n2, true);
3244
3258
  }
3245
- if (isTeleportDeferred(n2.props)) {
3259
+ if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) {
3246
3260
  n2.el.__isMounted = false;
3247
3261
  queuePostRenderEffect(() => {
3262
+ if (n2.el.__isMounted !== false) return;
3248
3263
  mountToTarget();
3249
3264
  delete n2.el.__isMounted;
3250
3265
  }, parentSuspense);
@@ -3252,7 +3267,12 @@ var VueRuntimeDOM = (function (exports) {
3252
3267
  mountToTarget();
3253
3268
  }
3254
3269
  } else {
3255
- if (isTeleportDeferred(n2.props) && n1.el.__isMounted === false) {
3270
+ n2.el = n1.el;
3271
+ n2.targetStart = n1.targetStart;
3272
+ const mainAnchor = n2.anchor = n1.anchor;
3273
+ const target = n2.target = n1.target;
3274
+ const targetAnchor = n2.targetAnchor = n1.targetAnchor;
3275
+ if (n1.el.__isMounted === false) {
3256
3276
  queuePostRenderEffect(() => {
3257
3277
  TeleportImpl.process(
3258
3278
  n1,
@@ -3269,11 +3289,6 @@ var VueRuntimeDOM = (function (exports) {
3269
3289
  }, parentSuspense);
3270
3290
  return;
3271
3291
  }
3272
- n2.el = n1.el;
3273
- n2.targetStart = n1.targetStart;
3274
- const mainAnchor = n2.anchor = n1.anchor;
3275
- const target = n2.target = n1.target;
3276
- const targetAnchor = n2.targetAnchor = n1.targetAnchor;
3277
3292
  const wasDisabled = isTeleportDisabled(n1.props);
3278
3293
  const currentContainer = wasDisabled ? container : target;
3279
3294
  const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
@@ -3736,7 +3751,7 @@ var VueRuntimeDOM = (function (exports) {
3736
3751
  callHook(hook, [el]);
3737
3752
  },
3738
3753
  enter(el) {
3739
- if (leavingVNodesCache[key] === vnode) return;
3754
+ if (!isHmrUpdating && leavingVNodesCache[key] === vnode) return;
3740
3755
  let hook = onEnter;
3741
3756
  let afterHook = onAfterEnter;
3742
3757
  let cancelHook = onEnterCancelled;
@@ -5367,12 +5382,16 @@ If this is a native custom element, make sure to exclude it from component resol
5367
5382
  );
5368
5383
  }
5369
5384
  } 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]);
5385
+ if (!Number.isInteger(source) || source < 0) {
5386
+ warn$1(
5387
+ `The v-for range expects a positive integer value but got ${source}.`
5388
+ );
5389
+ ret = [];
5390
+ } else {
5391
+ ret = new Array(source);
5392
+ for (let i = 0; i < source; i++) {
5393
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
5394
+ }
5376
5395
  }
5377
5396
  } else if (isObject(source)) {
5378
5397
  if (source[Symbol.iterator]) {
@@ -5823,6 +5842,7 @@ If this is a native custom element, make sure to exclude it from component resol
5823
5842
  }
5824
5843
  function withAsyncContext(getAwaitable) {
5825
5844
  const ctx = getCurrentInstance();
5845
+ const inSSRSetup = isInSSRComponentSetup;
5826
5846
  if (!ctx) {
5827
5847
  warn$1(
5828
5848
  `withAsyncContext called without active current instance. This is likely a bug.`
@@ -5830,13 +5850,25 @@ If this is a native custom element, make sure to exclude it from component resol
5830
5850
  }
5831
5851
  let awaitable = getAwaitable();
5832
5852
  unsetCurrentInstance();
5853
+ if (inSSRSetup) {
5854
+ setInSSRSetupState(false);
5855
+ }
5856
+ const restore = () => {
5857
+ setCurrentInstance(ctx);
5858
+ if (inSSRSetup) {
5859
+ setInSSRSetupState(true);
5860
+ }
5861
+ };
5833
5862
  const cleanup = () => {
5834
5863
  if (getCurrentInstance() !== ctx) ctx.scope.off();
5835
5864
  unsetCurrentInstance();
5865
+ if (inSSRSetup) {
5866
+ setInSSRSetupState(false);
5867
+ }
5836
5868
  };
5837
5869
  if (isPromise(awaitable)) {
5838
5870
  awaitable = awaitable.catch((e) => {
5839
- setCurrentInstance(ctx);
5871
+ restore();
5840
5872
  Promise.resolve().then(() => Promise.resolve().then(cleanup));
5841
5873
  throw e;
5842
5874
  });
@@ -5844,7 +5876,7 @@ If this is a native custom element, make sure to exclude it from component resol
5844
5876
  return [
5845
5877
  awaitable,
5846
5878
  () => {
5847
- setCurrentInstance(ctx);
5879
+ restore();
5848
5880
  Promise.resolve().then(cleanup);
5849
5881
  }
5850
5882
  ];
@@ -6954,11 +6986,12 @@ If you want to remount the same app, move your app creation logic into a factory
6954
6986
  }
6955
6987
  return nextProp !== prevProp;
6956
6988
  }
6957
- function updateHOCHostEl({ vnode, parent }, el) {
6989
+ function updateHOCHostEl({ vnode, parent, suspense }, el) {
6958
6990
  while (parent) {
6959
6991
  const root = parent.subTree;
6960
6992
  if (root.suspense && root.suspense.activeBranch === vnode) {
6961
- root.el = vnode.el;
6993
+ root.suspense.vnode.el = root.el = el;
6994
+ vnode = root;
6962
6995
  }
6963
6996
  if (root === vnode) {
6964
6997
  (vnode = parent.vnode).el = el;
@@ -6967,6 +7000,9 @@ If you want to remount the same app, move your app creation logic into a factory
6967
7000
  break;
6968
7001
  }
6969
7002
  }
7003
+ if (suspense && suspense.activeBranch === vnode) {
7004
+ suspense.vnode.el = el;
7005
+ }
6970
7006
  }
6971
7007
 
6972
7008
  const internalObjectProto = {};
@@ -7808,10 +7844,17 @@ If you want to remount the same app, move your app creation logic into a factory
7808
7844
  }
7809
7845
  hostInsert(el, container, anchor);
7810
7846
  if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
7847
+ const isHmr = isHmrUpdating;
7811
7848
  queuePostRenderEffect(() => {
7812
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7813
- needCallTransitionHooks && transition.enter(el);
7814
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7849
+ let prev;
7850
+ prev = setHmrUpdating(isHmr);
7851
+ try {
7852
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7853
+ needCallTransitionHooks && transition.enter(el);
7854
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7855
+ } finally {
7856
+ setHmrUpdating(prev);
7857
+ }
7815
7858
  }, parentSuspense);
7816
7859
  }
7817
7860
  };
@@ -8216,7 +8259,10 @@ If you want to remount the same app, move your app creation logic into a factory
8216
8259
  }
8217
8260
  } else {
8218
8261
  if (root.ce && root.ce._hasShadowRoot()) {
8219
- root.ce._injectChildStyle(type);
8262
+ root.ce._injectChildStyle(
8263
+ type,
8264
+ instance.parent ? instance.parent.type : void 0
8265
+ );
8220
8266
  }
8221
8267
  {
8222
8268
  startMeasure(instance, `render`);
@@ -8729,7 +8775,8 @@ If you want to remount the same app, move your app creation logic into a factory
8729
8775
  shapeFlag,
8730
8776
  patchFlag,
8731
8777
  dirs,
8732
- cacheIndex
8778
+ cacheIndex,
8779
+ memo
8733
8780
  } = vnode;
8734
8781
  if (patchFlag === -2) {
8735
8782
  optimized = false;
@@ -8791,10 +8838,14 @@ If you want to remount the same app, move your app creation logic into a factory
8791
8838
  remove(vnode);
8792
8839
  }
8793
8840
  }
8794
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
8841
+ const shouldInvalidateMemo = memo != null && cacheIndex == null;
8842
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) {
8795
8843
  queuePostRenderEffect(() => {
8796
8844
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
8797
8845
  shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
8846
+ if (shouldInvalidateMemo) {
8847
+ vnode.el = null;
8848
+ }
8798
8849
  }, parentSuspense);
8799
8850
  }
8800
8851
  };
@@ -9348,6 +9399,7 @@ If you want to remount the same app, move your app creation logic into a factory
9348
9399
  pendingId: suspenseId++,
9349
9400
  timeout: typeof timeout === "number" ? timeout : -1,
9350
9401
  activeBranch: null,
9402
+ isFallbackMountPending: false,
9351
9403
  pendingBranch: null,
9352
9404
  isInFallback: !isHydrating,
9353
9405
  isHydrating,
@@ -9397,7 +9449,7 @@ If you want to remount the same app, move your app creation logic into a factory
9397
9449
  }
9398
9450
  };
9399
9451
  }
9400
- if (activeBranch) {
9452
+ if (activeBranch && !suspense.isFallbackMountPending) {
9401
9453
  if (parentNode(activeBranch.el) === container2) {
9402
9454
  anchor = next(activeBranch);
9403
9455
  }
@@ -9410,6 +9462,7 @@ If you want to remount the same app, move your app creation logic into a factory
9410
9462
  move(pendingBranch, container2, anchor, 0);
9411
9463
  }
9412
9464
  }
9465
+ suspense.isFallbackMountPending = false;
9413
9466
  setActiveBranch(suspense, pendingBranch);
9414
9467
  suspense.pendingBranch = null;
9415
9468
  suspense.isInFallback = false;
@@ -9445,6 +9498,7 @@ If you want to remount the same app, move your app creation logic into a factory
9445
9498
  triggerEvent(vnode2, "onFallback");
9446
9499
  const anchor2 = next(activeBranch);
9447
9500
  const mountFallback = () => {
9501
+ suspense.isFallbackMountPending = false;
9448
9502
  if (!suspense.isInFallback) {
9449
9503
  return;
9450
9504
  }
@@ -9464,6 +9518,7 @@ If you want to remount the same app, move your app creation logic into a factory
9464
9518
  };
9465
9519
  const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
9466
9520
  if (delayEnter) {
9521
+ suspense.isFallbackMountPending = true;
9467
9522
  activeBranch.transition.afterLeave = mountFallback;
9468
9523
  }
9469
9524
  suspense.isInFallback = true;
@@ -10014,6 +10069,10 @@ Component that was made reactive: `,
10014
10069
  const incoming = toMerge[key];
10015
10070
  if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
10016
10071
  ret[key] = existing ? [].concat(existing, incoming) : incoming;
10072
+ } else if (incoming == null && existing == null && // mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
10073
+ // the model listener.
10074
+ !isModelListener(key)) {
10075
+ ret[key] = incoming;
10017
10076
  }
10018
10077
  } else if (key !== "") {
10019
10078
  ret[key] = toMerge[key];
@@ -10684,7 +10743,7 @@ Component that was made reactive: `,
10684
10743
  return true;
10685
10744
  }
10686
10745
 
10687
- const version = "3.5.29";
10746
+ const version = "3.5.31";
10688
10747
  const warn = warn$1 ;
10689
10748
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10690
10749
  const devtools = devtools$1 ;
@@ -11462,7 +11521,9 @@ Expected function or array of functions, received type ${typeof value}.`
11462
11521
  }
11463
11522
  } else if (
11464
11523
  // #11081 force set props for possible async custom element
11465
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
11524
+ el._isVueCE && // #12408 check if it's declared prop or it's async custom element
11525
+ (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
11526
+ el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
11466
11527
  ) {
11467
11528
  patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
11468
11529
  } else {
@@ -11510,6 +11571,17 @@ Expected function or array of functions, received type ${typeof value}.`
11510
11571
  }
11511
11572
  return key in el;
11512
11573
  }
11574
+ function shouldSetAsPropForVueCE(el, key) {
11575
+ const props = (
11576
+ // @ts-expect-error _def is private
11577
+ el._def.props
11578
+ );
11579
+ if (!props) {
11580
+ return false;
11581
+ }
11582
+ const camelKey = camelize(key);
11583
+ return Array.isArray(props) ? props.some((prop) => camelize(prop) === camelKey) : Object.keys(props).some((prop) => camelize(prop) === camelKey);
11584
+ }
11513
11585
 
11514
11586
  const REMOVAL = {};
11515
11587
  // @__NO_SIDE_EFFECTS__
@@ -11554,6 +11626,7 @@ Expected function or array of functions, received type ${typeof value}.`
11554
11626
  this._dirty = false;
11555
11627
  this._numberProps = null;
11556
11628
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11629
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
11557
11630
  this._ob = null;
11558
11631
  if (this.shadowRoot && _createApp !== createApp) {
11559
11632
  this._root = this.shadowRoot;
@@ -11582,7 +11655,8 @@ Expected function or array of functions, received type ${typeof value}.`
11582
11655
  }
11583
11656
  this._connected = true;
11584
11657
  let parent = this;
11585
- while (parent = parent && (parent.parentNode || parent.host)) {
11658
+ while (parent = parent && // #12479 should check assignedSlot first to get correct parent
11659
+ (parent.assignedSlot || parent.parentNode || parent.host)) {
11586
11660
  if (parent instanceof VueElement) {
11587
11661
  this._parent = parent;
11588
11662
  break;
@@ -11804,6 +11878,7 @@ Expected function or array of functions, received type ${typeof value}.`
11804
11878
  this._styles.forEach((s) => this._root.removeChild(s));
11805
11879
  this._styles.length = 0;
11806
11880
  }
11881
+ this._styleAnchors.delete(this._def);
11807
11882
  this._applyStyles(newStyles);
11808
11883
  this._instance = null;
11809
11884
  this._update();
@@ -11828,7 +11903,7 @@ Expected function or array of functions, received type ${typeof value}.`
11828
11903
  }
11829
11904
  return vnode;
11830
11905
  }
11831
- _applyStyles(styles, owner) {
11906
+ _applyStyles(styles, owner, parentComp) {
11832
11907
  if (!styles) return;
11833
11908
  if (owner) {
11834
11909
  if (owner === this._def || this._styleChildren.has(owner)) {
@@ -11837,11 +11912,19 @@ Expected function or array of functions, received type ${typeof value}.`
11837
11912
  this._styleChildren.add(owner);
11838
11913
  }
11839
11914
  const nonce = this._nonce;
11915
+ const root = this.shadowRoot;
11916
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
11917
+ let last = null;
11840
11918
  for (let i = styles.length - 1; i >= 0; i--) {
11841
11919
  const s = document.createElement("style");
11842
11920
  if (nonce) s.setAttribute("nonce", nonce);
11843
11921
  s.textContent = styles[i];
11844
- this.shadowRoot.prepend(s);
11922
+ root.insertBefore(s, last || insertionAnchor);
11923
+ last = s;
11924
+ if (i === 0) {
11925
+ if (!parentComp) this._styleAnchors.set(this._def, s);
11926
+ if (owner) this._styleAnchors.set(owner, s);
11927
+ }
11845
11928
  {
11846
11929
  if (owner) {
11847
11930
  if (owner.__hmrId) {
@@ -11858,6 +11941,28 @@ Expected function or array of functions, received type ${typeof value}.`
11858
11941
  }
11859
11942
  }
11860
11943
  }
11944
+ _getStyleAnchor(comp) {
11945
+ if (!comp) {
11946
+ return null;
11947
+ }
11948
+ const anchor = this._styleAnchors.get(comp);
11949
+ if (anchor && anchor.parentNode === this.shadowRoot) {
11950
+ return anchor;
11951
+ }
11952
+ if (anchor) {
11953
+ this._styleAnchors.delete(comp);
11954
+ }
11955
+ return null;
11956
+ }
11957
+ _getRootStyleInsertionAnchor(root) {
11958
+ for (let i = 0; i < root.childNodes.length; i++) {
11959
+ const node = root.childNodes[i];
11960
+ if (!(node instanceof HTMLStyleElement)) {
11961
+ return node;
11962
+ }
11963
+ }
11964
+ return null;
11965
+ }
11861
11966
  /**
11862
11967
  * Only called when shadowRoot is false
11863
11968
  */
@@ -11920,8 +12025,8 @@ Expected function or array of functions, received type ${typeof value}.`
11920
12025
  /**
11921
12026
  * @internal
11922
12027
  */
11923
- _injectChildStyle(comp) {
11924
- this._applyStyles(comp.styles, comp);
12028
+ _injectChildStyle(comp, parentComp) {
12029
+ this._applyStyles(comp.styles, comp, parentComp);
11925
12030
  }
11926
12031
  /**
11927
12032
  * @internal
@@ -11951,6 +12056,7 @@ Expected function or array of functions, received type ${typeof value}.`
11951
12056
  _removeChildStyle(comp) {
11952
12057
  {
11953
12058
  this._styleChildren.delete(comp);
12059
+ this._styleAnchors.delete(comp);
11954
12060
  if (this._childStyles && comp.__hmrId) {
11955
12061
  const oldStyles = this._childStyles.get(comp.__hmrId);
11956
12062
  if (oldStyles) {
@@ -12197,7 +12303,8 @@ Expected function or array of functions, received type ${typeof value}.`
12197
12303
  if (elValue === newValue) {
12198
12304
  return;
12199
12305
  }
12200
- if (document.activeElement === el && el.type !== "range") {
12306
+ const rootNode = el.getRootNode();
12307
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
12201
12308
  if (lazy && value === oldValue) {
12202
12309
  return;
12203
12310
  }