@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.
@@ -1876,7 +1876,9 @@ function queuePostFlushCb(cb) {
1876
1876
  }
1877
1877
  queueFlush();
1878
1878
  }
1879
- function flushPreFlushCbs(seen, i = flushIndex) {
1879
+ function flushPreFlushCbs(seen,
1880
+ // if currently flushing, skip the current job itself
1881
+ i = isFlushing ? flushIndex + 1 : 0) {
1880
1882
  {
1881
1883
  seen = seen || new Map();
1882
1884
  }
@@ -4814,7 +4816,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4814
4816
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4815
4817
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4816
4818
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4817
- injectHook(lifecycle, hook, target);
4819
+ injectHook(lifecycle, (...args) => hook(...args), target);
4818
4820
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4819
4821
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4820
4822
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -5366,7 +5368,10 @@ function createSlots(slots, dynamicSlots) {
5366
5368
  slots[slot.name] = slot.key
5367
5369
  ? (...args) => {
5368
5370
  const res = slot.fn(...args);
5369
- res.key = slot.key;
5371
+ // attach branch key so each conditional branch is considered a
5372
+ // different fragment
5373
+ if (res)
5374
+ res.key = slot.key;
5370
5375
  return res;
5371
5376
  }
5372
5377
  : slot.fn;
@@ -7134,7 +7139,7 @@ function createCompatVue(createApp, createSingletonApp) {
7134
7139
  return vm;
7135
7140
  }
7136
7141
  }
7137
- Vue.version = `2.6.14-compat:${"3.2.38"}`;
7142
+ Vue.version = `2.6.14-compat:${"3.2.40"}`;
7138
7143
  Vue.config = singletonApp.config;
7139
7144
  Vue.use = (p, ...options) => {
7140
7145
  if (p && isFunction(p.install)) {
@@ -7845,7 +7850,7 @@ function createHydrationFunctions(rendererInternals) {
7845
7850
  const isFragmentStart = isComment(node) && node.data === '[';
7846
7851
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
7847
7852
  const { type, ref, shapeFlag, patchFlag } = vnode;
7848
- const domType = node.nodeType;
7853
+ let domType = node.nodeType;
7849
7854
  vnode.el = node;
7850
7855
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
7851
7856
  optimized = false;
@@ -7885,10 +7890,12 @@ function createHydrationFunctions(rendererInternals) {
7885
7890
  }
7886
7891
  break;
7887
7892
  case Static:
7888
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
7889
- nextNode = onMismatch();
7893
+ if (isFragmentStart) {
7894
+ // entire template is static but SSRed as a fragment
7895
+ node = nextSibling(node);
7896
+ domType = node.nodeType;
7890
7897
  }
7891
- else {
7898
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
7892
7899
  // determine anchor, adopt content
7893
7900
  nextNode = node;
7894
7901
  // if the static vnode has its content stripped during build,
@@ -7905,7 +7912,10 @@ function createHydrationFunctions(rendererInternals) {
7905
7912
  }
7906
7913
  nextNode = nextSibling(nextNode);
7907
7914
  }
7908
- return nextNode;
7915
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
7916
+ }
7917
+ else {
7918
+ onMismatch();
7909
7919
  }
7910
7920
  break;
7911
7921
  case Fragment:
@@ -8230,7 +8240,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8230
8240
  {
8231
8241
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
8232
8242
  }
8233
- 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;
8243
+ 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;
8234
8244
  // Note: functions inside this closure should use `const xxx = () => {}`
8235
8245
  // style in order to prevent being inlined by minifiers.
8236
8246
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -8357,46 +8367,44 @@ function baseCreateRenderer(options, createHydrationFns) {
8357
8367
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8358
8368
  let el;
8359
8369
  let vnodeHook;
8360
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
8361
- {
8362
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8363
- // mount children first, since some props may rely on child content
8364
- // being already rendered, e.g. `<select value>`
8365
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8366
- hostSetElementText(el, vnode.children);
8367
- }
8368
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8369
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8370
- }
8371
- if (dirs) {
8372
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
8373
- }
8374
- // props
8375
- if (props) {
8376
- for (const key in props) {
8377
- if (key !== 'value' && !isReservedProp(key)) {
8378
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8379
- }
8380
- }
8381
- /**
8382
- * Special case for setting value on DOM elements:
8383
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8384
- * - it needs to be forced (#1471)
8385
- * #2353 proposes adding another renderer option to configure this, but
8386
- * the properties affects are so finite it is worth special casing it
8387
- * here to reduce the complexity. (Special casing it also should not
8388
- * affect non-DOM renderers)
8389
- */
8390
- if ('value' in props) {
8391
- hostPatchProp(el, 'value', null, props.value);
8392
- }
8393
- if ((vnodeHook = props.onVnodeBeforeMount)) {
8394
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
8395
- }
8396
- }
8397
- // scopeId
8398
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8370
+ const { type, props, shapeFlag, transition, dirs } = vnode;
8371
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8372
+ // mount children first, since some props may rely on child content
8373
+ // being already rendered, e.g. `<select value>`
8374
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8375
+ hostSetElementText(el, vnode.children);
8376
+ }
8377
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8378
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8399
8379
  }
8380
+ if (dirs) {
8381
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
8382
+ }
8383
+ // props
8384
+ if (props) {
8385
+ for (const key in props) {
8386
+ if (key !== 'value' && !isReservedProp(key)) {
8387
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8388
+ }
8389
+ }
8390
+ /**
8391
+ * Special case for setting value on DOM elements:
8392
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8393
+ * - it needs to be forced (#1471)
8394
+ * #2353 proposes adding another renderer option to configure this, but
8395
+ * the properties affects are so finite it is worth special casing it
8396
+ * here to reduce the complexity. (Special casing it also should not
8397
+ * affect non-DOM renderers)
8398
+ */
8399
+ if ('value' in props) {
8400
+ hostPatchProp(el, 'value', null, props.value);
8401
+ }
8402
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
8403
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
8404
+ }
8405
+ }
8406
+ // scopeId
8407
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8400
8408
  {
8401
8409
  Object.defineProperty(el, '__vnode', {
8402
8410
  value: vnode,
@@ -8582,6 +8590,13 @@ function baseCreateRenderer(options, createHydrationFns) {
8582
8590
  };
8583
8591
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
8584
8592
  if (oldProps !== newProps) {
8593
+ if (oldProps !== EMPTY_OBJ) {
8594
+ for (const key in oldProps) {
8595
+ if (!isReservedProp(key) && !(key in newProps)) {
8596
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8597
+ }
8598
+ }
8599
+ }
8585
8600
  for (const key in newProps) {
8586
8601
  // empty string is not valid prop
8587
8602
  if (isReservedProp(key))
@@ -8593,13 +8608,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8593
8608
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8594
8609
  }
8595
8610
  }
8596
- if (oldProps !== EMPTY_OBJ) {
8597
- for (const key in oldProps) {
8598
- if (!isReservedProp(key) && !(key in newProps)) {
8599
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8600
- }
8601
- }
8602
- }
8603
8611
  if ('value' in newProps) {
8604
8612
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
8605
8613
  }
@@ -10219,7 +10227,10 @@ function normalizeVNode(child) {
10219
10227
  }
10220
10228
  // optimized normalization for template-compiled render fns
10221
10229
  function cloneIfMounted(child) {
10222
- return child.el === null || child.memo ? child : cloneVNode(child);
10230
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
10231
+ child.memo
10232
+ ? child
10233
+ : cloneVNode(child);
10223
10234
  }
10224
10235
  function normalizeChildren(vnode, children) {
10225
10236
  let type = 0;
@@ -10569,7 +10580,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
10569
10580
  if (!isSSR && compile && !Component.render) {
10570
10581
  const template = (instance.vnode.props &&
10571
10582
  instance.vnode.props['inline-template']) ||
10572
- Component.template;
10583
+ Component.template ||
10584
+ resolveMergedOptions(instance).template;
10573
10585
  if (template) {
10574
10586
  {
10575
10587
  startMeasure(instance, `compile`);
@@ -11132,7 +11144,7 @@ function isMemoSame(cached, memo) {
11132
11144
  }
11133
11145
 
11134
11146
  // Core API ------------------------------------------------------------------
11135
- const version = "3.2.38";
11147
+ const version = "3.2.40";
11136
11148
  /**
11137
11149
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11138
11150
  * @internal
@@ -11190,22 +11202,6 @@ const nodeOps = {
11190
11202
  setScopeId(el, id) {
11191
11203
  el.setAttribute(id, '');
11192
11204
  },
11193
- cloneNode(el) {
11194
- const cloned = el.cloneNode(true);
11195
- // #3072
11196
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
11197
- // - normally, elements using `:value` bindings will not be hoisted, but if
11198
- // the bound value is a constant, e.g. `:value="true"` - they do get
11199
- // hoisted.
11200
- // - in production, hoisted nodes are cloned when subsequent inserts, but
11201
- // cloneNode() does not copy the custom property we attached.
11202
- // - This may need to account for other custom DOM properties we attach to
11203
- // elements in addition to `_value` in the future.
11204
- if (`_value` in el) {
11205
- cloned._value = el._value;
11206
- }
11207
- return cloned;
11208
- },
11209
11205
  // __UNSAFE__
11210
11206
  // Reason: innerHTML.
11211
11207
  // Static content here can only come from compiled templates.
@@ -11376,14 +11372,14 @@ const isEnumeratedAttr = /*#__PURE__*/ makeMap('contenteditable,draggable,spellc
11376
11372
  ;
11377
11373
  function compatCoerceAttr(el, key, value, instance = null) {
11378
11374
  if (isEnumeratedAttr(key)) {
11379
- const v2CocercedValue = value === null
11375
+ const v2CoercedValue = value === null
11380
11376
  ? 'false'
11381
11377
  : typeof value !== 'boolean' && value !== undefined
11382
11378
  ? 'true'
11383
11379
  : null;
11384
- if (v2CocercedValue &&
11385
- compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CocercedValue)) {
11386
- el.setAttribute(key, v2CocercedValue);
11380
+ if (v2CoercedValue &&
11381
+ compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CoercedValue)) {
11382
+ el.setAttribute(key, v2CoercedValue);
11387
11383
  return true;
11388
11384
  }
11389
11385
  }
@@ -11444,7 +11440,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11444
11440
  }
11445
11441
  else if (type === 'number') {
11446
11442
  // e.g. <img :width="null">
11447
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
11448
11443
  value = 0;
11449
11444
  needRemove = true;
11450
11445
  }
@@ -11467,7 +11462,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11467
11462
  el[key] = value;
11468
11463
  }
11469
11464
  catch (e) {
11470
- {
11465
+ // do not warn if value is auto-coerced from nullish values
11466
+ if (!needRemove) {
11471
11467
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
11472
11468
  `value ${value} is invalid.`, e);
11473
11469
  }
@@ -13958,34 +13954,42 @@ function parseChildren(context, mode, ancestors) {
13958
13954
  const shouldCondense = context.options.whitespace !== 'preserve';
13959
13955
  for (let i = 0; i < nodes.length; i++) {
13960
13956
  const node = nodes[i];
13961
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
13962
- if (!/[^\t\r\n\f ]/.test(node.content)) {
13963
- const prev = nodes[i - 1];
13964
- const next = nodes[i + 1];
13965
- // Remove if:
13966
- // - the whitespace is the first or last node, or:
13967
- // - (condense mode) the whitespace is adjacent to a comment, or:
13968
- // - (condense mode) the whitespace is between two elements AND contains newline
13969
- if (!prev ||
13970
- !next ||
13971
- (shouldCondense &&
13972
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
13973
- next.type === 3 /* NodeTypes.COMMENT */ ||
13974
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
13975
- next.type === 1 /* NodeTypes.ELEMENT */ &&
13976
- /[\r\n]/.test(node.content))))) {
13977
- removedWhitespace = true;
13978
- nodes[i] = null;
13957
+ if (node.type === 2 /* NodeTypes.TEXT */) {
13958
+ if (!context.inPre) {
13959
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
13960
+ const prev = nodes[i - 1];
13961
+ const next = nodes[i + 1];
13962
+ // Remove if:
13963
+ // - the whitespace is the first or last node, or:
13964
+ // - (condense mode) the whitespace is adjacent to a comment, or:
13965
+ // - (condense mode) the whitespace is between two elements AND contains newline
13966
+ if (!prev ||
13967
+ !next ||
13968
+ (shouldCondense &&
13969
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
13970
+ next.type === 3 /* NodeTypes.COMMENT */ ||
13971
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
13972
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
13973
+ /[\r\n]/.test(node.content))))) {
13974
+ removedWhitespace = true;
13975
+ nodes[i] = null;
13976
+ }
13977
+ else {
13978
+ // Otherwise, the whitespace is condensed into a single space
13979
+ node.content = ' ';
13980
+ }
13979
13981
  }
13980
- else {
13981
- // Otherwise, the whitespace is condensed into a single space
13982
- node.content = ' ';
13982
+ else if (shouldCondense) {
13983
+ // in condense mode, consecutive whitespaces in text are condensed
13984
+ // down to a single space.
13985
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
13983
13986
  }
13984
13987
  }
13985
- else if (shouldCondense) {
13986
- // in condense mode, consecutive whitespaces in text are condensed
13987
- // down to a single space.
13988
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
13988
+ else {
13989
+ // #6410 normalize windows newlines in <pre>:
13990
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
13991
+ // in the DOM
13992
+ node.content = node.content.replace(/\r\n/g, '\n');
13989
13993
  }
13990
13994
  }
13991
13995
  // Remove comment nodes if desired by configuration.
@@ -14673,11 +14677,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14673
14677
  }
14674
14678
  }
14675
14679
  }
14676
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
14677
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
14678
- child.codegenNode = context.hoist(child.codegenNode);
14679
- hoistedCount++;
14680
- }
14681
14680
  // walk further
14682
14681
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
14683
14682
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -16707,6 +16706,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16707
16706
  let hasDynamicKeys = false;
16708
16707
  let hasVnodeHook = false;
16709
16708
  const dynamicPropNames = [];
16709
+ const pushMergeArg = (arg) => {
16710
+ if (properties.length) {
16711
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16712
+ properties = [];
16713
+ }
16714
+ if (arg)
16715
+ mergeArgs.push(arg);
16716
+ };
16710
16717
  const analyzePatchFlag = ({ key, value }) => {
16711
16718
  if (isStaticExp(key)) {
16712
16719
  const name = key.content;
@@ -16819,11 +16826,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16819
16826
  if (!arg && (isVBind || isVOn)) {
16820
16827
  hasDynamicKeys = true;
16821
16828
  if (exp) {
16822
- if (properties.length) {
16823
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16824
- properties = [];
16825
- }
16826
16829
  if (isVBind) {
16830
+ // have to merge early for compat build check
16831
+ pushMergeArg();
16827
16832
  {
16828
16833
  // 2.x v-bind object order compat
16829
16834
  {
@@ -16857,7 +16862,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16857
16862
  }
16858
16863
  else {
16859
16864
  // v-on="obj" -> toHandlers(obj)
16860
- mergeArgs.push({
16865
+ pushMergeArg({
16861
16866
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
16862
16867
  loc,
16863
16868
  callee: context.helper(TO_HANDLERS),
@@ -16877,7 +16882,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16877
16882
  // has built-in directive transform.
16878
16883
  const { props, needRuntime } = directiveTransform(prop, node, context);
16879
16884
  !ssr && props.forEach(analyzePatchFlag);
16880
- properties.push(...props);
16885
+ if (isVOn && arg && !isStaticExp(arg)) {
16886
+ pushMergeArg(createObjectExpression(props, elementLoc));
16887
+ }
16888
+ else {
16889
+ properties.push(...props);
16890
+ }
16881
16891
  if (needRuntime) {
16882
16892
  runtimeDirectives.push(prop);
16883
16893
  if (isSymbol(needRuntime)) {
@@ -16899,9 +16909,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16899
16909
  let propsExpression = undefined;
16900
16910
  // has v-bind="object" or v-on="object", wrap with mergeProps
16901
16911
  if (mergeArgs.length) {
16902
- if (properties.length) {
16903
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16904
- }
16912
+ // close up any not-yet-merged props
16913
+ pushMergeArg();
16905
16914
  if (mergeArgs.length > 1) {
16906
16915
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
16907
16916
  }