@vue/compat 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.
@@ -4737,7 +4737,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4737
4737
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4738
4738
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4739
4739
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4740
- injectHook(lifecycle, hook, target);
4740
+ injectHook(lifecycle, (...args) => hook(...args), target);
4741
4741
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4742
4742
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4743
4743
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -5289,7 +5289,10 @@ function createSlots(slots, dynamicSlots) {
5289
5289
  slots[slot.name] = slot.key
5290
5290
  ? (...args) => {
5291
5291
  const res = slot.fn(...args);
5292
- res.key = slot.key;
5292
+ // attach branch key so each conditional branch is considered a
5293
+ // different fragment
5294
+ if (res)
5295
+ res.key = slot.key;
5293
5296
  return res;
5294
5297
  }
5295
5298
  : slot.fn;
@@ -7057,7 +7060,7 @@ function createCompatVue(createApp, createSingletonApp) {
7057
7060
  return vm;
7058
7061
  }
7059
7062
  }
7060
- Vue.version = `2.6.14-compat:${"3.2.39"}`;
7063
+ Vue.version = `2.6.14-compat:${"3.2.40"}`;
7061
7064
  Vue.config = singletonApp.config;
7062
7065
  Vue.use = (p, ...options) => {
7063
7066
  if (p && isFunction(p.install)) {
@@ -7768,7 +7771,7 @@ function createHydrationFunctions(rendererInternals) {
7768
7771
  const isFragmentStart = isComment(node) && node.data === '[';
7769
7772
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
7770
7773
  const { type, ref, shapeFlag, patchFlag } = vnode;
7771
- const domType = node.nodeType;
7774
+ let domType = node.nodeType;
7772
7775
  vnode.el = node;
7773
7776
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
7774
7777
  optimized = false;
@@ -7808,10 +7811,12 @@ function createHydrationFunctions(rendererInternals) {
7808
7811
  }
7809
7812
  break;
7810
7813
  case Static:
7811
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
7812
- nextNode = onMismatch();
7814
+ if (isFragmentStart) {
7815
+ // entire template is static but SSRed as a fragment
7816
+ node = nextSibling(node);
7817
+ domType = node.nodeType;
7813
7818
  }
7814
- else {
7819
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
7815
7820
  // determine anchor, adopt content
7816
7821
  nextNode = node;
7817
7822
  // if the static vnode has its content stripped during build,
@@ -7828,7 +7833,10 @@ function createHydrationFunctions(rendererInternals) {
7828
7833
  }
7829
7834
  nextNode = nextSibling(nextNode);
7830
7835
  }
7831
- return nextNode;
7836
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
7837
+ }
7838
+ else {
7839
+ onMismatch();
7832
7840
  }
7833
7841
  break;
7834
7842
  case Fragment:
@@ -8153,7 +8161,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8153
8161
  {
8154
8162
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
8155
8163
  }
8156
- 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;
8164
+ 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;
8157
8165
  // Note: functions inside this closure should use `const xxx = () => {}`
8158
8166
  // style in order to prevent being inlined by minifiers.
8159
8167
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -8280,46 +8288,44 @@ function baseCreateRenderer(options, createHydrationFns) {
8280
8288
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8281
8289
  let el;
8282
8290
  let vnodeHook;
8283
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
8284
- {
8285
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8286
- // mount children first, since some props may rely on child content
8287
- // being already rendered, e.g. `<select value>`
8288
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8289
- hostSetElementText(el, vnode.children);
8290
- }
8291
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8292
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8291
+ const { type, props, shapeFlag, transition, dirs } = vnode;
8292
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8293
+ // mount children first, since some props may rely on child content
8294
+ // being already rendered, e.g. `<select value>`
8295
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8296
+ hostSetElementText(el, vnode.children);
8297
+ }
8298
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8299
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8300
+ }
8301
+ if (dirs) {
8302
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
8303
+ }
8304
+ // props
8305
+ if (props) {
8306
+ for (const key in props) {
8307
+ if (key !== 'value' && !isReservedProp(key)) {
8308
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8309
+ }
8293
8310
  }
8294
- if (dirs) {
8295
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
8311
+ /**
8312
+ * Special case for setting value on DOM elements:
8313
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8314
+ * - it needs to be forced (#1471)
8315
+ * #2353 proposes adding another renderer option to configure this, but
8316
+ * the properties affects are so finite it is worth special casing it
8317
+ * here to reduce the complexity. (Special casing it also should not
8318
+ * affect non-DOM renderers)
8319
+ */
8320
+ if ('value' in props) {
8321
+ hostPatchProp(el, 'value', null, props.value);
8296
8322
  }
8297
- // props
8298
- if (props) {
8299
- for (const key in props) {
8300
- if (key !== 'value' && !isReservedProp(key)) {
8301
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8302
- }
8303
- }
8304
- /**
8305
- * Special case for setting value on DOM elements:
8306
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8307
- * - it needs to be forced (#1471)
8308
- * #2353 proposes adding another renderer option to configure this, but
8309
- * the properties affects are so finite it is worth special casing it
8310
- * here to reduce the complexity. (Special casing it also should not
8311
- * affect non-DOM renderers)
8312
- */
8313
- if ('value' in props) {
8314
- hostPatchProp(el, 'value', null, props.value);
8315
- }
8316
- if ((vnodeHook = props.onVnodeBeforeMount)) {
8317
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
8318
- }
8323
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
8324
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
8319
8325
  }
8320
- // scopeId
8321
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8322
8326
  }
8327
+ // scopeId
8328
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8323
8329
  {
8324
8330
  Object.defineProperty(el, '__vnode', {
8325
8331
  value: vnode,
@@ -8505,6 +8511,13 @@ function baseCreateRenderer(options, createHydrationFns) {
8505
8511
  };
8506
8512
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
8507
8513
  if (oldProps !== newProps) {
8514
+ if (oldProps !== EMPTY_OBJ) {
8515
+ for (const key in oldProps) {
8516
+ if (!isReservedProp(key) && !(key in newProps)) {
8517
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8518
+ }
8519
+ }
8520
+ }
8508
8521
  for (const key in newProps) {
8509
8522
  // empty string is not valid prop
8510
8523
  if (isReservedProp(key))
@@ -8516,13 +8529,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8516
8529
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8517
8530
  }
8518
8531
  }
8519
- if (oldProps !== EMPTY_OBJ) {
8520
- for (const key in oldProps) {
8521
- if (!isReservedProp(key) && !(key in newProps)) {
8522
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8523
- }
8524
- }
8525
- }
8526
8532
  if ('value' in newProps) {
8527
8533
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
8528
8534
  }
@@ -10142,7 +10148,10 @@ function normalizeVNode(child) {
10142
10148
  }
10143
10149
  // optimized normalization for template-compiled render fns
10144
10150
  function cloneIfMounted(child) {
10145
- return child.el === null || child.memo ? child : cloneVNode(child);
10151
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
10152
+ child.memo
10153
+ ? child
10154
+ : cloneVNode(child);
10146
10155
  }
10147
10156
  function normalizeChildren(vnode, children) {
10148
10157
  let type = 0;
@@ -11056,7 +11065,7 @@ function isMemoSame(cached, memo) {
11056
11065
  }
11057
11066
 
11058
11067
  // Core API ------------------------------------------------------------------
11059
- const version = "3.2.39";
11068
+ const version = "3.2.40";
11060
11069
  /**
11061
11070
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11062
11071
  * @internal
@@ -11114,22 +11123,6 @@ const nodeOps = {
11114
11123
  setScopeId(el, id) {
11115
11124
  el.setAttribute(id, '');
11116
11125
  },
11117
- cloneNode(el) {
11118
- const cloned = el.cloneNode(true);
11119
- // #3072
11120
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
11121
- // - normally, elements using `:value` bindings will not be hoisted, but if
11122
- // the bound value is a constant, e.g. `:value="true"` - they do get
11123
- // hoisted.
11124
- // - in production, hoisted nodes are cloned when subsequent inserts, but
11125
- // cloneNode() does not copy the custom property we attached.
11126
- // - This may need to account for other custom DOM properties we attach to
11127
- // elements in addition to `_value` in the future.
11128
- if (`_value` in el) {
11129
- cloned._value = el._value;
11130
- }
11131
- return cloned;
11132
- },
11133
11126
  // __UNSAFE__
11134
11127
  // Reason: innerHTML.
11135
11128
  // Static content here can only come from compiled templates.
@@ -11300,14 +11293,14 @@ const isEnumeratedAttr = /*#__PURE__*/ makeMap('contenteditable,draggable,spellc
11300
11293
  ;
11301
11294
  function compatCoerceAttr(el, key, value, instance = null) {
11302
11295
  if (isEnumeratedAttr(key)) {
11303
- const v2CocercedValue = value === null
11296
+ const v2CoercedValue = value === null
11304
11297
  ? 'false'
11305
11298
  : typeof value !== 'boolean' && value !== undefined
11306
11299
  ? 'true'
11307
11300
  : null;
11308
- if (v2CocercedValue &&
11309
- compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CocercedValue)) {
11310
- el.setAttribute(key, v2CocercedValue);
11301
+ if (v2CoercedValue &&
11302
+ compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CoercedValue)) {
11303
+ el.setAttribute(key, v2CoercedValue);
11311
11304
  return true;
11312
11305
  }
11313
11306
  }
@@ -11368,7 +11361,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11368
11361
  }
11369
11362
  else if (type === 'number') {
11370
11363
  // e.g. <img :width="null">
11371
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
11372
11364
  value = 0;
11373
11365
  needRemove = true;
11374
11366
  }
@@ -11391,7 +11383,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11391
11383
  el[key] = value;
11392
11384
  }
11393
11385
  catch (e) {
11394
- {
11386
+ // do not warn if value is auto-coerced from nullish values
11387
+ if (!needRemove) {
11395
11388
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
11396
11389
  `value ${value} is invalid.`, e);
11397
11390
  }