@vue/runtime-core 3.2.38 → 3.2.40

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.
@@ -299,7 +299,9 @@ function queuePostFlushCb(cb) {
299
299
  }
300
300
  queueFlush();
301
301
  }
302
- function flushPreFlushCbs(seen, i = flushIndex) {
302
+ function flushPreFlushCbs(seen,
303
+ // if currently flushing, skip the current job itself
304
+ i = isFlushing ? flushIndex + 1 : 0) {
303
305
  {
304
306
  seen = seen || new Map();
305
307
  }
@@ -2696,7 +2698,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
2696
2698
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
2697
2699
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
2698
2700
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
2699
- injectHook(lifecycle, hook, target);
2701
+ injectHook(lifecycle, (...args) => hook(...args), target);
2700
2702
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
2701
2703
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
2702
2704
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -2919,7 +2921,10 @@ function createSlots(slots, dynamicSlots) {
2919
2921
  slots[slot.name] = slot.key
2920
2922
  ? (...args) => {
2921
2923
  const res = slot.fn(...args);
2922
- res.key = slot.key;
2924
+ // attach branch key so each conditional branch is considered a
2925
+ // different fragment
2926
+ if (res)
2927
+ res.key = slot.key;
2923
2928
  return res;
2924
2929
  }
2925
2930
  : slot.fn;
@@ -4571,7 +4576,7 @@ function createHydrationFunctions(rendererInternals) {
4571
4576
  const isFragmentStart = isComment(node) && node.data === '[';
4572
4577
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
4573
4578
  const { type, ref, shapeFlag, patchFlag } = vnode;
4574
- const domType = node.nodeType;
4579
+ let domType = node.nodeType;
4575
4580
  vnode.el = node;
4576
4581
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
4577
4582
  optimized = false;
@@ -4611,10 +4616,12 @@ function createHydrationFunctions(rendererInternals) {
4611
4616
  }
4612
4617
  break;
4613
4618
  case Static:
4614
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
4615
- nextNode = onMismatch();
4619
+ if (isFragmentStart) {
4620
+ // entire template is static but SSRed as a fragment
4621
+ node = nextSibling(node);
4622
+ domType = node.nodeType;
4616
4623
  }
4617
- else {
4624
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
4618
4625
  // determine anchor, adopt content
4619
4626
  nextNode = node;
4620
4627
  // if the static vnode has its content stripped during build,
@@ -4631,7 +4638,10 @@ function createHydrationFunctions(rendererInternals) {
4631
4638
  }
4632
4639
  nextNode = nextSibling(nextNode);
4633
4640
  }
4634
- return nextNode;
4641
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
4642
+ }
4643
+ else {
4644
+ onMismatch();
4635
4645
  }
4636
4646
  break;
4637
4647
  case Fragment:
@@ -4956,7 +4966,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4956
4966
  {
4957
4967
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
4958
4968
  }
4959
- const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
4969
+ const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, insertStaticContent: hostInsertStaticContent } = options;
4960
4970
  // Note: functions inside this closure should use `const xxx = () => {}`
4961
4971
  // style in order to prevent being inlined by minifiers.
4962
4972
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -5083,46 +5093,44 @@ function baseCreateRenderer(options, createHydrationFns) {
5083
5093
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5084
5094
  let el;
5085
5095
  let vnodeHook;
5086
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
5087
- {
5088
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5089
- // mount children first, since some props may rely on child content
5090
- // being already rendered, e.g. `<select value>`
5091
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
5092
- hostSetElementText(el, vnode.children);
5093
- }
5094
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
5095
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5096
+ const { type, props, shapeFlag, transition, dirs } = vnode;
5097
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5098
+ // mount children first, since some props may rely on child content
5099
+ // being already rendered, e.g. `<select value>`
5100
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
5101
+ hostSetElementText(el, vnode.children);
5102
+ }
5103
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
5104
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5105
+ }
5106
+ if (dirs) {
5107
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
5108
+ }
5109
+ // props
5110
+ if (props) {
5111
+ for (const key in props) {
5112
+ if (key !== 'value' && !shared.isReservedProp(key)) {
5113
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5114
+ }
5096
5115
  }
5097
- if (dirs) {
5098
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
5116
+ /**
5117
+ * Special case for setting value on DOM elements:
5118
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5119
+ * - it needs to be forced (#1471)
5120
+ * #2353 proposes adding another renderer option to configure this, but
5121
+ * the properties affects are so finite it is worth special casing it
5122
+ * here to reduce the complexity. (Special casing it also should not
5123
+ * affect non-DOM renderers)
5124
+ */
5125
+ if ('value' in props) {
5126
+ hostPatchProp(el, 'value', null, props.value);
5099
5127
  }
5100
- // props
5101
- if (props) {
5102
- for (const key in props) {
5103
- if (key !== 'value' && !shared.isReservedProp(key)) {
5104
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5105
- }
5106
- }
5107
- /**
5108
- * Special case for setting value on DOM elements:
5109
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5110
- * - it needs to be forced (#1471)
5111
- * #2353 proposes adding another renderer option to configure this, but
5112
- * the properties affects are so finite it is worth special casing it
5113
- * here to reduce the complexity. (Special casing it also should not
5114
- * affect non-DOM renderers)
5115
- */
5116
- if ('value' in props) {
5117
- hostPatchProp(el, 'value', null, props.value);
5118
- }
5119
- if ((vnodeHook = props.onVnodeBeforeMount)) {
5120
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
5121
- }
5128
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
5129
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
5122
5130
  }
5123
- // scopeId
5124
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5125
5131
  }
5132
+ // scopeId
5133
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5126
5134
  {
5127
5135
  Object.defineProperty(el, '__vnode', {
5128
5136
  value: vnode,
@@ -5308,6 +5316,13 @@ function baseCreateRenderer(options, createHydrationFns) {
5308
5316
  };
5309
5317
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
5310
5318
  if (oldProps !== newProps) {
5319
+ if (oldProps !== shared.EMPTY_OBJ) {
5320
+ for (const key in oldProps) {
5321
+ if (!shared.isReservedProp(key) && !(key in newProps)) {
5322
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5323
+ }
5324
+ }
5325
+ }
5311
5326
  for (const key in newProps) {
5312
5327
  // empty string is not valid prop
5313
5328
  if (shared.isReservedProp(key))
@@ -5319,13 +5334,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5319
5334
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5320
5335
  }
5321
5336
  }
5322
- if (oldProps !== shared.EMPTY_OBJ) {
5323
- for (const key in oldProps) {
5324
- if (!shared.isReservedProp(key) && !(key in newProps)) {
5325
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5326
- }
5327
- }
5328
- }
5329
5337
  if ('value' in newProps) {
5330
5338
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
5331
5339
  }
@@ -6849,7 +6857,10 @@ function normalizeVNode(child) {
6849
6857
  }
6850
6858
  // optimized normalization for template-compiled render fns
6851
6859
  function cloneIfMounted(child) {
6852
- return child.el === null || child.memo ? child : cloneVNode(child);
6860
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
6861
+ child.memo
6862
+ ? child
6863
+ : cloneVNode(child);
6853
6864
  }
6854
6865
  function normalizeChildren(vnode, children) {
6855
6866
  let type = 0;
@@ -7196,7 +7207,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7196
7207
  // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
7197
7208
  // is done by server-renderer
7198
7209
  if (!isSSR && compile && !Component.render) {
7199
- const template = Component.template;
7210
+ const template = Component.template ||
7211
+ resolveMergedOptions(instance).template;
7200
7212
  if (template) {
7201
7213
  {
7202
7214
  startMeasure(instance, `compile`);
@@ -7754,7 +7766,7 @@ function isMemoSame(cached, memo) {
7754
7766
  }
7755
7767
 
7756
7768
  // Core API ------------------------------------------------------------------
7757
- const version = "3.2.38";
7769
+ const version = "3.2.40";
7758
7770
  const _ssrUtils = {
7759
7771
  createComponentInstance,
7760
7772
  setupComponent,
@@ -247,7 +247,9 @@ function queuePostFlushCb(cb) {
247
247
  }
248
248
  queueFlush();
249
249
  }
250
- function flushPreFlushCbs(seen, i = flushIndex) {
250
+ function flushPreFlushCbs(seen,
251
+ // if currently flushing, skip the current job itself
252
+ i = isFlushing ? flushIndex + 1 : 0) {
251
253
  for (; i < queue.length; i++) {
252
254
  const cb = queue[i];
253
255
  if (cb && cb.pre) {
@@ -2179,7 +2181,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
2179
2181
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
2180
2182
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
2181
2183
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
2182
- injectHook(lifecycle, hook, target);
2184
+ injectHook(lifecycle, (...args) => hook(...args), target);
2183
2185
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
2184
2186
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
2185
2187
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -2382,7 +2384,10 @@ function createSlots(slots, dynamicSlots) {
2382
2384
  slots[slot.name] = slot.key
2383
2385
  ? (...args) => {
2384
2386
  const res = slot.fn(...args);
2385
- res.key = slot.key;
2387
+ // attach branch key so each conditional branch is considered a
2388
+ // different fragment
2389
+ if (res)
2390
+ res.key = slot.key;
2386
2391
  return res;
2387
2392
  }
2388
2393
  : slot.fn;
@@ -3589,7 +3594,7 @@ function createHydrationFunctions(rendererInternals) {
3589
3594
  const isFragmentStart = isComment(node) && node.data === '[';
3590
3595
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
3591
3596
  const { type, ref, shapeFlag, patchFlag } = vnode;
3592
- const domType = node.nodeType;
3597
+ let domType = node.nodeType;
3593
3598
  vnode.el = node;
3594
3599
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
3595
3600
  optimized = false;
@@ -3626,10 +3631,12 @@ function createHydrationFunctions(rendererInternals) {
3626
3631
  }
3627
3632
  break;
3628
3633
  case Static:
3629
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
3630
- nextNode = onMismatch();
3634
+ if (isFragmentStart) {
3635
+ // entire template is static but SSRed as a fragment
3636
+ node = nextSibling(node);
3637
+ domType = node.nodeType;
3631
3638
  }
3632
- else {
3639
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
3633
3640
  // determine anchor, adopt content
3634
3641
  nextNode = node;
3635
3642
  // if the static vnode has its content stripped during build,
@@ -3646,7 +3653,10 @@ function createHydrationFunctions(rendererInternals) {
3646
3653
  }
3647
3654
  nextNode = nextSibling(nextNode);
3648
3655
  }
3649
- return nextNode;
3656
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
3657
+ }
3658
+ else {
3659
+ onMismatch();
3650
3660
  }
3651
3661
  break;
3652
3662
  case Fragment:
@@ -3908,7 +3918,7 @@ function createHydrationRenderer(options) {
3908
3918
  function baseCreateRenderer(options, createHydrationFns) {
3909
3919
  const target = shared.getGlobalThis();
3910
3920
  target.__VUE__ = true;
3911
- const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
3921
+ const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, insertStaticContent: hostInsertStaticContent } = options;
3912
3922
  // Note: functions inside this closure should use `const xxx = () => {}`
3913
3923
  // style in order to prevent being inlined by minifiers.
3914
3924
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
@@ -4014,55 +4024,44 @@ function baseCreateRenderer(options, createHydrationFns) {
4014
4024
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
4015
4025
  let el;
4016
4026
  let vnodeHook;
4017
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
4018
- if (vnode.el &&
4019
- hostCloneNode !== undefined &&
4020
- patchFlag === -1 /* PatchFlags.HOISTED */) {
4021
- // If a vnode has non-null el, it means it's being reused.
4022
- // Only static vnodes can be reused, so its mounted DOM nodes should be
4023
- // exactly the same, and we can simply do a clone here.
4024
- // only do this in production since cloned trees cannot be HMR updated.
4025
- el = vnode.el = hostCloneNode(vnode.el);
4027
+ const { type, props, shapeFlag, transition, dirs } = vnode;
4028
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
4029
+ // mount children first, since some props may rely on child content
4030
+ // being already rendered, e.g. `<select value>`
4031
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
4032
+ hostSetElementText(el, vnode.children);
4026
4033
  }
4027
- else {
4028
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
4029
- // mount children first, since some props may rely on child content
4030
- // being already rendered, e.g. `<select value>`
4031
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
4032
- hostSetElementText(el, vnode.children);
4034
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
4035
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
4036
+ }
4037
+ if (dirs) {
4038
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
4039
+ }
4040
+ // props
4041
+ if (props) {
4042
+ for (const key in props) {
4043
+ if (key !== 'value' && !shared.isReservedProp(key)) {
4044
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
4045
+ }
4033
4046
  }
4034
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
4035
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
4047
+ /**
4048
+ * Special case for setting value on DOM elements:
4049
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
4050
+ * - it needs to be forced (#1471)
4051
+ * #2353 proposes adding another renderer option to configure this, but
4052
+ * the properties affects are so finite it is worth special casing it
4053
+ * here to reduce the complexity. (Special casing it also should not
4054
+ * affect non-DOM renderers)
4055
+ */
4056
+ if ('value' in props) {
4057
+ hostPatchProp(el, 'value', null, props.value);
4036
4058
  }
4037
- if (dirs) {
4038
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
4059
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
4060
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
4039
4061
  }
4040
- // props
4041
- if (props) {
4042
- for (const key in props) {
4043
- if (key !== 'value' && !shared.isReservedProp(key)) {
4044
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
4045
- }
4046
- }
4047
- /**
4048
- * Special case for setting value on DOM elements:
4049
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
4050
- * - it needs to be forced (#1471)
4051
- * #2353 proposes adding another renderer option to configure this, but
4052
- * the properties affects are so finite it is worth special casing it
4053
- * here to reduce the complexity. (Special casing it also should not
4054
- * affect non-DOM renderers)
4055
- */
4056
- if ('value' in props) {
4057
- hostPatchProp(el, 'value', null, props.value);
4058
- }
4059
- if ((vnodeHook = props.onVnodeBeforeMount)) {
4060
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
4061
- }
4062
- }
4063
- // scopeId
4064
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
4065
4062
  }
4063
+ // scopeId
4064
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
4066
4065
  if (dirs) {
4067
4066
  invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
4068
4067
  }
@@ -4224,6 +4223,13 @@ function baseCreateRenderer(options, createHydrationFns) {
4224
4223
  };
4225
4224
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
4226
4225
  if (oldProps !== newProps) {
4226
+ if (oldProps !== shared.EMPTY_OBJ) {
4227
+ for (const key in oldProps) {
4228
+ if (!shared.isReservedProp(key) && !(key in newProps)) {
4229
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
4230
+ }
4231
+ }
4232
+ }
4227
4233
  for (const key in newProps) {
4228
4234
  // empty string is not valid prop
4229
4235
  if (shared.isReservedProp(key))
@@ -4235,13 +4241,6 @@ function baseCreateRenderer(options, createHydrationFns) {
4235
4241
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
4236
4242
  }
4237
4243
  }
4238
- if (oldProps !== shared.EMPTY_OBJ) {
4239
- for (const key in oldProps) {
4240
- if (!shared.isReservedProp(key) && !(key in newProps)) {
4241
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
4242
- }
4243
- }
4244
- }
4245
4244
  if ('value' in newProps) {
4246
4245
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
4247
4246
  }
@@ -5581,7 +5580,10 @@ function normalizeVNode(child) {
5581
5580
  }
5582
5581
  // optimized normalization for template-compiled render fns
5583
5582
  function cloneIfMounted(child) {
5584
- return child.el === null || child.memo ? child : cloneVNode(child);
5583
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
5584
+ child.memo
5585
+ ? child
5586
+ : cloneVNode(child);
5585
5587
  }
5586
5588
  function normalizeChildren(vnode, children) {
5587
5589
  let type = 0;
@@ -5874,7 +5876,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
5874
5876
  // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
5875
5877
  // is done by server-renderer
5876
5878
  if (!isSSR && compile && !Component.render) {
5877
- const template = Component.template;
5879
+ const template = Component.template ||
5880
+ resolveMergedOptions(instance).template;
5878
5881
  if (template) {
5879
5882
  const { isCustomElement, compilerOptions } = instance.appContext.config;
5880
5883
  const { delimiters, compilerOptions: componentCompilerOptions } = Component;
@@ -6183,7 +6186,7 @@ function isMemoSame(cached, memo) {
6183
6186
  }
6184
6187
 
6185
6188
  // Core API ------------------------------------------------------------------
6186
- const version = "3.2.38";
6189
+ const version = "3.2.40";
6187
6190
  const _ssrUtils = {
6188
6191
  createComponentInstance,
6189
6192
  setupComponent,
@@ -261,7 +261,7 @@ export declare type CompatVue = Pick<App, 'version' | 'component' | 'directive'>
261
261
 
262
262
  declare interface CompiledSlotDescriptor {
263
263
  name: string;
264
- fn: Slot;
264
+ fn: SSRSlot;
265
265
  key?: string;
266
266
  }
267
267
 
@@ -607,7 +607,7 @@ export declare function createRenderer<HostNode = RendererNode, HostElement = Re
607
607
  * Compiler runtime helper for creating dynamic slots object
608
608
  * @private
609
609
  */
610
- export declare function createSlots(slots: Record<string, Slot>, dynamicSlots: (CompiledSlotDescriptor | CompiledSlotDescriptor[] | undefined)[]): Record<string, Slot>;
610
+ export declare function createSlots(slots: Record<string, SSRSlot>, dynamicSlots: (CompiledSlotDescriptor | CompiledSlotDescriptor[] | undefined)[]): Record<string, SSRSlot>;
611
611
 
612
612
  /**
613
613
  * @private
@@ -1667,6 +1667,8 @@ export declare const ssrContextKey: unique symbol;
1667
1667
 
1668
1668
  declare type SSRDirectiveHook = (binding: DirectiveBinding, vnode: VNode) => Data | undefined;
1669
1669
 
1670
+ declare type SSRSlot = (...args: any[]) => VNode[] | undefined;
1671
+
1670
1672
  /* Excluded from this release type: ssrUtils */
1671
1673
 
1672
1674
  export declare const Static: unique symbol;
@@ -1731,7 +1733,7 @@ export declare const Teleport: {
1731
1733
  declare const TeleportImpl: {
1732
1734
  __isTeleport: boolean;
1733
1735
  process(n1: TeleportVNode | null, n2: TeleportVNode, container: RendererElement, anchor: RendererNode | null, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, slotScopeIds: string[] | null, optimized: boolean, internals: RendererInternals): void;
1734
- remove(vnode: VNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, optimized: boolean, { um: unmount, o: { remove: hostRemove } }: RendererInternals, doRemove: Boolean): void;
1736
+ remove(vnode: VNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, optimized: boolean, { um, o: { remove } }: RendererInternals, doRemove: Boolean): void;
1735
1737
  move: typeof moveTeleport;
1736
1738
  hydrate: typeof hydrateTeleport;
1737
1739
  };
@@ -1782,7 +1784,7 @@ export { TrackOpTypes }
1782
1784
  */
1783
1785
  export declare function transformVNodeArgs(transformer?: typeof vnodeArgsTransformer): void;
1784
1786
 
1785
- export declare interface TransitionHooks<HostElement extends RendererElement = RendererElement> {
1787
+ export declare interface TransitionHooks<HostElement = RendererElement> {
1786
1788
  mode: BaseTransitionProps['mode'];
1787
1789
  persisted: boolean;
1788
1790
  beforeEnter(el: HostElement): void;
@@ -301,7 +301,9 @@ function queuePostFlushCb(cb) {
301
301
  }
302
302
  queueFlush();
303
303
  }
304
- function flushPreFlushCbs(seen, i = flushIndex) {
304
+ function flushPreFlushCbs(seen,
305
+ // if currently flushing, skip the current job itself
306
+ i = isFlushing ? flushIndex + 1 : 0) {
305
307
  if ((process.env.NODE_ENV !== 'production')) {
306
308
  seen = seen || new Map();
307
309
  }
@@ -2705,7 +2707,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
2705
2707
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
2706
2708
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
2707
2709
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
2708
- injectHook(lifecycle, hook, target);
2710
+ injectHook(lifecycle, (...args) => hook(...args), target);
2709
2711
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
2710
2712
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
2711
2713
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -2928,7 +2930,10 @@ function createSlots(slots, dynamicSlots) {
2928
2930
  slots[slot.name] = slot.key
2929
2931
  ? (...args) => {
2930
2932
  const res = slot.fn(...args);
2931
- res.key = slot.key;
2933
+ // attach branch key so each conditional branch is considered a
2934
+ // different fragment
2935
+ if (res)
2936
+ res.key = slot.key;
2932
2937
  return res;
2933
2938
  }
2934
2939
  : slot.fn;
@@ -4595,7 +4600,7 @@ function createHydrationFunctions(rendererInternals) {
4595
4600
  const isFragmentStart = isComment(node) && node.data === '[';
4596
4601
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
4597
4602
  const { type, ref, shapeFlag, patchFlag } = vnode;
4598
- const domType = node.nodeType;
4603
+ let domType = node.nodeType;
4599
4604
  vnode.el = node;
4600
4605
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
4601
4606
  optimized = false;
@@ -4636,10 +4641,12 @@ function createHydrationFunctions(rendererInternals) {
4636
4641
  }
4637
4642
  break;
4638
4643
  case Static:
4639
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
4640
- nextNode = onMismatch();
4644
+ if (isFragmentStart) {
4645
+ // entire template is static but SSRed as a fragment
4646
+ node = nextSibling(node);
4647
+ domType = node.nodeType;
4641
4648
  }
4642
- else {
4649
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
4643
4650
  // determine anchor, adopt content
4644
4651
  nextNode = node;
4645
4652
  // if the static vnode has its content stripped during build,
@@ -4656,7 +4663,10 @@ function createHydrationFunctions(rendererInternals) {
4656
4663
  }
4657
4664
  nextNode = nextSibling(nextNode);
4658
4665
  }
4659
- return nextNode;
4666
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
4667
+ }
4668
+ else {
4669
+ onMismatch();
4660
4670
  }
4661
4671
  break;
4662
4672
  case Fragment:
@@ -5014,7 +5024,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5014
5024
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
5015
5025
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
5016
5026
  }
5017
- const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
5027
+ const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, insertStaticContent: hostInsertStaticContent } = options;
5018
5028
  // Note: functions inside this closure should use `const xxx = () => {}`
5019
5029
  // style in order to prevent being inlined by minifiers.
5020
5030
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = (process.env.NODE_ENV !== 'production') && isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -5141,56 +5151,44 @@ function baseCreateRenderer(options, createHydrationFns) {
5141
5151
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5142
5152
  let el;
5143
5153
  let vnodeHook;
5144
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
5145
- if (!(process.env.NODE_ENV !== 'production') &&
5146
- vnode.el &&
5147
- hostCloneNode !== undefined &&
5148
- patchFlag === -1 /* PatchFlags.HOISTED */) {
5149
- // If a vnode has non-null el, it means it's being reused.
5150
- // Only static vnodes can be reused, so its mounted DOM nodes should be
5151
- // exactly the same, and we can simply do a clone here.
5152
- // only do this in production since cloned trees cannot be HMR updated.
5153
- el = vnode.el = hostCloneNode(vnode.el);
5154
+ const { type, props, shapeFlag, transition, dirs } = vnode;
5155
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5156
+ // mount children first, since some props may rely on child content
5157
+ // being already rendered, e.g. `<select value>`
5158
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
5159
+ hostSetElementText(el, vnode.children);
5154
5160
  }
5155
- else {
5156
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5157
- // mount children first, since some props may rely on child content
5158
- // being already rendered, e.g. `<select value>`
5159
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
5160
- hostSetElementText(el, vnode.children);
5161
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
5162
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5163
+ }
5164
+ if (dirs) {
5165
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
5166
+ }
5167
+ // props
5168
+ if (props) {
5169
+ for (const key in props) {
5170
+ if (key !== 'value' && !isReservedProp(key)) {
5171
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5172
+ }
5161
5173
  }
5162
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
5163
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5174
+ /**
5175
+ * Special case for setting value on DOM elements:
5176
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5177
+ * - it needs to be forced (#1471)
5178
+ * #2353 proposes adding another renderer option to configure this, but
5179
+ * the properties affects are so finite it is worth special casing it
5180
+ * here to reduce the complexity. (Special casing it also should not
5181
+ * affect non-DOM renderers)
5182
+ */
5183
+ if ('value' in props) {
5184
+ hostPatchProp(el, 'value', null, props.value);
5164
5185
  }
5165
- if (dirs) {
5166
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
5186
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
5187
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
5167
5188
  }
5168
- // props
5169
- if (props) {
5170
- for (const key in props) {
5171
- if (key !== 'value' && !isReservedProp(key)) {
5172
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5173
- }
5174
- }
5175
- /**
5176
- * Special case for setting value on DOM elements:
5177
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5178
- * - it needs to be forced (#1471)
5179
- * #2353 proposes adding another renderer option to configure this, but
5180
- * the properties affects are so finite it is worth special casing it
5181
- * here to reduce the complexity. (Special casing it also should not
5182
- * affect non-DOM renderers)
5183
- */
5184
- if ('value' in props) {
5185
- hostPatchProp(el, 'value', null, props.value);
5186
- }
5187
- if ((vnodeHook = props.onVnodeBeforeMount)) {
5188
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
5189
- }
5190
- }
5191
- // scopeId
5192
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5193
5189
  }
5190
+ // scopeId
5191
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5194
5192
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
5195
5193
  Object.defineProperty(el, '__vnode', {
5196
5194
  value: vnode,
@@ -5377,6 +5375,13 @@ function baseCreateRenderer(options, createHydrationFns) {
5377
5375
  };
5378
5376
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
5379
5377
  if (oldProps !== newProps) {
5378
+ if (oldProps !== EMPTY_OBJ) {
5379
+ for (const key in oldProps) {
5380
+ if (!isReservedProp(key) && !(key in newProps)) {
5381
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5382
+ }
5383
+ }
5384
+ }
5380
5385
  for (const key in newProps) {
5381
5386
  // empty string is not valid prop
5382
5387
  if (isReservedProp(key))
@@ -5388,13 +5393,6 @@ function baseCreateRenderer(options, createHydrationFns) {
5388
5393
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5389
5394
  }
5390
5395
  }
5391
- if (oldProps !== EMPTY_OBJ) {
5392
- for (const key in oldProps) {
5393
- if (!isReservedProp(key) && !(key in newProps)) {
5394
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5395
- }
5396
- }
5397
- }
5398
5396
  if ('value' in newProps) {
5399
5397
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
5400
5398
  }
@@ -6925,7 +6923,10 @@ function normalizeVNode(child) {
6925
6923
  }
6926
6924
  // optimized normalization for template-compiled render fns
6927
6925
  function cloneIfMounted(child) {
6928
- return child.el === null || child.memo ? child : cloneVNode(child);
6926
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
6927
+ child.memo
6928
+ ? child
6929
+ : cloneVNode(child);
6929
6930
  }
6930
6931
  function normalizeChildren(vnode, children) {
6931
6932
  let type = 0;
@@ -7275,7 +7276,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7275
7276
  // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
7276
7277
  // is done by server-renderer
7277
7278
  if (!isSSR && compile && !Component.render) {
7278
- const template = Component.template;
7279
+ const template = Component.template ||
7280
+ resolveMergedOptions(instance).template;
7279
7281
  if (template) {
7280
7282
  if ((process.env.NODE_ENV !== 'production')) {
7281
7283
  startMeasure(instance, `compile`);
@@ -7850,7 +7852,7 @@ function isMemoSame(cached, memo) {
7850
7852
  }
7851
7853
 
7852
7854
  // Core API ------------------------------------------------------------------
7853
- const version = "3.2.38";
7855
+ const version = "3.2.40";
7854
7856
  const _ssrUtils = {
7855
7857
  createComponentInstance,
7856
7858
  setupComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.2.38",
3
+ "version": "3.2.40",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.38",
36
- "@vue/reactivity": "3.2.38"
35
+ "@vue/shared": "3.2.40",
36
+ "@vue/reactivity": "3.2.40"
37
37
  }
38
38
  }