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