vue 3.6.0-rc.2 → 3.6.0-rc.4

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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.6.0-rc.2
2
+ * vue v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.6.0-rc.2
2
+ * vue v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.6.0-rc.2
2
+ * vue v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -318,7 +318,7 @@ const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
318
318
  /**
319
319
  * The full list is needed during SSR to produce the correct initial markup.
320
320
  */
321
- const isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + ",async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");
321
+ const isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + ",async,autofocus,autoplay,controls,default,defer,disabled,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");
322
322
  /**
323
323
  * Boolean attributes should be included if the value is truthy or ''.
324
324
  * e.g. `<select multiple>` compiles to `{ multiple: '' }`
@@ -2600,7 +2600,7 @@ function queueFlush() {
2600
2600
  function queuePostFlushCb(jobs, id = Infinity) {
2601
2601
  if (!isArray(jobs)) if (activePostJobs && id === -1) activePostJobs.splice(postFlushIndex, 0, jobs);
2602
2602
  else queueJobWorker(jobs, id, postJobs, postJobs.length, 0);
2603
- else for (const job of jobs) queueJobWorker(job, id, postJobs, postJobs.length, 0);
2603
+ else for (let i = 0; i < jobs.length; i++) queueJobWorker(jobs[i], id, postJobs, postJobs.length, 0);
2604
2604
  queueFlush();
2605
2605
  }
2606
2606
  function flushPreFlushCbs(instance, seen) {
@@ -2621,7 +2621,7 @@ function flushPreFlushCbs(instance, seen) {
2621
2621
  function flushPostFlushCbs(seen) {
2622
2622
  if (postJobs.length) {
2623
2623
  if (activePostJobs) {
2624
- activePostJobs.push(...postJobs);
2624
+ for (let i = 0; i < postJobs.length; i++) activePostJobs.push(postJobs[i]);
2625
2625
  postJobs.length = 0;
2626
2626
  return;
2627
2627
  }
@@ -3434,49 +3434,16 @@ const BaseTransitionImpl = {
3434
3434
  setup(props, { slots }) {
3435
3435
  const instance = getCurrentInstance();
3436
3436
  const state = useTransitionState();
3437
+ let resumeAfterLeave;
3437
3438
  return () => {
3438
- const children = slots.default && getTransitionRawChildren(slots.default(), true);
3439
- const child = children && children.length ? findNonCommentChild(children) : instance.subTree ? createCommentVNode() : void 0;
3439
+ const child = resolveTransitionChild(slots.default && slots.default(), !!instance.subTree);
3440
3440
  if (!child) return;
3441
3441
  const rawProps = /* @__PURE__ */ toRaw(props);
3442
3442
  const { mode } = rawProps;
3443
3443
  checkTransitionMode(mode);
3444
- if (state.isLeaving) return emptyPlaceholder(child);
3445
- const innerChild = getInnerChild$1(child);
3446
- if (!innerChild) return emptyPlaceholder(child);
3447
- let enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance, (hooks) => enterHooks = hooks);
3448
- if (innerChild.type !== Comment) setTransitionHooks(innerChild, enterHooks);
3449
- let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
3450
- if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(oldInnerChild, innerChild) && recursiveGetSubtree(instance).type !== Comment) {
3451
- let leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
3452
- setTransitionHooks(oldInnerChild, leavingHooks);
3453
- if (mode === "out-in" && innerChild.type !== Comment) {
3454
- state.isLeaving = true;
3455
- leavingHooks.afterLeave = () => {
3456
- state.isLeaving = false;
3457
- if (!(instance.job.flags & 4)) instance.update();
3458
- delete leavingHooks.afterLeave;
3459
- oldInnerChild = void 0;
3460
- };
3461
- return emptyPlaceholder(child);
3462
- } else if (mode === "in-out" && innerChild.type !== Comment) leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
3463
- const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
3464
- leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
3465
- el[leaveCbKey] = () => {
3466
- earlyRemove();
3467
- el[leaveCbKey] = void 0;
3468
- delete enterHooks.delayedLeave;
3469
- oldInnerChild = void 0;
3470
- };
3471
- enterHooks.delayedLeave = () => {
3472
- delayedLeave();
3473
- delete enterHooks.delayedLeave;
3474
- oldInnerChild = void 0;
3475
- };
3476
- };
3477
- else oldInnerChild = void 0;
3478
- } else if (oldInnerChild) oldInnerChild = void 0;
3479
- return child;
3444
+ return prepareTransitionSwitch(instance.subTree, child, rawProps, state, instance, mode === "out-in" ? resumeAfterLeave || (resumeAfterLeave = () => {
3445
+ if (!(instance.job.flags & 4)) instance.update();
3446
+ }) : NOOP);
3480
3447
  };
