@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.
@@ -4873,7 +4873,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4873
4873
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4874
4874
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4875
4875
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4876
- injectHook(lifecycle, hook, target);
4876
+ injectHook(lifecycle, (...args) => hook(...args), target);
4877
4877
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4878
4878
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4879
4879
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -5425,7 +5425,10 @@ function createSlots(slots, dynamicSlots) {
5425
5425
  slots[slot.name] = slot.key
5426
5426
  ? (...args) => {
5427
5427
  const res = slot.fn(...args);
5428
- res.key = slot.key;
5428
+ // attach branch key so each conditional branch is considered a
5429
+ // different fragment
5430
+ if (res)
5431
+ res.key = slot.key;
5429
5432
  return res;
5430
5433
  }
5431
5434
  : slot.fn;
@@ -7205,7 +7208,7 @@ function createCompatVue(createApp, createSingletonApp) {
7205
7208
  return vm;
7206
7209
  }
7207
7210
  }
7208
- Vue.version = `2.6.14-compat:${"3.2.39"}`;
7211
+ Vue.version = `2.6.14-compat:${"3.2.40"}`;
7209
7212
  Vue.config = singletonApp.config;
7210
7213
  Vue.use = (p, ...options) => {
7211
7214
  if (p && isFunction(p.install)) {
@@ -7922,7 +7925,7 @@ function createHydrationFunctions(rendererInternals) {
7922
7925
  const isFragmentStart = isComment(node) && node.data === '[';
7923
7926
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
7924
7927
  const { type, ref, shapeFlag, patchFlag } = vnode;
7925
- const domType = node.nodeType;
7928
+ let domType = node.nodeType;
7926
7929
  vnode.el = node;
7927
7930
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
7928
7931
  optimized = false;
@@ -7963,10 +7966,12 @@ function createHydrationFunctions(rendererInternals) {
7963
7966
  }
7964
7967
  break;
7965
7968
  case Static:
7966
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
7967
- nextNode = onMismatch();
7969
+ if (isFragmentStart) {
7970
+ // entire template is static but SSRed as a fragment
7971
+ node = nextSibling(node);
7972
+ domType = node.nodeType;
7968
7973
  }
7969
- else {
7974
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
7970
7975
  // determine anchor, adopt content
7971
7976
  nextNode = node;
7972
7977
  // if the static vnode has its content stripped during build,
@@ -7983,7 +7988,10 @@ function createHydrationFunctions(rendererInternals) {
7983
7988
  }
7984
7989
  nextNode = nextSibling(nextNode);
7985
7990
  }
7986
- return nextNode;
7991
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
7992
+ }
7993
+ else {
7994
+ onMismatch();
7987
7995
  }
7988
7996
  break;
7989
7997
  case Fragment:
@@ -8341,7 +8349,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8341
8349
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
8342
8350
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
8343
8351
  }
8344
- 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;
8352
+ 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;
8345
8353
  // Note: functions inside this closure should use `const xxx = () => {}`
8346
8354
  // style in order to prevent being inlined by minifiers.
8347
8355
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = (process.env.NODE_ENV !== 'production') && isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -8468,56 +8476,44 @@ function baseCreateRenderer(options, createHydrationFns) {
8468
8476
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
8469
8477
  let el;
8470
8478
  let vnodeHook;
8471
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
8472
- if (!(process.env.NODE_ENV !== 'production') &&
8473
- vnode.el &&
8474
- hostCloneNode !== undefined &&
8475
- patchFlag === -1 /* PatchFlags.HOISTED */) {
8476
- // If a vnode has non-null el, it means it's being reused.
8477
- // Only static vnodes can be reused, so its mounted DOM nodes should be
8478
- // exactly the same, and we can simply do a clone here.
8479
- // only do this in production since cloned trees cannot be HMR updated.
8480
- el = vnode.el = hostCloneNode(vnode.el);
8479
+ const { type, props, shapeFlag, transition, dirs } = vnode;
8480
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8481
+ // mount children first, since some props may rely on child content
8482
+ // being already rendered, e.g. `<select value>`
8483
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8484
+ hostSetElementText(el, vnode.children);
8481
8485
  }
8482
- else {
8483
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
8484
- // mount children first, since some props may rely on child content
8485
- // being already rendered, e.g. `<select value>`
8486
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
8487
- hostSetElementText(el, vnode.children);
8488
- }
8489
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8490
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8491
- }
8492
- if (dirs) {
8493
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
8494
- }
8495
- // props
8496
- if (props) {
8497
- for (const key in props) {
8498
- if (key !== 'value' && !isReservedProp(key)) {
8499
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8500
- }
8501
- }
8502
- /**
8503
- * Special case for setting value on DOM elements:
8504
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8505
- * - it needs to be forced (#1471)
8506
- * #2353 proposes adding another renderer option to configure this, but
8507
- * the properties affects are so finite it is worth special casing it
8508
- * here to reduce the complexity. (Special casing it also should not
8509
- * affect non-DOM renderers)
8510
- */
8511
- if ('value' in props) {
8512
- hostPatchProp(el, 'value', null, props.value);
8513
- }
8514
- if ((vnodeHook = props.onVnodeBeforeMount)) {
8515
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
8516
- }
8517
- }
8518
- // scopeId
8519
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8486
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
8487
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
8520
8488
  }
