@vue/runtime-dom 3.2.39 → 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
  }
@@ -4170,7 +4170,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4170
4170
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4171
4171
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4172
4172
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4173
- injectHook(lifecycle, hook, target);
4173
+ injectHook(lifecycle, (...args) => hook(...args), target);
4174
4174
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4175
4175
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4176
4176
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -4393,7 +4393,10 @@ function createSlots(slots, dynamicSlots) {
4393
4393
  slots[slot.name] = slot.key
4394
4394
  ? (...args) => {
4395
4395
  const res = slot.fn(...args);
4396
- 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;
4397
4400
  return res;
4398
4401
  }
4399
4402
  : slot.fn;
@@ -6045,7 +6048,7 @@ function createHydrationFunctions(rendererInternals) {
6045
6048
  const isFragmentStart = isComment(node) && node.data === '[';
6046
6049
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
6047
6050
  const { type, ref, shapeFlag, patchFlag } = vnode;
6048
- const domType = node.nodeType;
6051
+ let domType = node.nodeType;
6049
6052
  vnode.el = node;
6050
6053
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
6051
6054
  optimized = false;
@@ -6085,10 +6088,12 @@ function createHydrationFunctions(rendererInternals) {
6085
6088
  }
6086
6089
  break;
6087
6090
  case Static:
6088
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
6089
- nextNode = onMismatch();
6091
+ if (isFragmentStart) {
6092
+ // entire template is static but SSRed as a fragment
6093
+ node = nextSibling(node);
6094
+ domType = node.nodeType;
6090
6095
  }
6091
- else {
6096
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
6092
6097
  // determine anchor, adopt content
6093
6098
  nextNode = node;
6094
6099
  // if the static vnode has its content stripped during build,
@@ -6105,7 +6110,10 @@ function createHydrationFunctions(rendererInternals) {
6105
6110
  }
6106
6111
  nextNode = nextSibling(nextNode);
6107
6112
  }
6108
- return nextNode;
6113
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
6114
+ }
6115
+ else {
6116
+ onMismatch();
6109
6117
  }
6110
6118
  break;
6111
6119
  case Fragment:
@@ -6430,7 +6438,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6430
6438
  {
6431
6439
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
6432
6440
  }
6433
- 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;
6434
6442
  // Note: functions inside this closure should use `const xxx = () => {}`
6435
6443
  // style in order to prevent being inlined by minifiers.
6436
6444
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -6557,46 +6565,44 @@ function baseCreateRenderer(options, createHydrationFns) {
6557
6565
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6558
6566
  let el;
6559
6567
  let vnodeHook;
6560
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
6561
- {
6562
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
6563
- // mount children first, since some props may rely on child content
6564
- // being already rendered, e.g. `<select value>`
6565
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
6566
- hostSetElementText(el, vnode.children);
6567
- }
6568
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
6569
- 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
+ }
6570
6587
  }
6571
- if (dirs) {
6572
- 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);
6573
6599
  }
6574
- // props
6575
- if (props) {
6576
- for (const key in props) {
6577
- if (key !== 'value' && !isReservedProp(key)) {
6578
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6579
- }
6580
- }
6581
- /**
6582
- * Special case for setting value on DOM elements:
6583
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
6584
- * - it needs to be forced (#1471)
6585
- * #2353 proposes adding another renderer option to configure this, but
6586
- * the properties affects are so finite it is worth special casing it
6587
- * here to reduce the complexity. (Special casing it also should not
6588
- * affect non-DOM renderers)
6589
- */
6590
- if ('value' in props) {
6591
- hostPatchProp(el, 'value', null, props.value);
6592
- }
6593
- if ((vnodeHook = props.onVnodeBeforeMount)) {
6594
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
6595
- }
6600
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
6601
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
6596
6602
  }
6597
- // scopeId
6598
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6599
6603
  }
6604
+ // scopeId
6605
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6600
6606
  {
6601
6607
  Object.defineProperty(el, '__vnode', {
6602
6608
  value: vnode,
@@ -6782,6 +6788,13 @@ function baseCreateRenderer(options, createHydrationFns) {
6782
6788
  };
6783
6789
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
6784
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
+ }
6785
6798
  for (const key in newProps) {
6786
6799
  // empty string is not valid prop
6787
6800
  if (isReservedProp(key))
@@ -6793,13 +6806,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6793
6806
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6794
6807
  }
6795
6808
  }
6796
- if (oldProps !== EMPTY_OBJ) {
6797
- for (const key in oldProps) {
6798
- if (!isReservedProp(key) && !(key in newProps)) {
6799
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6800
- }
6801
- }
6802
- }
6803
6809
  if ('value' in newProps) {
6804
6810
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
6805
6811
  }
@@ -8323,7 +8329,10 @@ function normalizeVNode(child) {
8323
8329
  }
8324
8330
  // optimized normalization for template-compiled render fns
8325
8331
  function cloneIfMounted(child) {
8326
- 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);
8327
8336
  }
8328
8337
  function normalizeChildren(vnode, children) {
8329
8338
  let type = 0;
@@ -9221,7 +9230,7 @@ function isMemoSame(cached, memo) {
9221
9230
  }
9222
9231
 
9223
9232
  // Core API ------------------------------------------------------------------
9224
- const version = "3.2.39";
9233
+ const version = "3.2.40";
9225
9234
  /**
9226
9235
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9227
9236
  * @internal
@@ -9272,22 +9281,6 @@ const nodeOps = {
9272
9281
  setScopeId(el, id) {
9273
9282
  el.setAttribute(id, '');
9274
9283
  },
9275
- cloneNode(el) {
9276
- const cloned = el.cloneNode(true);
9277
- // #3072
9278
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
9279
- // - normally, elements using `:value` bindings will not be hoisted, but if
9280
- // the bound value is a constant, e.g. `:value="true"` - they do get
9281
- // hoisted.
9282
- // - in production, hoisted nodes are cloned when subsequent inserts, but
9283
- // cloneNode() does not copy the custom property we attached.
9284
- // - This may need to account for other custom DOM properties we attach to
9285
- // elements in addition to `_value` in the future.
9286
- if (`_value` in el) {
9287
- cloned._value = el._value;
9288
- }
9289
- return cloned;
9290
- },
9291
9284
  // __UNSAFE__
9292
9285
  // Reason: innerHTML.
9293
9286
  // Static content here can only come from compiled templates.
@@ -9499,7 +9492,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9499
9492
  }
9500
9493
  else if (type === 'number') {
9501
9494
  // e.g. <img :width="null">
9502
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9503
9495
  value = 0;
9504
9496
  needRemove = true;
9505
9497
  }
@@ -9511,7 +9503,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9511
9503
  el[key] = value;
9512
9504
  }
9513
9505
  catch (e) {
9514
- {
9506
+ // do not warn if value is auto-coerced from nullish values
9507
+ if (!needRemove) {
9515
9508
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
9516
9509
  `value ${value} is invalid.`, e);
9517
9510
  }