@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.
@@ -1879,7 +1879,9 @@ var Vue = (function () {
1879
1879
  }
1880
1880
  queueFlush();
1881
1881
  }
1882
- function flushPreFlushCbs(seen, i = flushIndex) {
1882
+ function flushPreFlushCbs(seen,
1883
+ // if currently flushing, skip the current job itself
1884
+ i = isFlushing ? flushIndex + 1 : 0) {
1883
1885
  {
1884
1886
  seen = seen || new Map();
1885
1887
  }
@@ -4817,7 +4819,7 @@ var Vue = (function () {
4817
4819
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4818
4820
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4819
4821
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4820
- injectHook(lifecycle, hook, target);
4822
+ injectHook(lifecycle, (...args) => hook(...args), target);
4821
4823
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4822
4824
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4823
4825
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -5369,7 +5371,10 @@ var Vue = (function () {
5369
5371
  slots[slot.name] = slot.key
5370
5372
  ? (...args) => {
5371
5373
  const res = slot.fn(...args);
5372
- res.key = slot.key;
5374
+ // attach branch key so each conditional branch is considered a
5375
+ // different fragment
5376
+ if (res)
5377
+ res.key = slot.key;
5373
5378
  return res;
5374
5379
  }
5375
5380
  : slot.fn;
@@ -7137,7 +7142,7 @@ var Vue = (function () {
7137
7142
  return vm;
7138
7143
  }
7139
7144
  }
7140
- Vue.version = `2.6.14-compat:${"3.2.38"}`;
7145
+ Vue.version = `2.6.14-compat:${"3.2.40"}`;
7141
7146
  Vue.config = singletonApp.config;
7142
7147
  Vue.use = (p, ...options) => {
7143
7148
  if (p && isFunction(p.install)) {
@@ -7848,7 +7853,7 @@ var Vue = (function () {
7848
7853
  const isFragmentStart = isComment(node) && node.data === '[';
7849
7854
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
7850
7855
  const { type, ref, shapeFlag, patchFlag } = vnode;
7851
- const domType = node.nodeType;
7856
+ let domType = node.nodeType;
7852
7857
  vnode.el = node;
7853
7858
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
7854
7859
  optimized = false;
@@ -7888,10 +7893,12 @@ var Vue = (function () {
7888
7893
  }
7889
7894
  break;
7890
7895
  case Static:
7891
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
7892
- nextNode = onMismatch();
7896
+ if (isFragmentStart) {
7897
+ // entire template is static but SSRed as a fragment
7898
+ node = nextSibling(node);
7899
+ domType = node.nodeType;
7893
7900
  }
7894
- else {
7901
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
7895
7902
  // determine anchor, adopt content
7896
7903
  nextNode = node;
7897
7904
  // if the static vnode has its content stripped during build,
@@ -7908,7 +7915,10 @@ var Vue = (function () {
7908
7915
  }
7909
7916
  nextNode = nextSibling(nextNode);
7910
7917
  }
7911
- return nextNode;
7918
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
7919
+ }
7920
+ else {
7921
+ onMismatch();
7912
7922
  }
7913
7923
  break;
7914
7924
  case Fragment:
@@ -8233,7 +8243,7 @@ var Vue = (function () {
8233
8243
  {
8234
8244
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
8235
8245
  }
8236
- 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;
8246
+ 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;
8237
8247
  // Note: functions inside this closure should use `const xxx = () => {}`
8238
8248
  // style in order to prevent being inlined by minifiers.
8239
8249
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -8360,46 +8370,44 @@ var Vue = (function () {
8360
8370
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8361
8371
  let el;
8362
8372
  let vnodeHook;
8363
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
8364
- {
8365
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8366
- // mount children first, since some props may rely on child content
8367
- // being already rendered, e.g. `<select value>`
8368
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8369
- hostSetElementText(el, vnode.children);
8370
- }
8371
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8372
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8373
- }
8374
- if (dirs) {
8375
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
8376
- }
8377
- // props
8378
- if (props) {
8379
- for (const key in props) {
8380
- if (key !== 'value' && !isReservedProp(key)) {
8381
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8382
- }
8383
- }
8384
- /**
8385
- * Special case for setting value on DOM elements:
8386
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8387
- * - it needs to be forced (#1471)
8388
- * #2353 proposes adding another renderer option to configure this, but
8389
- * the properties affects are so finite it is worth special casing it
8390
- * here to reduce the complexity. (Special casing it also should not
8391
- * affect non-DOM renderers)
8392
- */
8393
- if ('value' in props) {
8394
- hostPatchProp(el, 'value', null, props.value);
8395
- }
8396
- if ((vnodeHook = props.onVnodeBeforeMount)) {
8397
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
8398
- }
8399
- }
8400
- // scopeId
8401
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8373
+ const { type, props, shapeFlag, transition, dirs } = vnode;
8374
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8375
+ // mount children first, since some props may rely on child content
8376
+ // being already rendered, e.g. `<select value>`
8377
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8378
+ hostSetElementText(el, vnode.children);
8379
+ }
8380
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8381
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8402
8382
  }
8383
+ if (dirs) {
8384
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
8385
+ }
8386
+ // props
8387
+ if (props) {
8388
+ for (const key in props) {
8389
+ if (key !== 'value' && !isReservedProp(key)) {
8390
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8391
+ }
8392
+ }
8393
+ /**
8394
+ * Special case for setting value on DOM elements:
8395
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8396
+ * - it needs to be forced (#1471)
8397
+ * #2353 proposes adding another renderer option to configure this, but
8398
+ * the properties affects are so finite it is worth special casing it
8399
+ * here to reduce the complexity. (Special casing it also should not
8400
+ * affect non-DOM renderers)
8401
+ */
8402
+ if ('value' in props) {
8403
+ hostPatchProp(el, 'value', null, props.value);
8404
+ }
8405
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
8406
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
8407
+ }
8408
+ }
8409
+ // scopeId
8410
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8403
8411
  {
8404
8412
  Object.defineProperty(el, '__vnode', {
8405
8413
  value: vnode,
@@ -8585,6 +8593,13 @@ var Vue = (function () {
8585
8593
  };
8586
8594
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
8587
8595
  if (oldProps !== newProps) {
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
+ }
8588
8603
  for (const key in newProps) {
8589
8604
  // empty string is not valid prop
8590
8605
  if (isReservedProp(key))
@@ -8596,13 +8611,6 @@ var Vue = (function () {
8596
8611
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8597
8612
  }
8598
8613
  }
8599
- if (oldProps !== EMPTY_OBJ) {
8600
- for (const key in oldProps) {
8601
- if (!isReservedProp(key) && !(key in newProps)) {
8602
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8603
- }
8604
- }
8605
- }
8606
8614
  if ('value' in newProps) {
8607
8615
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
8608
8616
  }
@@ -10222,7 +10230,10 @@ var Vue = (function () {
10222
10230
  }
10223
10231
  // optimized normalization for template-compiled render fns
10224
10232
  function cloneIfMounted(child) {
10225
- return child.el === null || child.memo ? child : cloneVNode(child);
10233
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
10234
+ child.memo
10235
+ ? child
10236
+ : cloneVNode(child);
10226
10237
  }
10227
10238
  function normalizeChildren(vnode, children) {
10228
10239
  let type = 0;
@@ -10572,7 +10583,8 @@ var Vue = (function () {
10572
10583
  if (!isSSR && compile && !Component.render) {
10573
10584
  const template = (instance.vnode.props &&
10574
10585
  instance.vnode.props['inline-template']) ||
10575
- Component.template;
10586
+ Component.template ||
10587
+ resolveMergedOptions(instance).template;
10576
10588
  if (template) {
10577
10589
  {
10578
10590
  startMeasure(instance, `compile`);
@@ -11130,7 +11142,7 @@ var Vue = (function () {
11130
11142
  }
11131
11143
 
11132
11144
  // Core API ------------------------------------------------------------------
11133
- const version = "3.2.38";
11145
+ const version = "3.2.40";
11134
11146
  /**
11135
11147
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11136
11148
  * @internal
@@ -11188,22 +11200,6 @@ var Vue = (function () {
11188
11200
  setScopeId(el, id) {
11189
11201
  el.setAttribute(id, '');
11190
11202
  },
11191
- cloneNode(el) {
11192
- const cloned = el.cloneNode(true);
11193
- // #3072
11194
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
11195
- // - normally, elements using `:value` bindings will not be hoisted, but if
11196
- // the bound value is a constant, e.g. `:value="true"` - they do get
11197
- // hoisted.
11198
- // - in production, hoisted nodes are cloned when subsequent inserts, but
11199
- // cloneNode() does not copy the custom property we attached.
11200
- // - This may need to account for other custom DOM properties we attach to
11201
- // elements in addition to `_value` in the future.
11202
- if (`_value` in el) {
11203
- cloned._value = el._value;
11204
- }
11205
- return cloned;
11206
- },
11207
11203
  // __UNSAFE__
11208
11204
  // Reason: innerHTML.
11209
11205
  // Static content here can only come from compiled templates.
@@ -11374,14 +11370,14 @@ var Vue = (function () {
11374
11370
  ;
11375
11371
  function compatCoerceAttr(el, key, value, instance = null) {
11376
11372
  if (isEnumeratedAttr(key)) {
11377
- const v2CocercedValue = value === null
11373
+ const v2CoercedValue = value === null
11378
11374
  ? 'false'
11379
11375
  : typeof value !== 'boolean' && value !== undefined
11380
11376
  ? 'true'
11381
11377
  : null;
11382
- if (v2CocercedValue &&
11383
- compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CocercedValue)) {
11384
- el.setAttribute(key, v2CocercedValue);
11378
+ if (v2CoercedValue &&
11379
+ compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CoercedValue)) {
11380
+ el.setAttribute(key, v2CoercedValue);
11385
11381
  return true;
11386
11382
  }
11387
11383
  }
@@ -11442,7 +11438,6 @@ var Vue = (function () {
11442
11438
  }
11443
11439
  else if (type === 'number') {
11444
11440
  // e.g. <img :width="null">
11445
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
11446
11441
  value = 0;
11447
11442
  needRemove = true;
11448
11443
  }
@@ -11465,7 +11460,8 @@ var Vue = (function () {
11465
11460
  el[key] = value;
11466
11461
  }
11467
11462
  catch (e) {
11468
- {
11463
+ // do not warn if value is auto-coerced from nullish values
11464
+ if (!needRemove) {
11469
11465
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
11470
11466
  `value ${value} is invalid.`, e);
11471
11467
  }
@@ -13944,34 +13940,42 @@ var Vue = (function () {
13944
13940
  const shouldCondense = context.options.whitespace !== 'preserve';
13945
13941
  for (let i = 0; i < nodes.length; i++) {
13946
13942
  const node = nodes[i];
13947
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
13948
- if (!/[^\t\r\n\f ]/.test(node.content)) {
13949
- const prev = nodes[i - 1];
13950
- const next = nodes[i + 1];
13951
- // Remove if:
13952
- // - the whitespace is the first or last node, or:
13953
- // - (condense mode) the whitespace is adjacent to a comment, or:
13954
- // - (condense mode) the whitespace is between two elements AND contains newline
13955
- if (!prev ||
13956
- !next ||
13957
- (shouldCondense &&
13958
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
13959
- next.type === 3 /* NodeTypes.COMMENT */ ||
13960
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
13961
- next.type === 1 /* NodeTypes.ELEMENT */ &&
13962
- /[\r\n]/.test(node.content))))) {
13963
- removedWhitespace = true;
13964
- nodes[i] = null;
13943
+ if (node.type === 2 /* NodeTypes.TEXT */) {
13944
+ if (!context.inPre) {
13945
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
13946
+ const prev = nodes[i - 1];
13947
+ const next = nodes[i + 1];
13948
+ // Remove if:
13949
+ // - the whitespace is the first or last node, or:
13950
+ // - (condense mode) the whitespace is adjacent to a comment, or:
13951
+ // - (condense mode) the whitespace is between two elements AND contains newline
13952
+ if (!prev ||
13953
+ !next ||
13954
+ (shouldCondense &&
13955
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
13956
+ next.type === 3 /* NodeTypes.COMMENT */ ||
13957
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
13958
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
13959
+ /[\r\n]/.test(node.content))))) {
13960
+ removedWhitespace = true;
13961
+ nodes[i] = null;
13962
+ }
13963
+ else {
13964
+ // Otherwise, the whitespace is condensed into a single space
13965
+ node.content = ' ';
13966
+ }
13965
13967
  }
13966
- else {
13967
- // Otherwise, the whitespace is condensed into a single space
13968
- node.content = ' ';
13968
+ else if (shouldCondense) {
13969
+ // in condense mode, consecutive whitespaces in text are condensed
13970
+ // down to a single space.
13971
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
13969
13972
  }
13970
13973
  }
13971
- else if (shouldCondense) {
13972
- // in condense mode, consecutive whitespaces in text are condensed
13973
- // down to a single space.
13974
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
13974
+ else {
13975
+ // #6410 normalize windows newlines in <pre>:
13976
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
13977
+ // in the DOM
13978
+ node.content = node.content.replace(/\r\n/g, '\n');
13975
13979
  }
13976
13980
  }
13977
13981
  // Remove comment nodes if desired by configuration.
@@ -14659,11 +14663,6 @@ var Vue = (function () {
14659
14663
  }
14660
14664
  }
14661
14665
  }
14662
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
14663
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
14664
- child.codegenNode = context.hoist(child.codegenNode);
14665
- hoistedCount++;
14666
- }
14667
14666
  // walk further
14668
14667
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
14669
14668
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -16693,6 +16692,14 @@ var Vue = (function () {
16693
16692
  let hasDynamicKeys = false;
16694
16693
  let hasVnodeHook = false;
16695
16694
  const dynamicPropNames = [];
16695
+ const pushMergeArg = (arg) => {
16696
+ if (properties.length) {
16697
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16698
+ properties = [];
16699
+ }
16700
+ if (arg)
16701
+ mergeArgs.push(arg);
16702
+ };
16696
16703
  const analyzePatchFlag = ({ key, value }) => {
16697
16704
  if (isStaticExp(key)) {
16698
16705
  const name = key.content;
@@ -16805,11 +16812,9 @@ var Vue = (function () {
16805
16812
  if (!arg && (isVBind || isVOn)) {
16806
16813
  hasDynamicKeys = true;
16807
16814
  if (exp) {
16808
- if (properties.length) {
16809
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16810
- properties = [];
16811
- }
16812
16815
  if (isVBind) {
16816
+ // have to merge early for compat build check
16817
+ pushMergeArg();
16813
16818
  {
16814
16819
  // 2.x v-bind object order compat
16815
16820
  {
@@ -16843,7 +16848,7 @@ var Vue = (function () {
16843
16848
  }
16844
16849
  else {
16845
16850
  // v-on="obj" -> toHandlers(obj)
16846
- mergeArgs.push({
16851
+ pushMergeArg({
16847
16852
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
16848
16853
  loc,
16849
16854
  callee: context.helper(TO_HANDLERS),
@@ -16863,7 +16868,12 @@ var Vue = (function () {
16863
16868
  // has built-in directive transform.
16864
16869
  const { props, needRuntime } = directiveTransform(prop, node, context);
16865
16870
  !ssr && props.forEach(analyzePatchFlag);
16866
- properties.push(...props);
16871
+ if (isVOn && arg && !isStaticExp(arg)) {
16872
+ pushMergeArg(createObjectExpression(props, elementLoc));
16873
+ }
16874
+ else {
16875
+ properties.push(...props);
16876
+ }
16867
16877
  if (needRuntime) {
16868
16878
  runtimeDirectives.push(prop);
16869
16879
  if (isSymbol(needRuntime)) {
@@ -16885,9 +16895,8 @@ var Vue = (function () {
16885
16895
  let propsExpression = undefined;
16886
16896
  // has v-bind="object" or v-on="object", wrap with mergeProps
16887
16897
  if (mergeArgs.length) {
16888
- if (properties.length) {
16889
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16890
- }
16898
+ // close up any not-yet-merged props
16899
+ pushMergeArg();
16891
16900
  if (mergeArgs.length > 1) {
16892
16901
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
16893
16902
  }