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