vue 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.
@@ -4251,7 +4251,7 @@ var Vue = (function (exports) {
4251
4251
  const createHook = (lifecycle) => (hook, target = currentInstance) =>
4252
4252
  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4253
4253
  (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
4254
- injectHook(lifecycle, hook, target);
4254
+ injectHook(lifecycle, (...args) => hook(...args), target);
4255
4255
  const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
4256
4256
  const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
4257
4257
  const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
@@ -4474,7 +4474,10 @@ var Vue = (function (exports) {
4474
4474
  slots[slot.name] = slot.key
4475
4475
  ? (...args) => {
4476
4476
  const res = slot.fn(...args);
4477
- res.key = slot.key;
4477
+ // attach branch key so each conditional branch is considered a
4478
+ // different fragment
4479
+ if (res)
4480
+ res.key = slot.key;
4478
4481
  return res;
4479
4482
  }
4480
4483
  : slot.fn;
@@ -6126,7 +6129,7 @@ var Vue = (function (exports) {
6126
6129
  const isFragmentStart = isComment(node) && node.data === '[';
6127
6130
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
6128
6131
  const { type, ref, shapeFlag, patchFlag } = vnode;
6129
- const domType = node.nodeType;
6132
+ let domType = node.nodeType;
6130
6133
  vnode.el = node;
6131
6134
  if (patchFlag === -2 /* PatchFlags.BAIL */) {
6132
6135
  optimized = false;
@@ -6166,10 +6169,12 @@ var Vue = (function (exports) {
6166
6169
  }
6167
6170
  break;
6168
6171
  case Static:
6169
- if (domType !== 1 /* DOMNodeTypes.ELEMENT */ && domType !== 3 /* DOMNodeTypes.TEXT */) {
6170
- nextNode = onMismatch();
6172
+ if (isFragmentStart) {
6173
+ // entire template is static but SSRed as a fragment
6174
+ node = nextSibling(node);
6175
+ domType = node.nodeType;
6171
6176
  }
6172
- else {
6177
+ if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
6173
6178
  // determine anchor, adopt content
6174
6179
  nextNode = node;
6175
6180
  // if the static vnode has its content stripped during build,
@@ -6186,7 +6191,10 @@ var Vue = (function (exports) {
6186
6191
  }
6187
6192
  nextNode = nextSibling(nextNode);
6188
6193
  }
6189
- return nextNode;
6194
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
6195
+ }
6196
+ else {
6197
+ onMismatch();
6190
6198
  }
6191
6199
  break;
6192
6200
  case Fragment:
@@ -6511,7 +6519,7 @@ var Vue = (function (exports) {
6511
6519
  {
6512
6520
  setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
6513
6521
  }
6514
- 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;
6522
+ 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;
6515
6523
  // Note: functions inside this closure should use `const xxx = () => {}`
6516
6524
  // style in order to prevent being inlined by minifiers.
6517
6525
  const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
@@ -6638,46 +6646,44 @@ var Vue = (function (exports) {
6638
6646
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6639
6647
  let el;
6640
6648
  let vnodeHook;
6641
- const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
6642
- {
6643
- el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
6644
- // mount children first, since some props may rely on child content
6645
- // being already rendered, e.g. `<select value>`
6646
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
6647
- hostSetElementText(el, vnode.children);
6648
- }
6649
- else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
6650
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
6651
- }
6652
- if (dirs) {
6653
- invokeDirectiveHook(vnode, null, parentComponent, 'created');
6654
- }
6655
- // props
6656
- if (props) {
6657
- for (const key in props) {
6658
- if (key !== 'value' && !isReservedProp(key)) {
6659
- hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6660
- }
6661
- }
6662
- /**
6663
- * Special case for setting value on DOM elements:
6664
- * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
6665
- * - it needs to be forced (#1471)
6666
- * #2353 proposes adding another renderer option to configure this, but
6667
- * the properties affects are so finite it is worth special casing it
6668
- * here to reduce the complexity. (Special casing it also should not
6669
- * affect non-DOM renderers)
6670
- */
6671
- if ('value' in props) {
6672
- hostPatchProp(el, 'value', null, props.value);
6673
- }
6674
- if ((vnodeHook = props.onVnodeBeforeMount)) {
6675
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
6676
- }
6677
- }
6678
- // scopeId
6679
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6649
+ const { type, props, shapeFlag, transition, dirs } = vnode;
6650
+ el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
6651
+ // mount children first, since some props may rely on child content
6652
+ // being already rendered, e.g. `<select value>`
6653
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
6654
+ hostSetElementText(el, vnode.children);
6655
+ }
6656
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
6657
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
6680
6658
  }
6659
+ if (dirs) {
6660
+ invokeDirectiveHook(vnode, null, parentComponent, 'created');
6661
+ }
6662
+ // props
6663
+ if (props) {
6664
+ for (const key in props) {
6665
+ if (key !== 'value' && !isReservedProp(key)) {
6666
+ hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6667
+ }
6668
+ }
6669
+ /**
6670
+ * Special case for setting value on DOM elements:
6671
+ * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
6672
+ * - it needs to be forced (#1471)
6673
+ * #2353 proposes adding another renderer option to configure this, but
6674
+ * the properties affects are so finite it is worth special casing it
6675
+ * here to reduce the complexity. (Special casing it also should not
6676
+ * affect non-DOM renderers)
6677
+ */
6678
+ if ('value' in props) {
6679
+ hostPatchProp(el, 'value', null, props.value);
6680
+ }
6681
+ if ((vnodeHook = props.onVnodeBeforeMount)) {
6682
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
6683
+ }
6684
+ }
6685
+ // scopeId
6686
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
6681
6687
  {
6682
6688
  Object.defineProperty(el, '__vnode', {
6683
6689
  value: vnode,
@@ -6863,6 +6869,13 @@ var Vue = (function (exports) {
6863
6869
  };
6864
6870
  const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
6865
6871
  if (oldProps !== newProps) {
6872
+ if (oldProps !== EMPTY_OBJ) {
6873
+ for (const key in oldProps) {
6874
+ if (!isReservedProp(key) && !(key in newProps)) {
6875
+ hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6876
+ }
6877
+ }
6878
+ }
6866
6879
  for (const key in newProps) {
6867
6880
  // empty string is not valid prop
6868
6881
  if (isReservedProp(key))
@@ -6874,13 +6887,6 @@ var Vue = (function (exports) {
6874
6887
  hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6875
6888
  }
6876
6889
  }
6877
- if (oldProps !== EMPTY_OBJ) {
6878
- for (const key in oldProps) {
6879
- if (!isReservedProp(key) && !(key in newProps)) {
6880
- hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6881
- }
6882
- }
6883
- }
6884
6890
  if ('value' in newProps) {
6885
6891
  hostPatchProp(el, 'value', oldProps.value, newProps.value);
6886
6892
  }
@@ -8404,7 +8410,10 @@ var Vue = (function (exports) {
8404
8410
  }
8405
8411
  // optimized normalization for template-compiled render fns
8406
8412
  function cloneIfMounted(child) {
8407
- return child.el === null || child.memo ? child : cloneVNode(child);
8413
+ return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
8414
+ child.memo
8415
+ ? child
8416
+ : cloneVNode(child);
8408
8417
  }
8409
8418
  function normalizeChildren(vnode, children) {
8410
8419
  let type = 0;
@@ -9297,7 +9306,7 @@ var Vue = (function (exports) {
9297
9306
  }
9298
9307
 
9299
9308
  // Core API ------------------------------------------------------------------
9300
- const version = "3.2.39";
9309
+ const version = "3.2.40";
9301
9310
  /**
9302
9311
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9303
9312
  * @internal
@@ -9348,22 +9357,6 @@ var Vue = (function (exports) {
9348
9357
  setScopeId(el, id) {
9349
9358
  el.setAttribute(id, '');
9350
9359
  },
9351
- cloneNode(el) {
9352
- const cloned = el.cloneNode(true);
9353
- // #3072
9354
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
9355
- // - normally, elements using `:value` bindings will not be hoisted, but if
9356
- // the bound value is a constant, e.g. `:value="true"` - they do get
9357
- // hoisted.
9358
- // - in production, hoisted nodes are cloned when subsequent inserts, but
9359
- // cloneNode() does not copy the custom property we attached.
9360
- // - This may need to account for other custom DOM properties we attach to
9361
- // elements in addition to `_value` in the future.
9362
- if (`_value` in el) {
9363
- cloned._value = el._value;
9364
- }
9365
- return cloned;
9366
- },
9367
9360
  // __UNSAFE__
9368
9361
  // Reason: innerHTML.
9369
9362
  // Static content here can only come from compiled templates.
@@ -9575,7 +9568,6 @@ var Vue = (function (exports) {
9575
9568
  }
9576
9569
  else if (type === 'number') {
9577
9570
  // e.g. <img :width="null">
9578
- // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9579
9571
  value = 0;
9580
9572
  needRemove = true;
9581
9573
  }
@@ -9587,7 +9579,8 @@ var Vue = (function (exports) {
9587
9579
  el[key] = value;
9588
9580
  }
9589
9581
  catch (e) {
9590
- {
9582
+ // do not warn if value is auto-coerced from nullish values
9583
+ if (!needRemove) {
9591
9584
  warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
9592
9585
  `value ${value} is invalid.`, e);
9593
9586
  }
@@ -11797,34 +11790,42 @@ var Vue = (function (exports) {
11797
11790
  const shouldCondense = context.options.whitespace !== 'preserve';
11798
11791
  for (let i = 0; i < nodes.length; i++) {
11799
11792
  const node = nodes[i];
11800
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
11801
- if (!/[^\t\r\n\f ]/.test(node.content)) {
11802
- const prev = nodes[i - 1];
11803
- const next = nodes[i + 1];
11804
- // Remove if:
11805
- // - the whitespace is the first or last node, or:
11806
- // - (condense mode) the whitespace is adjacent to a comment, or:
11807
- // - (condense mode) the whitespace is between two elements AND contains newline
11808
- if (!prev ||
11809
- !next ||
11810
- (shouldCondense &&
11811
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
11812
- next.type === 3 /* NodeTypes.COMMENT */ ||
11813
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
11814
- next.type === 1 /* NodeTypes.ELEMENT */ &&
11815
- /[\r\n]/.test(node.content))))) {
11816
- removedWhitespace = true;
11817
- nodes[i] = null;
11793
+ if (node.type === 2 /* NodeTypes.TEXT */) {
11794
+ if (!context.inPre) {
11795
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
11796
+ const prev = nodes[i - 1];
11797
+ const next = nodes[i + 1];
11798
+ // Remove if:
11799
+ // - the whitespace is the first or last node, or:
11800
+ // - (condense mode) the whitespace is adjacent to a comment, or:
11801
+ // - (condense mode) the whitespace is between two elements AND contains newline
11802
+ if (!prev ||
11803
+ !next ||
11804
+ (shouldCondense &&
11805
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
11806
+ next.type === 3 /* NodeTypes.COMMENT */ ||
11807
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
11808
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
11809
+ /[\r\n]/.test(node.content))))) {
11810
+ removedWhitespace = true;
11811
+ nodes[i] = null;
11812
+ }
11813
+ else {
11814
+ // Otherwise, the whitespace is condensed into a single space
11815
+ node.content = ' ';
11816
+ }
11818
11817
  }
11819
- else {
11820
- // Otherwise, the whitespace is condensed into a single space
11821
- node.content = ' ';
11818
+ else if (shouldCondense) {
11819
+ // in condense mode, consecutive whitespaces in text are condensed
11820
+ // down to a single space.
11821
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
11822
11822
  }
11823
11823
  }
11824
- else if (shouldCondense) {
11825
- // in condense mode, consecutive whitespaces in text are condensed
11826
- // down to a single space.
11827
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
11824
+ else {
11825
+ // #6410 normalize windows newlines in <pre>:
11826
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
11827
+ // in the DOM
11828
+ node.content = node.content.replace(/\r\n/g, '\n');
11828
11829
  }
11829
11830
  }
11830
11831
  // Remove comment nodes if desired by configuration.
@@ -12465,11 +12466,6 @@ var Vue = (function (exports) {
12465
12466
  }
12466
12467
  }
12467
12468
  }
12468
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
12469
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
12470
- child.codegenNode = context.hoist(child.codegenNode);
12471
- hoistedCount++;
12472
- }
12473
12469
  // walk further
12474
12470
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
12475
12471
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -14480,6 +14476,14 @@ var Vue = (function (exports) {
14480
14476
  let hasDynamicKeys = false;
14481
14477
  let hasVnodeHook = false;
14482
14478
  const dynamicPropNames = [];
14479
+ const pushMergeArg = (arg) => {
14480
+ if (properties.length) {
14481
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
14482
+ properties = [];
14483
+ }
14484
+ if (arg)
14485
+ mergeArgs.push(arg);
14486
+ };
14483
14487
  const analyzePatchFlag = ({ key, value }) => {
14484
14488
  if (isStaticExp(key)) {
14485
14489
  const name = key.content;
@@ -14592,16 +14596,14 @@ var Vue = (function (exports) {
14592
14596
  if (!arg && (isVBind || isVOn)) {
14593
14597
  hasDynamicKeys = true;
14594
14598
  if (exp) {
14595
- if (properties.length) {
14596
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
14597
- properties = [];
14598
- }
14599
14599
  if (isVBind) {
14600
+ // have to merge early for compat build check
14601
+ pushMergeArg();
14600
14602
  mergeArgs.push(exp);
14601
14603
  }
14602
14604
  else {
14603
14605
  // v-on="obj" -> toHandlers(obj)
14604
- mergeArgs.push({
14606
+ pushMergeArg({
14605
14607
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
14606
14608
  loc,
14607
14609
  callee: context.helper(TO_HANDLERS),
@@ -14621,7 +14623,12 @@ var Vue = (function (exports) {
14621
14623
  // has built-in directive transform.
14622
14624
  const { props, needRuntime } = directiveTransform(prop, node, context);
14623
14625
  !ssr && props.forEach(analyzePatchFlag);
14624
- properties.push(...props);
14626
+ if (isVOn && arg && !isStaticExp(arg)) {
14627
+ pushMergeArg(createObjectExpression(props, elementLoc));
14628
+ }
14629
+ else {
14630
+ properties.push(...props);
14631
+ }
14625
14632
  if (needRuntime) {
14626
14633
  runtimeDirectives.push(prop);
14627
14634
  if (isSymbol(needRuntime)) {
@@ -14643,9 +14650,8 @@ var Vue = (function (exports) {
14643
14650
  let propsExpression = undefined;
14644
14651
  // has v-bind="object" or v-on="object", wrap with mergeProps
14645
14652
  if (mergeArgs.length) {
14646
- if (properties.length) {
14647
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
14648
- }
14653
+ // close up any not-yet-merged props
14654
+ pushMergeArg();
14649
14655
  if (mergeArgs.length > 1) {
14650
14656
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
14651
14657
  }