@vue/runtime-dom 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.
@@ -41,22 +41,6 @@ const nodeOps = {
41
41
  setScopeId(el, id) {
42
42
  el.setAttribute(id, '');
43
43
  },
44
- cloneNode(el) {
45
- const cloned = el.cloneNode(true);
46
- // #3072
47
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
48
- // - normally, elements using `:value` bindings will not be hoisted, but if
49
- // the bound value is a constant, e.g. `:value="true"` - they do get
50
- // hoisted.
51
- // - in production, hoisted nodes are cloned when subsequent inserts, but
52
- // cloneNode() does not copy the custom property we attached.
53
- // - This may need to account for other custom DOM properties we attach to
54
- // elements in addition to `_value` in the future.
55
- if (`_value` in el) {
56
- cloned._value = el._value;
57
- }
58
- return cloned;
59
- },
60
44
  // __UNSAFE__
61
45
  // Reason: innerHTML.
62
46
  // Static content here can only come from compiled templates.
@@ -268,7 +252,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
268
252
  }
269
253
  else if (type === 'number') {
270
254
  // e.g. <img :width="null">
271
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
272
255
  value = 0;
273
256
  needRemove = true;
274
257
  }
@@ -280,7 +263,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
280
263
  el[key] = value;
281
264
  }
282
265
  catch (e) {
283
- {
266
+ // do not warn if value is auto-coerced from nullish values
267
+ if (!needRemove) {
284
268
  runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
285
269
  `value ${value} is invalid.`, e);
286
270
  }
@@ -41,22 +41,6 @@ const nodeOps = {
41
41
  setScopeId(el, id) {
42
42
  el.setAttribute(id, '');
43
43
  },
44
- cloneNode(el) {
45
- const cloned = el.cloneNode(true);
46
- // #3072
47
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
48
- // - normally, elements using `:value` bindings will not be hoisted, but if
49
- // the bound value is a constant, e.g. `:value="true"` - they do get
50
- // hoisted.
51
- // - in production, hoisted nodes are cloned when subsequent inserts, but
52
- // cloneNode() does not copy the custom property we attached.
53
- // - This may need to account for other custom DOM properties we attach to
54
- // elements in addition to `_value` in the future.
55
- if (`_value` in el) {
56
- cloned._value = el._value;
57
- }
58
- return cloned;
59
- },
60
44
  // __UNSAFE__
61
45
  // Reason: innerHTML.
62
46
  // Static content here can only come from compiled templates.
@@ -268,7 +252,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
268
252
  }
269
253
  else if (type === 'number') {
270
254
  // e.g. <img :width="null">
271
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
272
255
  value = 0;
273
256
  needRemove = true;
274
257
  }
@@ -1797,7 +1797,9 @@ function queuePostFlushCb(cb) {
1797
1797
  }
1798
1798
  queueFlush();
1799
1799
  }