3481
3448
  }
3482
3449
  };
@@ -3618,15 +3585,91 @@ function getInnerChild$1(vnode) {
3618
3585
  if (shapeFlag & 32 && isFunction(children.default)) return children.default();
3619
3586
  }
3620
3587
  }
3588
+ function resolveTransitionChild(children, renderEmpty = false) {
3589
+ const branches = children && getTransitionRawChildren(children, true);
3590
+ return branches && branches.length ? findNonCommentChild(branches) : renderEmpty ? createCommentVNode() : void 0;
3591
+ }
3592
+ /**
3593
+ * @internal
3594
+ */
3595
+ function prepareTransitionSwitch(previous, next, props, state, instance, resumeAfterLeave, delayedLeaveSource) {
3596
+ if (state.isLeaving) return emptyPlaceholder(next);
3597
+ const nextInner = getInnerChild$1(next);
3598
+ if (!nextInner) return emptyPlaceholder(next);
3599
+ let enterHooks = resolveTransitionHooks(nextInner, props, state, instance, (hooks) => {
3600
+ if (delayedLeaveSource) forwardDelayedLeave(hooks, delayedLeaveSource);
3601
+ enterHooks = hooks;
3602
+ });
3603
+ if (delayedLeaveSource) forwardDelayedLeave(enterHooks, delayedLeaveSource);
3604
+ if (nextInner.type !== Comment) setTransitionHooks(nextInner, enterHooks);
3605
+ const mode = props.mode;
3606
+ const previousInner = previous && getInnerChild$1(previous);
3607
+ if (previous && previousInner && previousInner.type !== Comment && !isSameVNodeType(previousInner, nextInner) && (!previous.component || recursiveGetSubtree(previous.component).type !== Comment)) {
3608
+ const leavingHooks = prepareLeavingTransitionHooks(previousInner, props, state, instance);
3609
+ if (nextInner.type !== Comment && (mode === "out-in" || mode === "in-out") && applyTransitionModeSwitch(previousInner, leavingHooks, mode === "in-out" ? () => enterHooks : void 0, props, state, resumeAfterLeave)) return emptyPlaceholder(next);
3610
+ }
3611
+ return next;
3612
+ }
3613
+ function forwardDelayedLeave(hooks, source) {
3614
+ const delayedLeave = source && source.delayedLeave;
3615
+ if (!delayedLeave) return;
3616
+ hooks.delayedLeave = () => {
3617
+ if (source.delayedLeave === delayedLeave) delayedLeave();
3618
+ delete hooks.delayedLeave;
3619
+ };
3620
+ }
3621
+ function prepareLeavingTransitionHooks(previousInner, props, state, instance) {
3622
+ return setTransitionHooks(previousInner, resolveTransitionHooks(previousInner, props, state, instance));
3623
+ }
3624
+ function applyTransitionModeSwitch(leavingVNode, leavingHooks, getEnterHooks, props, state, resumeAfterLeave) {
3625
+ if (props.mode === "out-in") {
3626
+ state.isLeaving = true;
3627
+ leavingHooks.afterLeave = () => {
3628
+ state.isLeaving = false;
3629
+ resumeAfterLeave();
3630
+ delete leavingHooks.afterLeave;
3631
+ };
3632
+ return true;
3633
+ } else if (props.mode === "in-out" && getEnterHooks) {
3634
+ let delayedLeavingVNode = leavingVNode;
3635
+ leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
3636
+ const enterHooks = getEnterHooks();
3637
+ if (!enterHooks) {
3638
+ delayedLeave();
3639
+ return;
3640
+ }
3641
+ const vnode = delayedLeavingVNode;
3642
+ const leavingVNodesCache = getLeavingNodesForType(state, vnode);
3643
+ leavingVNodesCache[String(vnode.key)] = vnode;
3644
+ el[leaveCbKey] = () => {
3645
+ earlyRemove();
3646
+ el[leaveCbKey] = void 0;
3647
+ delete enterHooks.delayedLeave;
3648
+ delayedLeavingVNode = void 0;
3649
+ };
3650
+ enterHooks.delayedLeave = () => {
3651
+ delayedLeave();
3652
+ delete enterHooks.delayedLeave;
3653
+ delayedLeavingVNode = void 0;
3654
+ };
3655
+ };
3656
+ }
3657
+ return false;
3658
+ }
3621
3659
  function setTransitionHooks(vnode, hooks) {
3622
3660
  if (vnode.shapeFlag & 6 && vnode.component) {
3623
3661
  vnode.transition = hooks;
3624
3662
  if (isVaporComponent(vnode.type)) getVaporInterface(vnode.component, vnode).setTransitionHooks(vnode.component, hooks);
3625
- else setTransitionHooks(vnode.component.subTree, hooks);
3663
+ else {
3664
+ const subTree = vnode.component.subTree;
3665
+ return setTransitionHooks(isTeleport(subTree.type) ? getInnerChild$1(subTree) || subTree : subTree, hooks);
3666
+ }
3626
3667
  } else if (vnode.shapeFlag & 128) {
3627
- vnode.ssContent.transition = hooks.clone(vnode.ssContent);
3628
- vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
3668
+ const contentHooks = vnode.ssContent.transition = hooks.clone(vnode.ssContent);
3669
+ const fallbackHooks = vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
3670
+ return vnode.suspense && vnode.suspense.activeBranch === vnode.ssFallback ? fallbackHooks : contentHooks;
3629
3671
  } else vnode.transition = hooks;
3672
+ return hooks;
3630
3673
  }
