@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.
@@ -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
  **/
@@ -449,8 +449,9 @@ class EffectScope {
449
449
  this._isPaused = true;
450
450
  let i, l;
451
451
  if (this.scopes) {
452
- for (i = 0, l = this.scopes.length; i < l; i++) {
453
- this.scopes[i].pause();
452
+ const scopes = this.scopes.slice();
453
+ for (i = 0, l = scopes.length; i < l; i++) {
454
+ scopes[i].pause();
454
455
  }
455
456
  }
456
457
  for (i = 0, l = this.effects.length; i < l; i++) {
@@ -467,12 +468,14 @@ class EffectScope {
467
468
  this._isPaused = false;
468
469
  let i, l;
469
470
  if (this.scopes) {
470
- for (i = 0, l = this.scopes.length; i < l; i++) {
471
- this.scopes[i].resume();
471
+ const scopes = this.scopes.slice();
472
+ for (i = 0, l = scopes.length; i < l; i++) {
473
+ scopes[i].resume();
472
474
  }
473
475
  }
474
- for (i = 0, l = this.effects.length; i < l; i++) {
475
- this.effects[i].resume();
476
+ const effects = this.effects.slice();
477
+ for (i = 0, l = effects.length; i < l; i++) {
478
+ effects[i].resume();
476
479
  }
477
480
  }
478
481
  }
@@ -534,8 +537,9 @@ class EffectScope {
534
537
  }
535
538
  this.cleanups.length = 0;
536
539
  if (this.scopes) {
537
- for (i = 0, l = this.scopes.length; i < l; i++) {
538
- this.scopes[i].stop(true);
540
+ const scopes = this.scopes.slice();
541
+ for (i = 0, l = scopes.length; i < l; i++) {
542
+ scopes[i].stop(true);
539
543
  }
540
544
  this.scopes.length = 0;
541
545
  }
@@ -1448,7 +1452,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1448
1452
  value,
1449
1453
  isRef(target) ? target : receiver
1450
1454
  );
1451
- if (target === toRaw(receiver)) {
1455
+ if (target === toRaw(receiver) && result) {
1452
1456
  if (!hadKey) {
1453
1457
  trigger(target, "add", key, value);
1454
1458
  } else if (hasChanged(value, oldValue)) {
@@ -3475,10 +3479,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
3475
3479
  setBlockTracking(-1);
3476
3480
  }
3477
3481
  const prevInstance = setCurrentRenderingInstance(ctx);
3482
+ const prevStackSize = blockStack.length;
3478
3483
  let res;
3479
3484
  try {
3480
3485
  res = fn(...args);
3481
3486
  } finally {
3487
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
3482
3488
  setCurrentRenderingInstance(prevInstance);
3483
3489
  if (renderFnWithContext._d) {
3484
3490
  setBlockTracking(1);
@@ -3941,11 +3947,9 @@ const TeleportImpl = {
3941
3947
  }
3942
3948
  } else {
3943
3949
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3944
- const nextTarget = n2.target = resolveTarget(
3945
- n2.props,
3946
- querySelector
3947
- );
3950
+ const nextTarget = resolveTarget(n2.props, querySelector);
3948
3951
  if (nextTarget) {
3952
+ n2.target = nextTarget;
3949
3953
  moveTeleport(
3950
3954
  n2,
3951
3955
  nextTarget,
@@ -3983,7 +3987,8 @@ const TeleportImpl = {
3983
3987
  target,
3984
3988
  props
3985
3989
  } = vnode;
3986
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3990
+ const disabled = isTeleportDisabled(props);
3991
+ const shouldRemove = doRemove || !disabled;
3987
3992
  const pendingMount = pendingMounts.get(vnode);
3988
3993
  if (pendingMount) {
3989
3994
  pendingMount.flags |= 8;
@@ -3994,7 +3999,7 @@ const TeleportImpl = {
3994
3999
  hostRemove(targetAnchor);
3995
4000
  }
3996
4001
  doRemove && hostRemove(anchor);
3997
- if (!pendingMount && shapeFlag & 16) {
4002
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3998
4003
  for (let i = 0; i < children.length; i++) {
3999
4004
  const child = children[i];
4000
4005
  unmount(
@@ -4933,9 +4938,18 @@ function createHydrationFunctions(rendererInternals) {
4933
4938
  };
4934
4939
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4935
4940
  optimized = optimized || !!vnode.dynamicChildren;
4936
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4941
+ const {
4942
+ type,
4943
+ dynamicProps,
4944
+ props,
4945
+ patchFlag,
4946
+ shapeFlag,
4947
+ dirs,
4948
+ transition
4949
+ } = vnode;
4937
4950
  const forcePatch = type === "input" || type === "option";
4938
- if (!!(process.env.NODE_ENV !== "production") || forcePatch || patchFlag !== -1) {
4951
+ const hasDynamicProps = !!dynamicProps;
4952
+ if (!!(process.env.NODE_ENV !== "production") || forcePatch || hasDynamicProps || patchFlag !== -1) {
4939
4953
  if (dirs) {
4940
4954
  invokeDirectiveHook(vnode, null, parentComponent, "created");
4941
4955
  }
@@ -5002,8 +5016,9 @@ Server rendered element contains more child nodes than client vdom.`
5002
5016
  }
5003
5017
  }
5004
5018
  if (props) {
5005
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || !optimized || patchFlag & (16 | 32)) {
5019
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || hasDynamicProps || !optimized || patchFlag & (16 | 32)) {
5006
5020
  const isCustomElement = el.tagName.includes("-");
5021
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
5007
5022
  for (const key in props) {
5008
5023
  if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && // #11189 skip if this node has directives that have created hooks
5009
5024
  // as it could have mutated the DOM in any possible way
@@ -5011,8 +5026,8 @@ Server rendered element contains more child nodes than client vdom.`
5011
5026
  logMismatchError();
5012
5027
  }
5013
5028
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
5014
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
5015
- patchProp(el, key, null, props[key], void 0, parentComponent);
5029
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
5030
+ patchProp(el, key, null, props[key], namespace, parentComponent);
5016
5031
  }
5017
5032
  }
5018
5033
  } else if (props.onClick) {
@@ -5127,7 +5142,7 @@ Server rendered element contains fewer child nodes than client vdom.`
5127
5142
  }
5128
5143
  };
5129
5144
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5130
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
5145
+ if (!isNodeMismatchAllowed(node, vnode)) {
5131
5146
  (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
5132
5147
  `Hydration node mismatch:
5133
5148
  - rendered on server:`,
@@ -5342,7 +5357,12 @@ function isMismatchAllowed(el, allowedType) {
5342
5357
  el = el.parentElement;
5343
5358
  }
5344
5359
  }
5345
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
5360
+ return isMismatchAllowedByAttr(
5361
+ el && el.getAttribute(allowMismatchAttr),
5362
+ allowedType
5363
+ );
5364
+ }
5365
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
5346
5366
  if (allowedAttr == null) {
5347
5367
  return false;
5348
5368
  } else if (allowedAttr === "") {
@@ -5355,6 +5375,19 @@ function isMismatchAllowed(el, allowedType) {
5355
5375
  return list.includes(MismatchTypeString[allowedType]);
5356
5376
  }
5357
5377
  }
5378
+ function isNodeMismatchAllowed(node, vnode) {
5379
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
5380
+ }
5381
+ function isMismatchAllowedByNode(node) {
5382
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
5383
+ node.getAttribute(allowMismatchAttr),
5384
+ 1 /* CHILDREN */
5385
+ );
5386
+ }
5387
+ function isMismatchAllowedByVNode({ props }) {
5388
+ const allowedAttr = props && props[allowMismatchAttr];
5389
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
5390
+ }
5358
5391
 
5359
5392
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
5360
5393
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -5508,6 +5541,7 @@ function defineAsyncComponent(source) {
5508
5541
  name: "AsyncComponentWrapper",
5509
5542
  __asyncLoader: load,
5510
5543
  __asyncHydrate(el, instance, hydrate) {
5544
+ const wasConnected = el.isConnected;
5511
5545
  let patched = false;
5512
5546
  (instance.bu || (instance.bu = [])).push(() => patched = true);
5513
5547
  const performHydrate = () => {
@@ -5519,6 +5553,7 @@ function defineAsyncComponent(source) {
5519
5553
  }
5520
5554
  return;
5521
5555
  }
5556
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
5522
5557
  hydrate();
5523
5558
  };
5524
5559
  const doHydrate = hydrateStrategy ? () => {
@@ -6368,14 +6403,15 @@ function createSlots(slots, dynamicSlots) {
6368
6403
  return slots;
6369
6404
  }
6370
6405
 
6371
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6406
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
6372
6407
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6373
- const hasProps = Object.keys(props).length > 0;
6374
- if (name !== "default") props.name = name;
6408
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
6409
+ const hasProps = Object.keys(slotProps).length > 0;
6410
+ if (name !== "default") slotProps.name = name;
6375
6411
  return openBlock(), createBlock(
6376
6412
  Fragment,
6377
6413
  null,
6378
- [createVNode("slot", props, fallback && fallback())],
6414
+ [createVNode("slot", slotProps, fallback && fallback())],
6379
6415
  hasProps ? -2 : 64
6380
6416
  );
6381
6417
  }
@@ -6389,26 +6425,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6389
6425
  if (slot && slot._c) {
6390
6426
  slot._d = false;
6391
6427
  }
6428
+ const prevStackSize = blockStack.length;
6392
6429
  openBlock();
6393
- const validSlotContent = slot && ensureValidVNode(slot(props));
6394
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
6395
- // key attached in the `createSlots` helper, respect that
6396
- validSlotContent && validSlotContent.key;
6397
- const rendered = createBlock(
6398
- Fragment,
6399
- {
6400
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6401
- (!validSlotContent && fallback ? "_fb" : "")
6402
- },
6403
- validSlotContent || (fallback ? fallback() : []),
6404
- validSlotContent && slots._ === 1 ? 64 : -2
6405
- );
6430
+ let rendered;
6431
+ try {
6432
+ const validSlotContent = slot && ensureValidVNode(slot(props));
6433
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
6434
+ // key attached in the `createSlots` helper, respect that
6435
+ validSlotContent && validSlotContent.key;
6436
+ rendered = createBlock(
6437
+ Fragment,
6438
+ {
6439
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6440
+ (!validSlotContent && fallback ? "_fb" : "")
6441
+ },
6442
+ validSlotContent || (fallback ? fallback() : []),
6443
+ validSlotContent && slots._ === 1 ? 64 : -2
6444
+ );
6445
+ } catch (err) {
6446
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
6447
+ throw err;
6448
+ } finally {
6449
+ if (slot && slot._c) {
6450
+ slot._d = true;
6451
+ }
6452
+ }
6406
6453
  if (!noSlotted && rendered.scopeId) {
6407
6454
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
6408
6455
  }
6409
- if (slot && slot._c) {
6410
- slot._d = true;
6411
- }
6412
6456
  return rendered;
6413
6457
  }
6414
6458
  function ensureValidVNode(vnodes) {
@@ -7588,7 +7632,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7588
7632
  return vm;
7589
7633
  }
7590
7634
  }
7591
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
7635
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
7592
7636
  Vue.config = singletonApp.config;
7593
7637
  Vue.use = (plugin, ...options) => {
7594
7638
  if (plugin && isFunction(plugin.install)) {
@@ -8451,7 +8495,8 @@ function isEmitListener(options, key) {
8451
8495
  if (key.startsWith(compatModelEventPrefix)) {
8452
8496
  return true;
8453
8497
  }
8454
- key = key.slice(2).replace(/Once$/, "");
8498
+ key = key.slice(2);
8499
+ key = key === "Once" ? key : key.replace(/Once$/, "");
8455
8500
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8456
8501
  }
8457
8502
 
@@ -9795,7 +9840,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9795
9840
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
9796
9841
  }
9797
9842
  parentComponent && toggleRecurse(parentComponent, true);
9798
- if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating) {
9843
+ if (
9844
+ // HMR updated, force full diff
9845
+ !!(process.env.NODE_ENV !== "production") && isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
9846
+ // Force full diff when block metadata is unstable.
9847
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
9848
+ ) {
9799
9849
  patchFlag = 0;
9800
9850
  optimized = false;
9801
9851
  dynamicChildren = null;
@@ -12040,6 +12090,10 @@ function normalizeChildren(vnode, children) {
12040
12090
  }
12041
12091
  }
12042
12092
  } else if (isFunction(children)) {
12093
+ if (shapeFlag & (1 | 64)) {
12094
+ normalizeChildren(vnode, { default: children });
12095
+ return;
12096
+ }
12043
12097
  children = { default: children, _ctx: currentRenderingInstance };
12044
12098
  type = 32;
12045
12099
  } else {
@@ -12784,7 +12838,7 @@ function isMemoSame(cached, memo) {
12784
12838
  return true;
12785
12839
  }
12786
12840
 
12787
- const version = "3.5.38";
12841
+ const version = "3.5.40";
12788
12842
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12789
12843
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12790
12844
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13605,16 +13659,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
13605
13659
  }
13606
13660
  }
13607
13661
  }
13608
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
13662
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
13663
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
13609
13664
  function parseName(name) {
13610
13665
  let options;
13611
- if (optionsModifierRE.test(name)) {
13612
- options = {};
13613
- let m;
13614
- while (m = name.match(optionsModifierRE)) {
13615
- name = name.slice(0, name.length - m[0].length);
13616
- options[m[0].toLowerCase()] = true;
13617
- }
13666
+ let m;
13667
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
13668
+ if (!options) options = {};
13669
+ name = name.slice(0, name.length - m[1].length);
13670
+ options[m[1].toLowerCase()] = true;
13618
13671
  }
13619
13672
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
13620
13673
  return [event, options];
@@ -14585,13 +14638,13 @@ const vModelSelect = {
14585
14638
  // <select multiple> value need to be deep traversed
14586
14639
  deep: true,
14587
14640
  created(el, { value, modifiers: { number } }, vnode) {
14588
- const isSetModel = isSet(value);
14641
+ el._modelValue = value;
14589
14642
  addEventListener(el, "change", () => {
14590
14643
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
14591
14644
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
14592
14645
  );
14593
14646
  el[assignKey](
14594
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
14647
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
14595
14648
  );
14596
14649
  el._assigning = true;
14597
14650
  nextTick(() => {
@@ -14605,7 +14658,8 @@ const vModelSelect = {
14605
14658
  mounted(el, { value }) {
14606
14659
  setSelected(el, value);
14607
14660
  },
14608
- beforeUpdate(el, _binding, vnode) {
14661
+ beforeUpdate(el, { value }, vnode) {
14662
+ el._modelValue = value;
14609
14663
  el[assignKey] = getModelAssigner(vnode);
14610
14664
  },
14611
14665
  updated(el, { value }) {
@@ -16538,6 +16592,9 @@ function getUnnormalizedProps(props, callPath = []) {
16538
16592
  return [props, callPath];
16539
16593
  }
16540
16594
  function injectProp(node, prop, context) {
16595
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
16596
+ return;
16597
+ }
16541
16598
  let propsWithInjection;
16542
16599
  let props = node.type === 13 ? node.props : node.arguments[2];
16543
16600
  let callPath = [];
@@ -16595,6 +16652,24 @@ function injectProp(node, prop, context) {
16595
16652
  }
16596
16653
  }
16597
16654
  }
16655
+ function injectSlotKey(node, prop) {
16656
+ var _a, _b, _c;
16657
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
16658
+ return false;
16659
+ }
16660
+ const props = node.arguments[2];
16661
+ if (props && !isString(props)) {
16662
+ const [unnormalizedProps] = getUnnormalizedProps(props);
16663
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
16664
+ return true;
16665
+ }
16666
+ }
16667
+ (_a = node.arguments)[2] || (_a[2] = "{}");
16668
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
16669
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
16670
+ node.arguments[5] = prop.value;
16671
+ return true;
16672
+ }
16598
16673
  function hasProp(prop, props) {
16599
16674
  let result = false;
16600
16675
  if (prop.key.type === 4) {
@@ -20229,7 +20304,7 @@ function rewriteFilter(node, context) {
20229
20304
  if (child.type === 4) {
20230
20305
  parseFilter(child, context);
20231
20306
  } else if (child.type === 8) {
20232
- rewriteFilter(node, context);
20307
+ rewriteFilter(child, context);
20233
20308
  } else if (child.type === 5) {
20234
20309
  rewriteFilter(child.content, context);
20235
20310
  }