vue 3.5.38 → 3.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.38
2
+ * vue v3.5.40
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -376,8 +376,9 @@ class EffectScope {
376
376
  this._isPaused = true;
377
377
  let i, l;
378
378
  if (this.scopes) {
379
- for (i = 0, l = this.scopes.length; i < l; i++) {
380
- this.scopes[i].pause();
379
+ const scopes = this.scopes.slice();
380
+ for (i = 0, l = scopes.length; i < l; i++) {
381
+ scopes[i].pause();
381
382
  }
382
383
  }
383
384
  for (i = 0, l = this.effects.length; i < l; i++) {
@@ -394,12 +395,14 @@ class EffectScope {
394
395
  this._isPaused = false;
395
396
  let i, l;
396
397
  if (this.scopes) {
397
- for (i = 0, l = this.scopes.length; i < l; i++) {
398
- this.scopes[i].resume();
398
+ const scopes = this.scopes.slice();
399
+ for (i = 0, l = scopes.length; i < l; i++) {
400
+ scopes[i].resume();
399
401
  }
400
402
  }
401
- for (i = 0, l = this.effects.length; i < l; i++) {
402
- this.effects[i].resume();
403
+ const effects = this.effects.slice();
404
+ for (i = 0, l = effects.length; i < l; i++) {
405
+ effects[i].resume();
403
406
  }
404
407
  }
405
408
  }
@@ -461,8 +464,9 @@ class EffectScope {
461
464
  }
462
465
  this.cleanups.length = 0;
463
466
  if (this.scopes) {
464
- for (i = 0, l = this.scopes.length; i < l; i++) {
465
- this.scopes[i].stop(true);
467
+ const scopes = this.scopes.slice();
468
+ for (i = 0, l = scopes.length; i < l; i++) {
469
+ scopes[i].stop(true);
466
470
  }
467
471
  this.scopes.length = 0;
468
472
  }
@@ -1371,7 +1375,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1371
1375
  value,
1372
1376
  isRef(target) ? target : receiver
1373
1377
  );
1374
- if (target === toRaw(receiver)) {
1378
+ if (target === toRaw(receiver) && result) {
1375
1379
  if (!hadKey) {
1376
1380
  trigger(target, "add", key, value);
1377
1381
  } else if (hasChanged(value, oldValue)) {
@@ -2959,10 +2963,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
2959
2963
  setBlockTracking(-1);
2960
2964
  }
2961
2965
  const prevInstance = setCurrentRenderingInstance(ctx);
2966
+ const prevStackSize = blockStack.length;
2962
2967
  let res;
2963
2968
  try {
2964
2969
  res = fn(...args);
2965
2970
  } finally {
2971
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
2966
2972
  setCurrentRenderingInstance(prevInstance);
2967
2973
  if (renderFnWithContext._d) {
2968
2974
  setBlockTracking(1);
@@ -3381,11 +3387,9 @@ const TeleportImpl = {
3381
3387
  }
3382
3388
  } else {
3383
3389
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3384
- const nextTarget = n2.target = resolveTarget(
3385
- n2.props,
3386
- querySelector
3387
- );
3390
+ const nextTarget = resolveTarget(n2.props, querySelector);
3388
3391
  if (nextTarget) {
3392
+ n2.target = nextTarget;
3389
3393
  moveTeleport(
3390
3394
  n2,
3391
3395
  nextTarget,
@@ -3423,7 +3427,8 @@ const TeleportImpl = {
3423
3427
  target,
3424
3428
  props
3425
3429
  } = vnode;
3426
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3430
+ const disabled = isTeleportDisabled(props);
3431
+ const shouldRemove = doRemove || !disabled;
3427
3432
  const pendingMount = pendingMounts.get(vnode);
3428
3433
  if (pendingMount) {
3429
3434
  pendingMount.flags |= 8;
@@ -3434,7 +3439,7 @@ const TeleportImpl = {
3434
3439
  hostRemove(targetAnchor);
3435
3440
  }
3436
3441
  doRemove && hostRemove(anchor);
3437
- if (!pendingMount && shapeFlag & 16) {
3442
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3438
3443
  for (let i = 0; i < children.length; i++) {
3439
3444
  const child = children[i];
3440
3445
  unmount(
@@ -4369,7 +4374,15 @@ function createHydrationFunctions(rendererInternals) {
4369
4374
  };
4370
4375
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4371
4376
  optimized = optimized || !!vnode.dynamicChildren;
4372
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4377
+ const {
4378
+ type,
4379
+ dynamicProps,
4380
+ props,
4381
+ patchFlag,
4382
+ shapeFlag,
4383
+ dirs,
4384
+ transition
4385
+ } = vnode;
4373
4386
  const forcePatch = type === "input" || type === "option";
4374
4387
  {
4375
4388
  if (dirs) {
@@ -4440,6 +4453,7 @@ Server rendered element contains more child nodes than client vdom.`
4440
4453
  if (props) {
4441
4454
  {
4442
4455
  const isCustomElement = el.tagName.includes("-");
4456
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
4443
4457
  for (const key in props) {
4444
4458
  if (// #11189 skip if this node has directives that have created hooks
4445
4459
  // as it could have mutated the DOM in any possible way
@@ -4447,8 +4461,8 @@ Server rendered element contains more child nodes than client vdom.`
4447
4461
  logMismatchError();
4448
4462
  }
4449
4463
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4450
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
4451
- patchProp(el, key, null, props[key], void 0, parentComponent);
4464
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
4465
+ patchProp(el, key, null, props[key], namespace, parentComponent);
4452
4466
  }
4453
4467
  }
4454
4468
  }
@@ -4552,7 +4566,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4552
4566
  }
4553
4567
  };
4554
4568
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
4555
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
4569
+ if (!isNodeMismatchAllowed(node, vnode)) {
4556
4570
  warn$1(
4557
4571
  `Hydration node mismatch:
4558
4572
  - rendered on server:`,
@@ -4767,7 +4781,12 @@ function isMismatchAllowed(el, allowedType) {
4767
4781
  el = el.parentElement;
4768
4782
  }
4769
4783
  }
4770
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
4784
+ return isMismatchAllowedByAttr(
4785
+ el && el.getAttribute(allowMismatchAttr),
4786
+ allowedType
4787
+ );
4788
+ }
4789
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
4771
4790
  if (allowedAttr == null) {
4772
4791
  return false;
4773
4792
  } else if (allowedAttr === "") {
@@ -4780,6 +4799,19 @@ function isMismatchAllowed(el, allowedType) {
4780
4799
  return list.includes(MismatchTypeString[allowedType]);
4781
4800
  }
4782
4801
  }
4802
+ function isNodeMismatchAllowed(node, vnode) {
4803
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
4804
+ }
4805
+ function isMismatchAllowedByNode(node) {
4806
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
4807
+ node.getAttribute(allowMismatchAttr),
4808
+ 1 /* CHILDREN */
4809
+ );
4810
+ }
4811
+ function isMismatchAllowedByVNode({ props }) {
4812
+ const allowedAttr = props && props[allowMismatchAttr];
4813
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
4814
+ }
4783
4815
 
4784
4816
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
4785
4817
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -4933,6 +4965,7 @@ function defineAsyncComponent(source) {
4933
4965
  name: "AsyncComponentWrapper",
4934
4966
  __asyncLoader: load,
4935
4967
  __asyncHydrate(el, instance, hydrate) {
4968
+ const wasConnected = el.isConnected;
4936
4969
  let patched = false;
4937
4970
  (instance.bu || (instance.bu = [])).push(() => patched = true);
4938
4971
  const performHydrate = () => {
@@ -4944,6 +4977,7 @@ function defineAsyncComponent(source) {
4944
4977
  }
4945
4978
  return;
4946
4979
  }
4980
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
4947
4981
  hydrate();
4948
4982
  };
4949
4983
  const doHydrate = hydrateStrategy ? () => {
@@ -5502,14 +5536,15 @@ function createSlots(slots, dynamicSlots) {
5502
5536
  return slots;
5503
5537
  }
5504
5538
 
5505
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5539
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
5506
5540
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
5507
- const hasProps = Object.keys(props).length > 0;
5508
- if (name !== "default") props.name = name;
5541
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
5542
+ const hasProps = Object.keys(slotProps).length > 0;
5543
+ if (name !== "default") slotProps.name = name;
5509
5544
  return openBlock(), createBlock(
5510
5545
  Fragment,
5511
5546
  null,
5512
- [createVNode("slot", props, fallback && fallback())],
5547
+ [createVNode("slot", slotProps, fallback && fallback())],
5513
5548
  hasProps ? -2 : 64
5514
5549
  );
5515
5550
  }
@@ -5523,26 +5558,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5523
5558
  if (slot && slot._c) {
5524
5559
  slot._d = false;
5525
5560
  }
5561
+ const prevStackSize = blockStack.length;
5526
5562
  openBlock();
5527
- const validSlotContent = slot && ensureValidVNode(slot(props));
5528
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
5529
- // key attached in the `createSlots` helper, respect that
5530
- validSlotContent && validSlotContent.key;
5531
- const rendered = createBlock(
5532
- Fragment,
5533
- {
5534
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
5535
- (!validSlotContent && fallback ? "_fb" : "")
5536
- },
5537
- validSlotContent || (fallback ? fallback() : []),
5538
- validSlotContent && slots._ === 1 ? 64 : -2
5539
- );
5563
+ let rendered;
5564
+ try {
5565
+ const validSlotContent = slot && ensureValidVNode(slot(props));
5566
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
5567
+ // key attached in the `createSlots` helper, respect that
5568
+ validSlotContent && validSlotContent.key;
5569
+ rendered = createBlock(
5570
+ Fragment,
5571
+ {
5572
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
5573
+ (!validSlotContent && fallback ? "_fb" : "")
5574
+ },
5575
+ validSlotContent || (fallback ? fallback() : []),
5576
+ validSlotContent && slots._ === 1 ? 64 : -2
5577
+ );
5578
+ } catch (err) {
5579
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
5580
+ throw err;
5581
+ } finally {
5582
+ if (slot && slot._c) {
5583
+ slot._d = true;
5584
+ }
5585
+ }
5540
5586
  if (!noSlotted && rendered.scopeId) {
5541
5587
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
5542
5588
  }
5543
- if (slot && slot._c) {
5544
- slot._d = true;
5545
- }
5546
5589
  return rendered;
5547
5590
  }
5548
5591
  function ensureValidVNode(vnodes) {
@@ -6777,7 +6820,8 @@ function isEmitListener(options, key) {
6777
6820
  if (!options || !isOn(key)) {
6778
6821
  return false;
6779
6822
  }
6780
- key = key.slice(2).replace(/Once$/, "");
6823
+ key = key.slice(2);
6824
+ key = key === "Once" ? key : key.replace(/Once$/, "");
6781
6825
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
6782
6826
  }
6783
6827
 
@@ -8001,7 +8045,12 @@ function baseCreateRenderer(options, createHydrationFns) {
8001
8045
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
8002
8046
  }
8003
8047
  parentComponent && toggleRecurse(parentComponent, true);
8004
- if (isHmrUpdating) {
8048
+ if (
8049
+ // HMR updated, force full diff
8050
+ isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
8051
+ // Force full diff when block metadata is unstable.
8052
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
8053
+ ) {
8005
8054
  patchFlag = 0;
8006
8055
  optimized = false;
8007
8056
  dynamicChildren = null;
@@ -10134,6 +10183,10 @@ function normalizeChildren(vnode, children) {
10134
10183
  }
10135
10184
  }
10136
10185
  } else if (isFunction(children)) {
10186
+ if (shapeFlag & (1 | 64)) {
10187
+ normalizeChildren(vnode, { default: children });
10188
+ return;
10189
+ }
10137
10190
  children = { default: children, _ctx: currentRenderingInstance };
10138
10191
  type = 32;
10139
10192
  } else {
@@ -10852,7 +10905,7 @@ function isMemoSame(cached, memo) {
10852
10905
  return true;
10853
10906
  }
10854
10907
 
10855
- const version = "3.5.38";
10908
+ const version = "3.5.40";
10856
10909
  const warn = warn$1 ;
10857
10910
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10858
10911
  const devtools = devtools$1 ;
@@ -11585,16 +11638,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
11585
11638
  }
11586
11639
  }
11587
11640
  }
11588
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
11641
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
11642
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
11589
11643
  function parseName(name) {
11590
11644
  let options;
11591
- if (optionsModifierRE.test(name)) {
11592
- options = {};
11593
- let m;
11594
- while (m = name.match(optionsModifierRE)) {
11595
- name = name.slice(0, name.length - m[0].length);
11596
- options[m[0].toLowerCase()] = true;
11597
- }
11645
+ let m;
11646
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
11647
+ if (!options) options = {};
11648
+ name = name.slice(0, name.length - m[1].length);
11649
+ options[m[1].toLowerCase()] = true;
11598
11650
  }
11599
11651
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
11600
11652
  return [event, options];
@@ -12556,13 +12608,13 @@ const vModelSelect = {
12556
12608
  // <select multiple> value need to be deep traversed
12557
12609
  deep: true,
12558
12610
  created(el, { value, modifiers: { number } }, vnode) {
12559
- const isSetModel = isSet(value);
12611
+ el._modelValue = value;
12560
12612
  addEventListener(el, "change", () => {
12561
12613
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
12562
12614
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
12563
12615
  );
12564
12616
  el[assignKey](
12565
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
12617
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
12566
12618
  );
12567
12619
  el._assigning = true;
12568
12620
  nextTick(() => {
@@ -12576,7 +12628,8 @@ const vModelSelect = {
12576
12628
  mounted(el, { value }) {
12577
12629
  setSelected(el, value);
12578
12630
  },
12579
- beforeUpdate(el, _binding, vnode) {
12631
+ beforeUpdate(el, { value }, vnode) {
12632
+ el._modelValue = value;
12580
12633
  el[assignKey] = getModelAssigner(vnode);
12581
12634
  },
12582
12635
  updated(el, { value }) {