3631
3674
  function getTransitionRawChildren(children, keepComment = false, parentKey) {
3632
3675
  let ret = [];
@@ -3978,7 +4021,10 @@ function createHydrationFunctions(rendererInternals) {
3978
4021
  const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
3979
4022
  for (const key in props) {
3980
4023
  if (!(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) logMismatchError();
3981
- if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) patchProp(el, key, null, props[key], namespace, parentComponent);
4024
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
4025
+ if (isUnchangedResourceProp(el, key, props[key])) continue;
4026
+ patchProp(el, key, null, props[key], namespace, parentComponent);
4027
+ }
3982
4028
  }
3983
4029
  }
3984
4030
  let vnodeHooks;
@@ -4087,6 +4133,16 @@ const isTemplateNode$1 = (node) => {
4087
4133
  /**
4088
4134
  * Dev only
4089
4135
  */
4136
+ const resourceProps = /* @__PURE__ */ new Set([
4137
+ "src",
4138
+ "srcset",
4139
+ "href",
4140
+ "poster"
4141
+ ]);
4142
+ function isUnchangedResourceProp(el, key, clientValue) {
4143
+ if (!resourceProps.has(key)) return false;
4144
+ return el.getAttribute(key) === (clientValue == null ? null : `${clientValue}`);
4145
+ }
4090
4146
  function propHasMismatch(el, key, clientValue, vnode, instance) {
4091
4147
  let mismatchType;
4092
4148
  let mismatchKey;
@@ -4127,7 +4183,10 @@ function propHasMismatch(el, key, clientValue, vnode, instance) {
4127
4183
  function getAttributeMismatch(el, key, clientValue) {
4128
4184
  let actual;
4129
4185
  let expected;
4130
- if (isBooleanAttr(key)) {
4186
+ if (key === "hidden") {
4187
+ actual = normalizeHiddenValue(el.getAttribute(key));
4188
+ expected = normalizeHiddenValue(clientValue);
4189
+ } else if (isBooleanAttr(key)) {
4131
4190
  actual = el.hasAttribute(key);
4132
4191
  expected = includeBooleanAttr(clientValue);
4133
4192
  } else if (clientValue == null) {
@@ -4155,6 +4214,11 @@ function warnPropMismatch(el, mismatchKey, mismatchType, actual, expected) {
4155
4214
  }
4156
4215
  return false;
4157
4216
  }
4217
+ function normalizeHiddenValue(value) {
4218
+ if (!isRenderableAttrValue(value)) return false;
4219
+ if (isString(value)) return value.toLowerCase() === "until-found" ? "until-found" : "";
4220
+ return includeBooleanAttr(value) ? "" : false;
4221
+ }
4158
4222
  function toClassSet(str) {
4159
4223
  return new Set(str.trim().split(/\s+/));
4160
4224
  }
@@ -4815,7 +4879,8 @@ function createSlots(slots, dynamicSlots) {
4815
4879
  * Compiler runtime helper for rendering `<slot/>`
4816
4880
  * @private
4817
4881
  */
4818
- function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
4882
+ function renderSlot(slots, name, props, fallback, noSlotted, branchKey) {
4883
+ if (props == null) props = {};
4819
4884
  let slot = slots[name];
4820
4885
  if (fallback) fallback.__vdom = true;
4821
4886
  const vaporSlot = slot && (slot.__vs || (slot.__vapor ? slot : null));
@@ -5868,8 +5933,9 @@ function renderComponentRoot(instance) {
5868
5933
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
5869
5934
  }
5870
5935
  if (vnode.transition) {
5871
- if (!isElementRoot(root)) warn$1("Component inside <Transition> renders non-element root node that cannot be animated.");
5872
- setTransitionHooks(root, vnode.transition);
5936
+ const child = isTeleport(root.type) ? getInnerChild$1(root) || root : root;
5937
+ if (!isElementRoot(child)) warn$1("Component inside <Transition> renders non-element root node that cannot be animated.");
5938
+ setTransitionHooks(child, vnode.transition);
5873
5939
  }
5874
5940
  if (setRoot) setRoot(root);
5875
5941
  else result = root;
@@ -5929,9 +5995,10 @@ function filterSingleRoot(children, recurse = true) {
5929
5995
  }
5930
5996
  return singleRoot;
5931
5997
  }
5998
+ const isFunctionalFallthroughKey = (key) => key === "class" || key === "style" || isOn(key);
5932
5999
  const getFunctionalFallthrough = (attrs) => {
5933
6000
  let res;
5934
- for (const key in attrs) if (key === "class" || key === "style" || isOn(key)) (res || (res = {}))[key] = attrs[key];
6001
+ for (const key in attrs) if (isFunctionalFallthroughKey(key)) (res || (res = {}))[key] = attrs[key];
5935
6002
  return res;
5936
6003
  };
5937
6004
  const filterModelListeners = (attrs, props) => {
@@ -7416,6 +7483,10 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
7416
7483
  suspense.activeBranch = pendingBranch;
7417
7484
  } else unmount(pendingBranch, parentComponent, suspense);
7418
7485
  suspense.deps = 0;
7486
+ for (let i = 0; i < suspense.effects.length; i++) {
7487
+ const effect = suspense.effects[i];
7488
+ if (effect.flags & 8) queuePostFlushCb(effect);
7489
+ }
7419
7490
  suspense.effects.length = 0;
7420
7491
  suspense.hiddenContainer = createElement("div");
7421
7492
  if (isInFallback) {
@@ -7523,7 +7594,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7523
7594
  let hasUnresolvedAncestor = false;
7524
7595
  while (parent) {
7525
7596
  if (parent.pendingBranch) {
7526
- parent.effects.push(...effects);
7597
+ for (let i = 0; i < effects.length; i++) parent.effects.push(effects[i]);
7527
7598
  hasUnresolvedAncestor = true;
7528
7599
  break;
7529
7600
  }
@@ -7793,9 +7864,24 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
7793
7864
  if (shapeFlag & 128) type.normalize(vnode);
7794
7865
  } else if (children) vnode.shapeFlag |= isString(children) ? 8 : 16;
7795
7866
  if (vnode.key !== vnode.key) warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
7867
+ if (props && vnode.shapeFlag & 1) {
7868
+ const overwritingProp = props.innerHTML != null ? "innerHTML" : props.textContent != null ? "textContent" : null;
7869
+ if (overwritingProp && hasContentChildren(vnode.children)) warn$1(`The \`${overwritingProp}\` prop on <${vnode.type}> will override its children. Remove either the \`${overwritingProp}\` prop or the children.`);
7870
+ }
7796
7871
  if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock && (vnode.patchFlag > 0 || shapeFlag & 6) && vnode.patchFlag !== 32) currentBlock.push(vnode);
7797
7872
  return vnode;
7798
7873
  }
7874
+ /**
7875
+ * dev only
7876
+ * Whether children would actually render something. Empty text and empty
7877
+ * arrays are ignored, mirroring the compiler's `node.children.length` check
7878
+ * for `v-html` / `v-text`.
7879
+ */
7880
+ function hasContentChildren(children) {
7881
+ if (isString(children)) return children !== "";
7882
+ if (isArray(children)) return children.length > 0;
7883
+ return false;
7884
+ }
7799
7885
  const createVNode = createVNodeWithArgsTransform;
7800
7886
  function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
7801
7887
  if (!type || type === NULL_DYNAMIC_COMPONENT) {
@@ -8184,7 +8270,12 @@ function setupStatefulComponent(instance, isSSR) {
8184
8270
  };
8185
8271
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
8186
8272
  if (isSSR) return setupResult.then((resolvedResult) => {
8187
- handleSetupResult(instance, resolvedResult, isSSR);
8273
+ setInSSRSetupState(true);
8274
+ try {
8275
+ handleSetupResult(instance, resolvedResult, isSSR);
8276
+ } finally {
8277
+ setInSSRSetupState(false);
8278
+ }
8188
8279
  }).catch((e) => {
8189
8280
  handleError(e, instance, 0);
8190
8281
  });
@@ -8555,7 +8646,7 @@ function isMemoSame(cached, memo) {
8555
8646
  }
8556
8647
  //#endregion
8557
8648
  //#region packages/runtime-core/src/index.ts
8558
- const version = "3.6.0-rc.2";
8649
+ const version = "3.6.0-rc.4";
8559
8650
  const warn = warn$1;
8560
8651
  /**
8561
8652
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -9276,7 +9367,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
9276
9367
  if (!this._instance) if (this._resolved) this._mountComponent(this._def);
9277
9368
  else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => {
9278
9369
  this._pendingResolve = void 0;
9279
- this._resolveDef();
9370
+ if (this.isConnected) return this._resolveDef();
9280
9371
  });
9281
9372
  else this._resolveDef();
9282
9373
  }
@@ -9312,7 +9403,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
9312
9403
  * resolve inner component definition (handle possible async component)
9313
9404
  */
9314
9405
  _resolveDef() {
9315
- if (this._pendingResolve) return;
9406
+ if (this._pendingResolve) return this._pendingResolve;
9316
9407
  for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name);
9317
9408
  this._ob = new MutationObserver(this._processMutations.bind(this));
9318
9409
  this._ob.observe(this, { attributes: true });
@@ -9342,6 +9433,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
9342
9433
  this._def = def;
9343
9434
  resolve(def);
9344
9435
  });
9436
+ return this._pendingResolve;
9345
9437
  } else resolve(this._def);
9346
9438
  }
9347
9439
  _mountComponent(def) {
@@ -9380,14 +9472,17 @@ var VueElementBase = class VueElementBase extends BaseClass {
9380
9472
  const { props } = def;
9381
9473
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
9382
9474
  for (const key of Object.keys(this)) if (key[0] !== "_" && declaredPropKeys.includes(key)) this._setProp(key, this[key]);
9383
- for (const key of declaredPropKeys.map(camelize)) Object.defineProperty(this, key, {
9384
- get() {
9385
- return this._getProp(key);
9386
- },
9387
- set(val) {
9388
- this._setProp(key, val, true, !this._patching);
9389
- }
9390
- });
9475
+ for (const key of declaredPropKeys.map(camelize)) {
9476
+ if (key in Object.getPrototypeOf(this)) warn(`Custom element prop "${key}" conflicts with an existing property on the element and will overwrite it.`);
9477
+ Object.defineProperty(this, key, {
9478
+ get() {
9479
+ return this._getProp(key);
9480
+ },
9481
+ set(val) {
9482
+ this._setProp(key, val, true, !this._patching);
9483
+ }
9484
+ });
9485
+ }
9391
9486
  }
9392
9487
  _setAttr(key) {
9393
9488
  if (key.startsWith("data-v-")) return;
@@ -9803,13 +9898,22 @@ function onCompositionEnd(e) {
9803
9898
  }
9804
9899
  }
9805
9900
  const assignKey = Symbol("_assign");
9901
+ const initialValueKey = Symbol("_initialValue");
9806
9902
  const vModelText = {
9807
9903
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
9904
+ if (el.parentNode) {
9905
+ if (el.type === "text") el[initialValueKey] = el.defaultValue.replace(/[\r\n]/g, "");
9906
+ else if (el.type === "textarea") el[initialValueKey] = el.defaultValue.replace(/\r\n?/g, "\n");
9907
+ }
9808
9908
  el[assignKey] = getModelAssigner(vnode);
9809
9909
  vModelTextInit(el, trim, number || !!(vnode.props && vnode.props.type === "number"), lazy);
9810
9910
  },
9811
- mounted(el, { value }) {
9812
- el.value = value == null ? "" : value;
9911
+ mounted(el, { value, modifiers: { trim, number } }) {
9912
+ const newValue = value == null ? "" : value;
9913
+ const initialValue = el[initialValueKey];
9914
+ delete el[initialValueKey];
9915
+ if (initialValue !== void 0 && (el.type === "text" || el.type === "textarea") && el.value !== initialValue) el[assignKey](castValue(el.value, trim, number));
9916
+ else el.value = newValue;
9813
9917
  },
9814
9918
  beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
9815
9919
  el[assignKey] = getModelAssigner(vnode);
@@ -13119,15 +13223,22 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
13119
13223
  else {
13120
13224
  childBlock = children[0].codegenNode;
13121
13225
  if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
13122
- if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
13226
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
13227
+ if (childBlock.isBlock !== shouldUseBlock) if (childBlock.isBlock) {
13123
13228
  removeHelper(OPEN_BLOCK);
13124
13229
  removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
13125
13230
  } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
13126
- childBlock.isBlock = !isStableFragment;
13231
+ childBlock.isBlock = shouldUseBlock;
13127
13232
  if (childBlock.isBlock) {
13128
13233
  helper(OPEN_BLOCK);
13129
13234
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
13130
- } else helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
13235
+ } else {
13236
+ helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
13237
+ if (childBlock.needsPatch) {
13238
+ var _childBlock$patchFlag;
13239
+ childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
13240
+ }
13241
+ }
13131
13242
  }
13132
13243
  if (memo) {
13133
13244
  const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
@@ -13349,12 +13460,16 @@ const transformElement = (node, context) => {
13349
13460
  let vnodeDynamicProps;
13350
13461
  let dynamicPropNames;
13351
13462
  let vnodeDirectives;
13463
+ let needsPatch = false;
13464
+ let isBlockRequired = false;
13352
13465
  let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
13353
13466
  if (props.length > 0) {
13354
13467
  const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
13355
13468
  vnodeProps = propsBuildResult.props;
13356
13469
  patchFlag = propsBuildResult.patchFlag;
13357
13470
  dynamicPropNames = propsBuildResult.dynamicPropNames;
13471
+ needsPatch = propsBuildResult.needsPatch;
13472
+ isBlockRequired = propsBuildResult.isBlockRequired;
13358
13473
  const directives = propsBuildResult.directives;
13359
13474
  vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
13360
13475
  if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
@@ -13383,7 +13498,10 @@ const transformElement = (node, context) => {
13383
13498
  } else vnodeChildren = node.children;
13384
13499
  }
13385
13500
  if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
13386
- node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
13501
+ const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
13502
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
13503
+ if (needsPatch) vnodeCall.needsPatch = true;
13504
+ if (isBlockRequired) vnodeCall.isBlockRequired = true;
13387
13505
  };
13388
13506
  };
13389
13507
  function resolveComponentType(node, context, ssr = false) {
@@ -13417,6 +13535,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13417
13535
  const runtimeDirectives = [];
13418
13536
  const hasChildren = children.length > 0;
13419
13537
  let shouldUseBlock = false;
13538
+ let isBlockRequired = false;
13420
13539
  let patchFlag = 0;
13421
13540
  let hasRef = false;
13422
13541
  let hasClassBinding = false;
@@ -13441,12 +13560,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13441
13560
  const isEventHandler = isOn(name);
13442
13561
  if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
13443
13562
  if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
13563
+ if (name === "ref") hasRef = true;
13444
13564
  if (isEventHandler && value.type === 14) value = value.arguments[0];
13445
13565
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
13446
- if (name === "ref") hasRef = true;
13447
- else if (name === "class") hasClassBinding = true;
13566
+ if (name === "class") hasClassBinding = true;
13448
13567
  else if (name === "style") hasStyleBinding = true;
13449
- else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
13568
+ else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
13450
13569
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
13451
13570
  } else hasDynamicKeys = true;
13452
13571
  };
@@ -13472,7 +13591,11 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13472
13591
  if (name === "once" || name === "memo") continue;
13473
13592
  if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) continue;
13474
13593
  if (isVOn && ssr) continue;
13475
- if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) shouldUseBlock = true;
13594
+ if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
13595
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
13596
+ shouldUseBlock = true;
13597
+ isBlockRequired = true;
13598
+ }
13476
13599
  if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
