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