@vue/compat 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.38
2
+ * @vue/compat v3.5.40
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -502,8 +502,9 @@ class EffectScope {
502
502
  this._isPaused = true;
503
503
  let i, l;
504
504
  if (this.scopes) {
505
- for (i = 0, l = this.scopes.length; i < l; i++) {
506
- this.scopes[i].pause();
505
+ const scopes = this.scopes.slice();
506
+ for (i = 0, l = scopes.length; i < l; i++) {
507
+ scopes[i].pause();
507
508
  }
508
509
  }
509
510
  for (i = 0, l = this.effects.length; i < l; i++) {
@@ -520,12 +521,14 @@ class EffectScope {
520
521
  this._isPaused = false;
521
522
  let i, l;
522
523
  if (this.scopes) {
523
- for (i = 0, l = this.scopes.length; i < l; i++) {
524
- this.scopes[i].resume();
524
+ const scopes = this.scopes.slice();
525
+ for (i = 0, l = scopes.length; i < l; i++) {
526
+ scopes[i].resume();
525
527
  }
526
528
  }
527
- for (i = 0, l = this.effects.length; i < l; i++) {
528
- this.effects[i].resume();
529
+ const effects = this.effects.slice();
530
+ for (i = 0, l = effects.length; i < l; i++) {
531
+ effects[i].resume();
529
532
  }
530
533
  }
531
534
  }
@@ -587,8 +590,9 @@ class EffectScope {
587
590
  }
588
591
  this.cleanups.length = 0;
589
592
  if (this.scopes) {
590
- for (i = 0, l = this.scopes.length; i < l; i++) {
591
- this.scopes[i].stop(true);
593
+ const scopes = this.scopes.slice();
594
+ for (i = 0, l = scopes.length; i < l; i++) {
595
+ scopes[i].stop(true);
592
596
  }
593
597
  this.scopes.length = 0;
594
598
  }
@@ -1497,7 +1501,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1497
1501
  value,
1498
1502
  isRef(target) ? target : receiver
1499
1503
  );
1500
- if (target === toRaw(receiver)) {
1504
+ if (target === toRaw(receiver) && result) {
1501
1505
  if (!hadKey) {
1502
1506
  trigger(target, "add", key, value);
1503
1507
  } else if (hasChanged(value, oldValue)) {
@@ -3510,10 +3514,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
3510
3514
  setBlockTracking(-1);
3511
3515
  }
3512
3516
  const prevInstance = setCurrentRenderingInstance(ctx);
3517
+ const prevStackSize = blockStack.length;
3513
3518
  let res;
3514
3519
  try {
3515
3520
  res = fn(...args);
3516
3521
  } finally {
3522
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
3517
3523
  setCurrentRenderingInstance(prevInstance);
3518
3524
  if (renderFnWithContext._d) {
3519
3525
  setBlockTracking(1);
@@ -3976,11 +3982,9 @@ const TeleportImpl = {
3976
3982
  }
3977
3983
  } else {
3978
3984
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3979
- const nextTarget = n2.target = resolveTarget(
3980
- n2.props,
3981
- querySelector
3982
- );
3985
+ const nextTarget = resolveTarget(n2.props, querySelector);
3983
3986
  if (nextTarget) {
3987
+ n2.target = nextTarget;
3984
3988
  moveTeleport(
3985
3989
  n2,
3986
3990
  nextTarget,
@@ -4018,7 +4022,8 @@ const TeleportImpl = {
4018
4022
  target,
4019
4023
  props
4020
4024
  } = vnode;
4021
- const shouldRemove = doRemove || !isTeleportDisabled(props);
4025
+ const disabled = isTeleportDisabled(props);
4026
+ const shouldRemove = doRemove || !disabled;
4022
4027
  const pendingMount = pendingMounts.get(vnode);
4023
4028
  if (pendingMount) {
4024
4029
  pendingMount.flags |= 8;
@@ -4029,7 +4034,7 @@ const TeleportImpl = {
4029
4034
  hostRemove(targetAnchor);
4030
4035
  }
4031
4036
  doRemove && hostRemove(anchor);
4032
- if (!pendingMount && shapeFlag & 16) {
4037
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
4033
4038
  for (let i = 0; i < children.length; i++) {
4034
4039
  const child = children[i];
4035
4040
  unmount(
@@ -4967,7 +4972,15 @@ function createHydrationFunctions(rendererInternals) {
4967
4972
  };
4968
4973
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4969
4974
  optimized = optimized || !!vnode.dynamicChildren;
4970
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4975
+ const {
4976
+ type,
4977
+ dynamicProps,
4978
+ props,
4979
+ patchFlag,
4980
+ shapeFlag,
4981
+ dirs,
4982
+ transition
4983
+ } = vnode;
4971
4984
  const forcePatch = type === "input" || type === "option";
4972
4985
  {
4973
4986
  if (dirs) {
@@ -5038,6 +5051,7 @@ Server rendered element contains more child nodes than client vdom.`
5038
5051
  if (props) {
5039
5052
  {
5040
5053
  const isCustomElement = el.tagName.includes("-");
5054
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
5041
5055
  for (const key in props) {
5042
5056
  if (// #11189 skip if this node has directives that have created hooks
5043
5057
  // as it could have mutated the DOM in any possible way
@@ -5045,8 +5059,8 @@ Server rendered element contains more child nodes than client vdom.`
5045
5059
  logMismatchError();
5046
5060
  }
5047
5061
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
5048
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
5049
- patchProp(el, key, null, props[key], void 0, parentComponent);
5062
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
5063
+ patchProp(el, key, null, props[key], namespace, parentComponent);
5050
5064
  }
5051
5065
  }
5052
5066
  }
@@ -5150,7 +5164,7 @@ Server rendered element contains fewer child nodes than client vdom.`
5150
5164
  }
5151
5165
  };
5152
5166
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5153
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
5167
+ if (!isNodeMismatchAllowed(node, vnode)) {
5154
5168
  warn$1(
5155
5169
  `Hydration node mismatch:
5156
5170
  - rendered on server:`,
@@ -5365,7 +5379,12 @@ function isMismatchAllowed(el, allowedType) {
5365
5379
  el = el.parentElement;
5366
5380
  }
5367
5381
  }
5368
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
5382
+ return isMismatchAllowedByAttr(
5383
+ el && el.getAttribute(allowMismatchAttr),
5384
+ allowedType
5385
+ );
5386
+ }
5387
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
5369
5388
  if (allowedAttr == null) {
5370
5389
  return false;
5371
5390
  } else if (allowedAttr === "") {
@@ -5378,6 +5397,19 @@ function isMismatchAllowed(el, allowedType) {
5378
5397
  return list.includes(MismatchTypeString[allowedType]);
5379
5398
  }
5380
5399
  }
5400
+ function isNodeMismatchAllowed(node, vnode) {
5401
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
5402
+ }
5403
+ function isMismatchAllowedByNode(node) {
5404
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
5405
+ node.getAttribute(allowMismatchAttr),
5406
+ 1 /* CHILDREN */
5407
+ );
5408
+ }
5409
+ function isMismatchAllowedByVNode({ props }) {
5410
+ const allowedAttr = props && props[allowMismatchAttr];
5411
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
5412
+ }
5381
5413
 
5382
5414
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
5383
5415
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -5531,6 +5563,7 @@ function defineAsyncComponent(source) {
5531
5563
  name: "AsyncComponentWrapper",
5532
5564
  __asyncLoader: load,
5533
5565
  __asyncHydrate(el, instance, hydrate) {
5566
+ const wasConnected = el.isConnected;
5534
5567
  let patched = false;
5535
5568
  (instance.bu || (instance.bu = [])).push(() => patched = true);
5536
5569
  const performHydrate = () => {
@@ -5542,6 +5575,7 @@ function defineAsyncComponent(source) {
5542
5575
  }
5543
5576
  return;
5544
5577
  }
5578
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
5545
5579
  hydrate();
5546
5580
  };
5547
5581
  const doHydrate = hydrateStrategy ? () => {
@@ -6388,14 +6422,15 @@ function createSlots(slots, dynamicSlots) {
6388
6422
  return slots;
6389
6423
  }
6390
6424
 
6391
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6425
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
6392
6426
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6393
- const hasProps = Object.keys(props).length > 0;
6394
- if (name !== "default") props.name = name;
6427
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
6428
+ const hasProps = Object.keys(slotProps).length > 0;
6429
+ if (name !== "default") slotProps.name = name;
6395
6430
  return openBlock(), createBlock(
6396
6431
  Fragment,
6397
6432
  null,
6398
- [createVNode("slot", props, fallback && fallback())],
6433
+ [createVNode("slot", slotProps, fallback && fallback())],
6399
6434
  hasProps ? -2 : 64
6400
6435
  );
6401
6436
  }
@@ -6409,26 +6444,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6409
6444
  if (slot && slot._c) {
6410
6445
  slot._d = false;
6411
6446
  }
6447
+ const prevStackSize = blockStack.length;
6412
6448
  openBlock();
6413
- const validSlotContent = slot && ensureValidVNode(slot(props));
6414
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
6415
- // key attached in the `createSlots` helper, respect that
6416
- validSlotContent && validSlotContent.key;
6417
- const rendered = createBlock(
6418
- Fragment,
6419
- {
6420
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6421
- (!validSlotContent && fallback ? "_fb" : "")
6422
- },
6423
- validSlotContent || (fallback ? fallback() : []),
6424
- validSlotContent && slots._ === 1 ? 64 : -2
6425
- );
6449
+ let rendered;
6450
+ try {
6451
+ const validSlotContent = slot && ensureValidVNode(slot(props));
6452
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
6453
+ // key attached in the `createSlots` helper, respect that
6454
+ validSlotContent && validSlotContent.key;
6455
+ rendered = createBlock(
6456
+ Fragment,
6457
+ {
6458
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6459
+ (!validSlotContent && fallback ? "_fb" : "")
6460
+ },
6461
+ validSlotContent || (fallback ? fallback() : []),
6462
+ validSlotContent && slots._ === 1 ? 64 : -2
6463
+ );
6464
+ } catch (err) {
6465
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
6466
+ throw err;
6467
+ } finally {
6468
+ if (slot && slot._c) {
6469
+ slot._d = true;
6470
+ }
6471
+ }
6426
6472
  if (!noSlotted && rendered.scopeId) {
6427
6473
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
6428
6474
  }
6429
- if (slot && slot._c) {
6430
- slot._d = true;
6431
- }
6432
6475
  return rendered;
6433
6476
  }
6434
6477
  function ensureValidVNode(vnodes) {
@@ -7606,7 +7649,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7606
7649
  return vm;
7607
7650
  }
7608
7651
  }
7609
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
7652
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
7610
7653
  Vue.config = singletonApp.config;
7611
7654
  Vue.use = (plugin, ...options) => {
7612
7655
  if (plugin && isFunction(plugin.install)) {
@@ -8467,7 +8510,8 @@ function isEmitListener(options, key) {
8467
8510
  if (key.startsWith(compatModelEventPrefix)) {
8468
8511
  return true;
8469
8512
  }
8470
- key = key.slice(2).replace(/Once$/, "");
8513
+ key = key.slice(2);
8514
+ key = key === "Once" ? key : key.replace(/Once$/, "");
8471
8515
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8472
8516
  }
8473
8517
 
@@ -9784,7 +9828,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9784
9828
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
9785
9829
  }
9786
9830
  parentComponent && toggleRecurse(parentComponent, true);
9787
- if (isHmrUpdating) {
9831
+ if (
9832
+ // HMR updated, force full diff
9833
+ isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
9834
+ // Force full diff when block metadata is unstable.
9835
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
9836
+ ) {
9788
9837
  patchFlag = 0;
9789
9838
  optimized = false;
9790
9839
  dynamicChildren = null;
@@ -12018,6 +12067,10 @@ function normalizeChildren(vnode, children) {
12018
12067
  }
12019
12068
  }
12020
12069
  } else if (isFunction(children)) {
12070
+ if (shapeFlag & (1 | 64)) {
12071
+ normalizeChildren(vnode, { default: children });
12072
+ return;
12073
+ }
12021
12074
  children = { default: children, _ctx: currentRenderingInstance };
12022
12075
  type = 32;
12023
12076
  } else {
@@ -12748,7 +12801,7 @@ function isMemoSame(cached, memo) {
12748
12801
  return true;
12749
12802
  }
12750
12803
 
12751
- const version = "3.5.38";
12804
+ const version = "3.5.40";
12752
12805
  const warn = warn$1 ;
12753
12806
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12754
12807
  const devtools = devtools$1 ;
@@ -13501,16 +13554,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
13501
13554
  }
13502
13555
  }
13503
13556
  }
13504
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
13557
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
13558
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
13505
13559
  function parseName(name) {
13506
13560
  let options;
13507
- if (optionsModifierRE.test(name)) {
13508
- options = {};
13509
- let m;
13510
- while (m = name.match(optionsModifierRE)) {
13511
- name = name.slice(0, name.length - m[0].length);
13512
- options[m[0].toLowerCase()] = true;
13513
- }
13561
+ let m;
13562
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
13563
+ if (!options) options = {};
13564
+ name = name.slice(0, name.length - m[1].length);
13565
+ options[m[1].toLowerCase()] = true;
13514
13566
  }
13515
13567
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
13516
13568
  return [event, options];
@@ -14481,13 +14533,13 @@ const vModelSelect = {
14481
14533
  // <select multiple> value need to be deep traversed
14482
14534
  deep: true,
14483
14535
  created(el, { value, modifiers: { number } }, vnode) {
14484
- const isSetModel = isSet(value);
14536
+ el._modelValue = value;
14485
14537
  addEventListener(el, "change", () => {
14486
14538
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
14487
14539
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
14488
14540
  );
14489
14541
  el[assignKey](
14490
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
14542
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
14491
14543
  );
14492
14544
  el._assigning = true;
14493
14545
  nextTick(() => {
@@ -14501,7 +14553,8 @@ const vModelSelect = {
14501
14553
  mounted(el, { value }) {
14502
14554
  setSelected(el, value);
14503
14555
  },
14504
- beforeUpdate(el, _binding, vnode) {
14556
+ beforeUpdate(el, { value }, vnode) {
14557
+ el._modelValue = value;
14505
14558
  el[assignKey] = getModelAssigner(vnode);
14506
14559
  },
14507
14560
  updated(el, { value }) {
@@ -16869,6 +16922,9 @@ function getUnnormalizedProps(props, callPath = []) {
16869
16922
  return [props, callPath];
16870
16923
  }
16871
16924
  function injectProp(node, prop, context) {
16925
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
16926
+ return;
16927
+ }
16872
16928
  let propsWithInjection;
16873
16929
  let props = node.type === 13 ? node.props : node.arguments[2];
16874
16930
  let callPath = [];
@@ -16926,6 +16982,24 @@ function injectProp(node, prop, context) {
16926
16982
  }
16927
16983
  }
16928
16984
  }
16985
+ function injectSlotKey(node, prop) {
16986
+ var _a, _b, _c;
16987
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
16988
+ return false;
16989
+ }
16990
+ const props = node.arguments[2];
16991
+ if (props && !isString(props)) {
16992
+ const [unnormalizedProps] = getUnnormalizedProps(props);
16993
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
16994
+ return true;
16995
+ }
16996
+ }
16997
+ (_a = node.arguments)[2] || (_a[2] = "{}");
16998
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
16999
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
17000
+ node.arguments[5] = prop.value;
17001
+ return true;
17002
+ }
16929
17003
  function hasProp(prop, props) {
16930
17004
  let result = false;
16931
17005
  if (prop.key.type === 4) {
@@ -21190,7 +21264,7 @@ function rewriteFilter(node, context) {
21190
21264
  if (child.type === 4) {
21191
21265
  parseFilter(child, context);
21192
21266
  } else if (child.type === 8) {
21193
- rewriteFilter(node, context);
21267
+ rewriteFilter(child, context);
21194
21268
  } else if (child.type === 5) {
21195
21269
  rewriteFilter(child.content, context);
21196
21270
  }