8489
+ if (dirs) {
8490
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
8491
+ }
8492
+ // props
8493
+ if (props) {
8494
+ for (const key in props) {
8495
+ if (key !== 'value' && !isReservedProp(key)) {
8496
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8497
+ }
8498
+ }
8499
+ /**
8500
+ * Special case for setting value on DOM elements:
8501
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
8502
+ * - it needs to be forced (#1471)
8503
+ * #2353 proposes adding another renderer option to configure this, but
8504
+ * the properties affects are so finite it is worth special casing it
8505
+ * here to reduce the complexity. (Special casing it also should not
8506
+ * affect non-DOM renderers)
8507
+ */
8508
+ if ('value' in props) {
8509
+ hostPatchProp(el, 'value', null, props.value);
8510
+ }
8511
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
8512
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
8513
+ }
8514
+ }
8515
+ // scopeId
8516
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
8521
8517
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
8522
8518
  Object.defineProperty(el, '__vnode', {
8523
8519
  value: vnode,
@@ -8704,6 +8700,13 @@ function baseCreateRenderer(options, createHydrationFns) {
8704
8700
  };
8705
8701
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
8706
8702
  if (oldProps !== newProps) {
8703
+ if (oldProps !== EMPTY_OBJ) {
8704
+ for (const key in oldProps) {
8705
+ if (!isReservedProp(key) && !(key in newProps)) {
8706
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8707
+ }
8708
+ }
8709
+ }
8707
8710
  for (const key in newProps) {
8708
8711
  // empty string is not valid prop
8709
8712
  if (isReservedProp(key))
@@ -8715,13 +8718,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8715
8718
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8716
8719
  }
8717
8720
  }
8718
- if (oldProps !== EMPTY_OBJ) {
8719
- for (const key in oldProps) {
8720
- if (!isReservedProp(key) && !(key in newProps)) {
8721
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
8722
- }
8723
- }
8724
- }
8725
8721
  if ('value' in newProps) {
8726
8722
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
8727
8723
  }
@@ -10348,7 +10344,10 @@ function normalizeVNode(child) {
10348
10344
  }
10349
10345
  // optimized normalization for template-compiled render fns
10350
10346
  function cloneIfMounted(child) {
10351
- return child.el === null || child.memo ? child : cloneVNode(child);
10347
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
10348
+ child.memo
10349
+ ? child
10350
+ : cloneVNode(child);
10352
10351
  }
10353
10352
  function normalizeChildren(vnode, children) {
10354
10353
  let type = 0;
@@ -11286,7 +11285,7 @@ function isMemoSame(cached, memo) {
11286
11285
  }
11287
11286
 
11288
11287
  // Core API ------------------------------------------------------------------
11289
- const version = "3.2.39";
11288
+ const version = "3.2.40";
11290
11289
  const _ssrUtils = {
11291
11290
  createComponentInstance,
11292
11291
  setupComponent,
@@ -11352,22 +11351,6 @@ const nodeOps = {
11352
11351
  setScopeId(el, id) {
11353
11352
  el.setAttribute(id, '');
11354
11353
  },
11355
- cloneNode(el) {
11356
- const cloned = el.cloneNode(true);
11357
- // #3072
11358
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
11359
- // - normally, elements using `:value` bindings will not be hoisted, but if
11360
- // the bound value is a constant, e.g. `:value="true"` - they do get
11361
- // hoisted.
11362
- // - in production, hoisted nodes are cloned when subsequent inserts, but
11363
- // cloneNode() does not copy the custom property we attached.
11364
- // - This may need to account for other custom DOM properties we attach to
11365
- // elements in addition to `_value` in the future.
11366
- if (`_value` in el) {
11367
- cloned._value = el._value;
11368
- }
11369
- return cloned;
11370
- },
11371
11354
  // __UNSAFE__
11372
11355
  // Reason: innerHTML.
11373
11356
  // Static content here can only come from compiled templates.
@@ -11538,14 +11521,14 @@ const isEnumeratedAttr = /*#__PURE__*/ makeMap('contenteditable,draggable,spellc
11538
11521
  ;
11539
11522
  function compatCoerceAttr(el, key, value, instance = null) {
11540
11523
  if (isEnumeratedAttr(key)) {
11541
- const v2CocercedValue = value === null
11524
+ const v2CoercedValue = value === null
11542
11525
  ? 'false'
11543
11526
  : typeof value !== 'boolean' && value !== undefined
11544
11527
  ? 'true'
11545
11528
  : null;
11546
- if (v2CocercedValue &&
11547
- compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CocercedValue)) {
11548
- el.setAttribute(key, v2CocercedValue);
11529
+ if (v2CoercedValue &&
11530
+ compatUtils.softAssertCompatEnabled("ATTR_ENUMERATED_COERCION" /* DeprecationTypes.ATTR_ENUMERATED_COERCION */, instance, key, value, v2CoercedValue)) {
11531
+ el.setAttribute(key, v2CoercedValue);
11549
11532
  return true;
11550
11533
  }
11551
11534
  }
@@ -11606,7 +11589,6 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11606
11589
  }
11607
11590
  else if (type === 'number') {
11608
11591
  // e.g. <img :width="null">
11609
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
11610
11592
  value = 0;
11611
11593
  needRemove = true;
11612
11594
  }
@@ -11630,7 +11612,8 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11630
11612
  el[key] = value;
11631
11613
  }
11632
11614
  catch (e) {
11633
- if ((process.env.NODE_ENV !== 'production')) {
11615
+ // do not warn if value is auto-coerced from nullish values
11616
+ if ((process.env.NODE_ENV !== 'production') && !needRemove) {
11634
11617
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
11635
11618
  `value ${value} is invalid.`, e);
11636
11619
  }
@@ -14177,34 +14160,42 @@ function parseChildren(context, mode, ancestors) {
14177
14160
  const shouldCondense = context.options.whitespace !== 'preserve';
14178
14161
  for (let i = 0; i < nodes.length; i++) {
14179
14162
  const node = nodes[i];
14180
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
14181
- if (!/[^\t\r\n\f ]/.test(node.content)) {
14182
- const prev = nodes[i - 1];
14183
- const next = nodes[i + 1];
14184
- // Remove if:
14185
- // - the whitespace is the first or last node, or:
14186
- // - (condense mode) the whitespace is adjacent to a comment, or:
14187
- // - (condense mode) the whitespace is between two elements AND contains newline
14188
- if (!prev ||
14189
- !next ||
14190
- (shouldCondense &&
14191
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
14192
- next.type === 3 /* NodeTypes.COMMENT */ ||
14193
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
14194
- next.type === 1 /* NodeTypes.ELEMENT */ &&
14195
- /[\r\n]/.test(node.content))))) {
14196
- removedWhitespace = true;
14197
- nodes[i] = null;
14163
+ if (node.type === 2 /* NodeTypes.TEXT */) {
14164
+ if (!context.inPre) {
14165
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
14166
+ const prev = nodes[i - 1];
14167
+ const next = nodes[i + 1];
14168
+ // Remove if:
14169
+ // - the whitespace is the first or last node, or:
14170
+ // - (condense mode) the whitespace is adjacent to a comment, or:
14171
+ // - (condense mode) the whitespace is between two elements AND contains newline
14172
+ if (!prev ||
14173
+ !next ||
14174
+ (shouldCondense &&
14175
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
14176
+ next.type === 3 /* NodeTypes.COMMENT */ ||
14177
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
14178
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
14179
+ /[\r\n]/.test(node.content))))) {
14180
+ removedWhitespace = true;
14181
+ nodes[i] = null;
14182
+ }
14183
+ else {
14184
+ // Otherwise, the whitespace is condensed into a single space
14185
+ node.content = ' ';
14186
+ }
14198
14187
  }
14199
- else {
14200
- // Otherwise, the whitespace is condensed into a single space
14201
- node.content = ' ';
14188
+ else if (shouldCondense) {
14189
+ // in condense mode, consecutive whitespaces in text are condensed
14190
+ // down to a single space.
14191
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
14202
14192
  }
14203
14193
  }
14204
- else if (shouldCondense) {
14205
- // in condense mode, consecutive whitespaces in text are condensed
14206
- // down to a single space.
14207
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
14194
+ else {
14195
+ // #6410 normalize windows newlines in <pre>:
14196
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
14197
+ // in the DOM
14198
+ node.content = node.content.replace(/\r\n/g, '\n');
14208
14199
  }
14209
14200
  }
14210
14201
  // Remove comment nodes if desired by configuration.
@@ -14893,11 +14884,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14893
14884
  }
14894
14885
  }
14895
14886
  }
14896
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
14897
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
14898
- child.codegenNode = context.hoist(child.codegenNode);
14899
- hoistedCount++;
14900
- }
14901
14887
  // walk further
14902
14888
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
14903
14889
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -16937,6 +16923,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16937
16923
  let hasDynamicKeys = false;
16938
16924
  let hasVnodeHook = false;
16939
16925
  const dynamicPropNames = [];
16926
+ const pushMergeArg = (arg) => {
16927
+ if (properties.length) {
16928
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
16929
+ properties = [];
16930
+ }
16931
+ if (arg)
16932
+ mergeArgs.push(arg);
16933
+ };
16940
16934
  const analyzePatchFlag = ({ key, value }) => {
16941
16935
  if (isStaticExp(key)) {
16942
16936
  const name = key.content;
@@ -17049,11 +17043,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17049
17043
  if (!arg && (isVBind || isVOn)) {
17050
17044
  hasDynamicKeys = true;
17051
17045
  if (exp) {
17052
- if (properties.length) {
17053
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
17054
- properties = [];
17055
- }
17056
17046
  if (isVBind) {
17047
+ // have to merge early for compat build check
17048
+ pushMergeArg();
17057
17049
  {
17058
17050
  // 2.x v-bind object order compat
17059
17051
  if ((process.env.NODE_ENV !== 'production')) {
@@ -17087,7 +17079,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17087
17079
  }
17088
17080
  else {
17089
17081
  // v-on="obj" -> toHandlers(obj)
17090
- mergeArgs.push({
17082
+ pushMergeArg({
17091
17083
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
17092
17084
  loc,
17093
17085
  callee: context.helper(TO_HANDLERS),
@@ -17107,7 +17099,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17107
17099
  // has built-in directive transform.
17108
17100
  const { props, needRuntime } = directiveTransform(prop, node, context);
17109
17101
  !ssr && props.forEach(analyzePatchFlag);
17110
- properties.push(...props);
17102
+ if (isVOn && arg && !isStaticExp(arg)) {
17103
+ pushMergeArg(createObjectExpression(props, elementLoc));
17104
+ }
17105
+ else {
17106
+ properties.push(...props);
17107
+ }
17111
17108
  if (needRuntime) {
17112
17109
  runtimeDirectives.push(prop);
17113
17110
  if (isSymbol(needRuntime)) {
@@ -17129,9 +17126,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17129
17126
  let propsExpression = undefined;
17130
17127
  // has v-bind="object" or v-on="object", wrap with mergeProps
17131
17128
  if (mergeArgs.length) {
17132
- if (properties.length) {
17133
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
17134
- }
17129
+ // close up any not-yet-merged props
17130
+ pushMergeArg();
17135
17131
  if (mergeArgs.length > 1) {
17136
17132
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
17137
17133
  }