13477
13600
  if (!arg && (isVBind || isVOn)) {
13478
13601
  hasDynamicKeys = true;
@@ -13502,7 +13625,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13502
13625
  }
13503
13626
  } else if (!isBuiltInDirective(name)) {
13504
13627
  runtimeDirectives.push(prop);
13505
- if (hasChildren) shouldUseBlock = true;
13628
+ if (hasChildren) {
13629
+ shouldUseBlock = true;
13630
+ isBlockRequired = true;
13631
+ }
13506
13632
  }
13507
13633
  }
13508
13634
  }
@@ -13519,7 +13645,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13519
13645
  if (dynamicPropNames.length) patchFlag |= 8;
13520
13646
  if (hasHydrationEventBinding) patchFlag |= 32;
13521
13647
  }
13522
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) patchFlag |= 512;
13648
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
13649
+ if (!shouldUseBlock && needsPatch) patchFlag |= 512;
13523
13650
  if (!context.inSSR && propsExpression) switch (propsExpression.type) {
13524
13651
  case 15:
13525
13652
  let classKeyIndex = -1;
@@ -13549,7 +13676,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
13549
13676
  directives: runtimeDirectives,
13550
13677
  patchFlag,
13551
13678
  dynamicPropNames,
13552
- shouldUseBlock
13679
+ shouldUseBlock,
13680
+ needsPatch,
13681
+ isBlockRequired
13553
13682
  };
13554
13683
  }
13555
13684
  function dedupeProperties(properties) {