@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
  **/
@@ -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
  }
@@ -1375,7 +1379,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1375
1379
  value,
1376
1380
  isRef(target) ? target : receiver
1377
1381
  );
1378
- if (target === toRaw(receiver)) {
1382
+ if (target === toRaw(receiver) && result) {
1379
1383
  if (!hadKey) {
1380
1384
  trigger(target, "add", key, value);
1381
1385
  } else if (hasChanged(value, oldValue)) {
@@ -3402,10 +3406,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
3402
3406
  setBlockTracking(-1);
3403
3407
  }
3404
3408
  const prevInstance = setCurrentRenderingInstance(ctx);
3409
+ const prevStackSize = blockStack.length;
3405
3410
  let res;
3406
3411
  try {
3407
3412
  res = fn(...args);
3408
3413
  } finally {
3414
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
3409
3415
  setCurrentRenderingInstance(prevInstance);
3410
3416
  if (renderFnWithContext._d) {
3411
3417
  setBlockTracking(1);
@@ -3868,11 +3874,9 @@ const TeleportImpl = {
3868
3874
  }
3869
3875
  } else {
3870
3876
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3871
- const nextTarget = n2.target = resolveTarget(
3872
- n2.props,
3873
- querySelector
3874
- );
3877
+ const nextTarget = resolveTarget(n2.props, querySelector);
3875
3878
  if (nextTarget) {
3879
+ n2.target = nextTarget;
3876
3880
  moveTeleport(
3877
3881
  n2,
3878
3882
  nextTarget,
@@ -3910,7 +3914,8 @@ const TeleportImpl = {
3910
3914
  target,
3911
3915
  props
3912
3916
  } = vnode;
3913
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3917
+ const disabled = isTeleportDisabled(props);
3918
+ const shouldRemove = doRemove || !disabled;
3914
3919
  const pendingMount = pendingMounts.get(vnode);
3915
3920
  if (pendingMount) {
3916
3921
  pendingMount.flags |= 8;
@@ -3921,7 +3926,7 @@ const TeleportImpl = {
3921
3926
  hostRemove(targetAnchor);
3922
3927
  }
3923
3928
  doRemove && hostRemove(anchor);
3924
- if (!pendingMount && shapeFlag & 16) {
3929
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3925
3930
  for (let i = 0; i < children.length; i++) {
3926
3931
  const child = children[i];
3927
3932
  unmount(
@@ -4860,9 +4865,18 @@ function createHydrationFunctions(rendererInternals) {
4860
4865
  };
4861
4866
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4862
4867
  optimized = optimized || !!vnode.dynamicChildren;
4863
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4868
+ const {
4869
+ type,
4870
+ dynamicProps,
4871
+ props,
4872
+ patchFlag,
4873
+ shapeFlag,
4874
+ dirs,
4875
+ transition
4876
+ } = vnode;
4864
4877
  const forcePatch = type === "input" || type === "option";
4865
- if (!!(process.env.NODE_ENV !== "production") || forcePatch || patchFlag !== -1) {
4878
+ const hasDynamicProps = !!dynamicProps;
4879
+ if (!!(process.env.NODE_ENV !== "production") || forcePatch || hasDynamicProps || patchFlag !== -1) {
4866
4880
  if (dirs) {
4867
4881
  invokeDirectiveHook(vnode, null, parentComponent, "created");
4868
4882
  }
@@ -4929,8 +4943,9 @@ Server rendered element contains more child nodes than client vdom.`
4929
4943
  }
4930
4944
  }
4931
4945
  if (props) {
4932
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || !optimized || patchFlag & (16 | 32)) {
4946
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || hasDynamicProps || !optimized || patchFlag & (16 | 32)) {
4933
4947
  const isCustomElement = el.tagName.includes("-");
4948
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
4934
4949
  for (const key in props) {
4935
4950
  if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && // #11189 skip if this node has directives that have created hooks
4936
4951
  // as it could have mutated the DOM in any possible way
@@ -4938,8 +4953,8 @@ Server rendered element contains more child nodes than client vdom.`
4938
4953
  logMismatchError();
4939
4954
  }
4940
4955
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4941
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
4942
- patchProp(el, key, null, props[key], void 0, parentComponent);
4956
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
4957
+ patchProp(el, key, null, props[key], namespace, parentComponent);
4943
4958
  }
4944
4959
  }
4945
4960
  } else if (props.onClick) {
@@ -5054,7 +5069,7 @@ Server rendered element contains fewer child nodes than client vdom.`
5054
5069
  }
5055
5070
  };
5056
5071
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5057
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
5072
+ if (!isNodeMismatchAllowed(node, vnode)) {
5058
5073
  (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
5059
5074
  `Hydration node mismatch:
5060
5075
  - rendered on server:`,
@@ -5269,7 +5284,12 @@ function isMismatchAllowed(el, allowedType) {
5269
5284
  el = el.parentElement;
5270
5285
  }
5271
5286
  }
5272
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
5287
+ return isMismatchAllowedByAttr(
5288
+ el && el.getAttribute(allowMismatchAttr),
5289
+ allowedType
5290
+ );
5291
+ }
5292
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
5273
5293
  if (allowedAttr == null) {
5274
5294
  return false;
5275
5295
  } else if (allowedAttr === "") {
@@ -5282,6 +5302,19 @@ function isMismatchAllowed(el, allowedType) {
5282
5302
  return list.includes(MismatchTypeString[allowedType]);
5283
5303
  }
5284
5304
  }
5305
+ function isNodeMismatchAllowed(node, vnode) {
5306
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
5307
+ }
5308
+ function isMismatchAllowedByNode(node) {
5309
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
5310
+ node.getAttribute(allowMismatchAttr),
5311
+ 1 /* CHILDREN */
5312
+ );
5313
+ }
5314
+ function isMismatchAllowedByVNode({ props }) {
5315
+ const allowedAttr = props && props[allowMismatchAttr];
5316
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
5317
+ }
5285
5318
 
5286
5319
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
5287
5320
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -5435,6 +5468,7 @@ function defineAsyncComponent(source) {
5435
5468
  name: "AsyncComponentWrapper",
5436
5469
  __asyncLoader: load,
5437
5470
  __asyncHydrate(el, instance, hydrate) {
5471
+ const wasConnected = el.isConnected;
5438
5472
  let patched = false;
5439
5473
  (instance.bu || (instance.bu = [])).push(() => patched = true);
5440
5474
  const performHydrate = () => {
@@ -5446,6 +5480,7 @@ function defineAsyncComponent(source) {
5446
5480
  }
5447
5481
  return;
5448
5482
  }
5483
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
5449
5484
  hydrate();
5450
5485
  };
5451
5486
  const doHydrate = hydrateStrategy ? () => {
@@ -6295,14 +6330,15 @@ function createSlots(slots, dynamicSlots) {
6295
6330
  return slots;
6296
6331
  }
6297
6332
 
6298
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6333
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
6299
6334
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6300
- const hasProps = Object.keys(props).length > 0;
6301
- if (name !== "default") props.name = name;
6335
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
6336
+ const hasProps = Object.keys(slotProps).length > 0;
6337
+ if (name !== "default") slotProps.name = name;
6302
6338
  return openBlock(), createBlock(
6303
6339
  Fragment,
6304
6340
  null,
6305
- [createVNode("slot", props, fallback && fallback())],
6341
+ [createVNode("slot", slotProps, fallback && fallback())],
6306
6342
  hasProps ? -2 : 64
6307
6343
  );
6308
6344
  }
@@ -6316,26 +6352,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6316
6352
  if (slot && slot._c) {
6317
6353
  slot._d = false;
6318
6354
  }
6355
+ const prevStackSize = blockStack.length;
6319
6356
  openBlock();
6320
- const validSlotContent = slot && ensureValidVNode(slot(props));
6321
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
6322
- // key attached in the `createSlots` helper, respect that
6323
- validSlotContent && validSlotContent.key;
6324
- const rendered = createBlock(
6325
- Fragment,
6326
- {
6327
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6328
- (!validSlotContent && fallback ? "_fb" : "")
6329
- },
6330
- validSlotContent || (fallback ? fallback() : []),
6331
- validSlotContent && slots._ === 1 ? 64 : -2
6332
- );
6357
+ let rendered;
6358
+ try {
6359
+ const validSlotContent = slot && ensureValidVNode(slot(props));
6360
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
6361
+ // key attached in the `createSlots` helper, respect that
6362
+ validSlotContent && validSlotContent.key;
6363
+ rendered = createBlock(
6364
+ Fragment,
6365
+ {
6366
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6367
+ (!validSlotContent && fallback ? "_fb" : "")
6368
+ },
6369
+ validSlotContent || (fallback ? fallback() : []),
6370
+ validSlotContent && slots._ === 1 ? 64 : -2
6371
+ );
6372
+ } catch (err) {
6373
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
6374
+ throw err;
6375
+ } finally {
6376
+ if (slot && slot._c) {
6377
+ slot._d = true;
6378
+ }
6379
+ }
6333
6380
  if (!noSlotted && rendered.scopeId) {
6334
6381
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
6335
6382
  }
6336
- if (slot && slot._c) {
6337
- slot._d = true;
6338
- }
6339
6383
  return rendered;
6340
6384
  }
6341
6385
  function ensureValidVNode(vnodes) {
@@ -7515,7 +7559,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7515
7559
  return vm;
7516
7560
  }
7517
7561
  }
7518
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
7562
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
7519
7563
  Vue.config = singletonApp.config;
7520
7564
  Vue.use = (plugin, ...options) => {
7521
7565
  if (plugin && isFunction(plugin.install)) {
@@ -8378,7 +8422,8 @@ function isEmitListener(options, key) {
8378
8422
  if (key.startsWith(compatModelEventPrefix)) {
8379
8423
  return true;
8380
8424
  }
8381
- key = key.slice(2).replace(/Once$/, "");
8425
+ key = key.slice(2);
8426
+ key = key === "Once" ? key : key.replace(/Once$/, "");
8382
8427
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8383
8428
  }
8384
8429
 
@@ -9722,7 +9767,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9722
9767
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
9723
9768
  }
9724
9769
  parentComponent && toggleRecurse(parentComponent, true);
9725
- if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating) {
9770
+ if (
9771
+ // HMR updated, force full diff
9772
+ !!(process.env.NODE_ENV !== "production") && isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
9773
+ // Force full diff when block metadata is unstable.
9774
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
9775
+ ) {
9726
9776
  patchFlag = 0;
9727
9777
  optimized = false;
9728
9778
  dynamicChildren = null;
@@ -11967,6 +12017,10 @@ function normalizeChildren(vnode, children) {
11967
12017
  }
11968
12018
  }
11969
12019
  } else if (isFunction(children)) {
12020
+ if (shapeFlag & (1 | 64)) {
12021
+ normalizeChildren(vnode, { default: children });
12022
+ return;
12023
+ }
11970
12024
  children = { default: children, _ctx: currentRenderingInstance };
11971
12025
  type = 32;
11972
12026
  } else {
@@ -12711,7 +12765,7 @@ function isMemoSame(cached, memo) {
12711
12765
  return true;
12712
12766
  }
12713
12767
 
12714
- const version = "3.5.38";
12768
+ const version = "3.5.40";
12715
12769
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12716
12770
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12717
12771
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13532,16 +13586,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
13532
13586
  }
13533
13587
  }
13534
13588
  }
13535
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
13589
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
13590
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
13536
13591
  function parseName(name) {
13537
13592
  let options;
13538
- if (optionsModifierRE.test(name)) {
13539
- options = {};
13540
- let m;
13541
- while (m = name.match(optionsModifierRE)) {
13542
- name = name.slice(0, name.length - m[0].length);
13543
- options[m[0].toLowerCase()] = true;
13544
- }
13593
+ let m;
13594
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
13595
+ if (!options) options = {};
13596
+ name = name.slice(0, name.length - m[1].length);
13597
+ options[m[1].toLowerCase()] = true;
13545
13598
  }
13546
13599
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
13547
13600
  return [event, options];
@@ -14512,13 +14565,13 @@ const vModelSelect = {
14512
14565
  // <select multiple> value need to be deep traversed
14513
14566
  deep: true,
14514
14567
  created(el, { value, modifiers: { number } }, vnode) {
14515
- const isSetModel = isSet(value);
14568
+ el._modelValue = value;
14516
14569
  addEventListener(el, "change", () => {
14517
14570
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
14518
14571
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
14519
14572
  );
14520
14573
  el[assignKey](
14521
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
14574
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
14522
14575
  );
14523
14576
  el._assigning = true;
14524
14577
  nextTick(() => {
@@ -14532,7 +14585,8 @@ const vModelSelect = {
14532
14585
  mounted(el, { value }) {
14533
14586
  setSelected(el, value);
14534
14587
  },
14535
- beforeUpdate(el, _binding, vnode) {
14588
+ beforeUpdate(el, { value }, vnode) {
14589
+ el._modelValue = value;
14536
14590
  el[assignKey] = getModelAssigner(vnode);
14537
14591
  },
14538
14592
  updated(el, { value }) {