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