1800
- function flushPreFlushCbs(seen, i = flushIndex) {
1800
+ function flushPreFlushCbs(seen,
1801
+ // if currently flushing, skip the current job itself
1802
+ i = isFlushing ? flushIndex + 1 : 0) {
1801
1803
  {
1802
1804
  seen = seen || new Map();
1803
1805
  }
@@ -4168,7 +4170,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4168
4170
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4169
4171
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4170
4172
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4171
- injectHook(lifecycle, hook, target);
4173
+ injectHook(lifecycle, (...args) => hook(...args), target);
4172
4174
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4173
4175
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4174
4176
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -4391,7 +4393,10 @@ function createSlots(slots, dynamicSlots) {
4391
4393
  slots[slot.name] = slot.key
4392
4394
  ? (...args) => {
4393
4395
  const res = slot.fn(...args);
4394
- res.key = slot.key;
4396
+ // attach branch key so each conditional branch is considered a
4397
+ // different fragment
4398
+ if (res)
4399
+ res.key = slot.key;
4395
4400
  return res;
4396
4401
  }
4397
4402
  : slot.fn;
@@ -6043,7 +6048,7 @@ function createHydrationFunctions(rendererInternals) {
6043
6048
  const isFragmentStart = isComment(node) && node.data === '[';
6044
6049
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
6045
6050
  const { type, ref, shapeFlag, patchFlag } = vnode;
6046
- const domType = node.nodeType;
6051
+ let domType = node.nodeType;
6047
6052
  vnode.el = node;
6048
6053
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
6049
6054
  optimized = false;
@@ -6083,10 +6088,12 @@ function createHydrationFunctions(rendererInternals) {
6083
6088
  }
6084
6089
  break;
6085
6090
  case Static:
6086
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
6087
- nextNode = onMismatch();
6091
+ if (isFragmentStart) {
6092
+ // entire template is static but SSRed as a fragment
6093
+ node = nextSibling(node);
6094
+ domType = node.nodeType;
6088
6095
  }
6089
- else {
6096
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
6090
6097
  // determine anchor, adopt content
6091
6098
  nextNode = node;
6092
6099
  // if the static vnode has its content stripped during build,
@@ -6103,7 +6110,10 @@ function createHydrationFunctions(rendererInternals) {
6103
6110
  }
6104
6111
  nextNode = nextSibling(nextNode);
6105
6112
  }
6106
- return nextNode;
6113
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
6114
+ }
6115
+ else {
6116
+ onMismatch();
6107
6117
  }
6108
6118
  break;
6109
6119
  case Fragment:
@@ -6428,7 +6438,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6428
6438
  {
6429
6439
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
6430
6440
  }
6431
- 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;
6441
+ 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;
6432
6442
  // Note: functions inside this closure should use `const xxx = () => {}`
6433
6443
  // style in order to prevent being inlined by minifiers.
6434
6444
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -6555,46 +6565,44 @@ function baseCreateRenderer(options, createHydrationFns) {
6555
6565
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6556
6566
  let el;
6557
6567
  let vnodeHook;
6558
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
6559
- {
6560
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
6561
- // mount children first, since some props may rely on child content
6562
- // being already rendered, e.g. `<select value>`
6563
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
6564
- hostSetElementText(el, vnode.children);
6565
- }
6566
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
6567
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
6568
+ const { type, props, shapeFlag, transition, dirs } = vnode;
6569
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
6570
+ // mount children first, since some props may rely on child content
6571
+ // being already rendered, e.g. `<select value>`
6572
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
6573
+ hostSetElementText(el, vnode.children);
6574
+ }
6575
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
6576
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
6577
+ }
6578
+ if (dirs) {
6579
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
6580
+ }
6581
+ // props
6582
+ if (props) {
6583
+ for (const key in props) {
6584
+ if (key !== 'value' && !isReservedProp(key)) {
6585
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6586
+ }
6568
6587
  }
6569
- if (dirs) {
6570
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
6588
+ /**
6589
+ * Special case for setting value on DOM elements:
6590
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
6591
+ * - it needs to be forced (#1471)
6592
+ * #2353 proposes adding another renderer option to configure this, but
6593
+ * the properties affects are so finite it is worth special casing it
6594
+ * here to reduce the complexity. (Special casing it also should not
6595
+ * affect non-DOM renderers)
6596
+ */
6597
+ if ('value' in props) {
6598
+ hostPatchProp(el, 'value', null, props.value);
6571
6599
  }
6572
- // props
6573
- if (props) {
6574
- for (const key in props) {
6575
- if (key !== 'value' && !isReservedProp(key)) {
6576
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6577
- }
6578
- }
6579
- /**
6580
- * Special case for setting value on DOM elements:
6581
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
6582
- * - it needs to be forced (#1471)
6583
- * #2353 proposes adding another renderer option to configure this, but
6584
- * the properties affects are so finite it is worth special casing it
6585
- * here to reduce the complexity. (Special casing it also should not
6586
- * affect non-DOM renderers)
6587
- */
6588
- if ('value' in props) {
6589
- hostPatchProp(el, 'value', null, props.value);
6590
- }
6591
- if ((vnodeHook = props.onVnodeBeforeMount)) {
6592
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
6593
- }
6600
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
6601
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
6594
6602
  }
6595
- // scopeId
6596
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6597
6603
  }
6604
+ // scopeId
6605
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6598
6606
  {
6599
6607
  Object.defineProperty(el, '__vnode', {
6600
6608
  value: vnode,
@@ -6780,6 +6788,13 @@ function baseCreateRenderer(options, createHydrationFns) {
6780
6788
  };
6781
6789
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
6782
6790
  if (oldProps !== newProps) {
6791
+ if (oldProps !== EMPTY_OBJ) {
6792
+ for (const key in oldProps) {
6793
+ if (!isReservedProp(key) && !(key in newProps)) {
6794
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6795
+ }
6796
+ }
6797
+ }
6783
6798
  for (const key in newProps) {
6784
6799
  // empty string is not valid prop
6785
6800
  if (isReservedProp(key))
@@ -6791,13 +6806,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6791
6806
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6792
6807
  }
6793
6808
  }
6794
- if (oldProps !== EMPTY_OBJ) {
6795
- for (const key in oldProps) {
6796
- if (!isReservedProp(key) && !(key in newProps)) {
6797
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6798
- }
6799
- }
6800
- }
6801
6809
  if ('value' in newProps) {
6802
6810
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
6803
6811
  }
@@ -8321,7 +8329,10 @@ function normalizeVNode(child) {
8321
8329
  }
8322
8330
  // optimized normalization for template-compiled render fns
8323
8331
  function cloneIfMounted(child) {
8324
- return child.el === null || child.memo ? child : cloneVNode(child);
8332
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
8333
+ child.memo
8334
+ ? child
8335
+ : cloneVNode(child);
8325
8336
  }
8326
8337
  function normalizeChildren(vnode, children) {
8327
8338
  let type = 0;
@@ -8663,7 +8674,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
8663
8674
  // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
8664
8675
  // is done by server-renderer
8665
8676
  if (!isSSR && compile && !Component.render) {
8666
- const template = Component.template;
8677
+ const template = Component.template ||
8678
+ resolveMergedOptions(instance).template;
8667
8679
  if (template) {
8668
8680
  {
8669
8681
  startMeasure(instance, `compile`);
@@ -9218,7 +9230,7 @@ function isMemoSame(cached, memo) {
9218
9230
  }
9219
9231
 
9220
9232
  // Core API ------------------------------------------------------------------
9221
- const version = "3.2.38";
9233
+ const version = "3.2.40";
9222
9234
  /**
9223
9235
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9224
9236
  * @internal
@@ -9269,22 +9281,6 @@ const nodeOps = {
9269
9281
  setScopeId(el, id) {
9270
9282
  el.setAttribute(id, '');
9271
9283
  },
9272
- cloneNode(el) {
9273
- const cloned = el.cloneNode(true);
9274
- // #3072
9275
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
9276
- // - normally, elements using `:value` bindings will not be hoisted, but if
9277
- // the bound value is a constant, e.g. `:value="true"` - they do get
9278
- // hoisted.
9279
- // - in production, hoisted nodes are cloned when subsequent inserts, but
9280
- // cloneNode() does not copy the custom property we attached.
9281
- // - This may need to account for other custom DOM properties we attach to
9282
- // elements in addition to `_value` in the future.
9283
- if (`_value` in el) {
9284
- cloned._value = el._value;
9285
- }
9286
- return cloned;
9287
- },
9288
9284
  // __UNSAFE__
9289
9285
  // Reason: innerHTML.
9290
9286
  // Static content here can only come from compiled templates.
@@ -9496,7 +9492,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9496
9492
  }
9497
9493
  else if (type === 'number') {
9498
9494
  // e.g. <img :width="null">
9499
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9500
9495
  value = 0;
9501
9496
  needRemove = true;
9502
9497
  }
@@ -9508,7 +9503,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9508
9503
  el[key] = value;
9509
9504
  }
9510
9505
  catch (e) {
9511
- {
9506
+ // do not warn if value is auto-coerced from nullish values
9507
+ if (!needRemove) {
9512
9508
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
9513
9509
  `value ${value} is invalid.`, e);
9514
9510
  }