@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
  }
@@ -1444,7 +1448,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1444
1448
  value,
1445
1449
  isRef(target) ? target : receiver
1446
1450
  );
1447
- if (target === toRaw(receiver)) {
1451
+ if (target === toRaw(receiver) && result) {
1448
1452
  if (!hadKey) {
1449
1453
  trigger(target, "add", key, value);
1450
1454
  } else if (hasChanged(value, oldValue)) {
@@ -3457,10 +3461,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
3457
3461
  setBlockTracking(-1);
3458
3462
  }
3459
3463
  const prevInstance = setCurrentRenderingInstance(ctx);
3464
+ const prevStackSize = blockStack.length;
3460
3465
  let res;
3461
3466
  try {
3462
3467
  res = fn(...args);
3463
3468
  } finally {
3469
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
3464
3470
  setCurrentRenderingInstance(prevInstance);
3465
3471
  if (renderFnWithContext._d) {
3466
3472
  setBlockTracking(1);
@@ -3923,11 +3929,9 @@ const TeleportImpl = {
3923
3929
  }
3924
3930
  } else {
3925
3931
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3926
- const nextTarget = n2.target = resolveTarget(
3927
- n2.props,
3928
- querySelector
3929
- );
3932
+ const nextTarget = resolveTarget(n2.props, querySelector);
3930
3933
  if (nextTarget) {
3934
+ n2.target = nextTarget;
3931
3935
  moveTeleport(
3932
3936
  n2,
3933
3937
  nextTarget,
@@ -3965,7 +3969,8 @@ const TeleportImpl = {
3965
3969
  target,
3966
3970
  props
3967
3971
  } = vnode;
3968
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3972
+ const disabled = isTeleportDisabled(props);
3973
+ const shouldRemove = doRemove || !disabled;
3969
3974
  const pendingMount = pendingMounts.get(vnode);
3970
3975
  if (pendingMount) {
3971
3976
  pendingMount.flags |= 8;
@@ -3976,7 +3981,7 @@ const TeleportImpl = {
3976
3981
  hostRemove(targetAnchor);
3977
3982
  }
3978
3983
  doRemove && hostRemove(anchor);
3979
- if (!pendingMount && shapeFlag & 16) {
3984
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3980
3985
  for (let i = 0; i < children.length; i++) {
3981
3986
  const child = children[i];
3982
3987
  unmount(
@@ -4914,7 +4919,15 @@ function createHydrationFunctions(rendererInternals) {
4914
4919
  };
4915
4920
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4916
4921
  optimized = optimized || !!vnode.dynamicChildren;
4917
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4922
+ const {
4923
+ type,
4924
+ dynamicProps,
4925
+ props,
4926
+ patchFlag,
4927
+ shapeFlag,
4928
+ dirs,
4929
+ transition
4930
+ } = vnode;
4918
4931
  const forcePatch = type === "input" || type === "option";
4919
4932
  {
4920
4933
  if (dirs) {
@@ -4985,6 +4998,7 @@ Server rendered element contains more child nodes than client vdom.`
4985
4998
  if (props) {
4986
4999
  {
4987
5000
  const isCustomElement = el.tagName.includes("-");
5001
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
4988
5002
  for (const key in props) {
4989
5003
  if (// #11189 skip if this node has directives that have created hooks
4990
5004
  // as it could have mutated the DOM in any possible way
@@ -4992,8 +5006,8 @@ Server rendered element contains more child nodes than client vdom.`
4992
5006
  logMismatchError();
4993
5007
  }
4994
5008
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4995
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
4996
- patchProp(el, key, null, props[key], void 0, parentComponent);
5009
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
5010
+ patchProp(el, key, null, props[key], namespace, parentComponent);
4997
5011
  }
4998
5012
  }
4999
5013
  }
@@ -5097,7 +5111,7 @@ Server rendered element contains fewer child nodes than client vdom.`
5097
5111
  }
5098
5112
  };
5099
5113
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5100
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
5114
+ if (!isNodeMismatchAllowed(node, vnode)) {
5101
5115
  warn$1(
5102
5116
  `Hydration node mismatch:
5103
5117
  - rendered on server:`,
@@ -5312,7 +5326,12 @@ function isMismatchAllowed(el, allowedType) {
5312
5326
  el = el.parentElement;
5313
5327
  }
5314
5328
  }
5315
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
5329
+ return isMismatchAllowedByAttr(
5330
+ el && el.getAttribute(allowMismatchAttr),
5331
+ allowedType
5332
+ );
5333
+ }
5334
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
5316
5335
  if (allowedAttr == null) {
5317
5336
  return false;
5318
5337
  } else if (allowedAttr === "") {
@@ -5325,6 +5344,19 @@ function isMismatchAllowed(el, allowedType) {
5325
5344
  return list.includes(MismatchTypeString[allowedType]);
5326
5345
  }
5327
5346
  }
5347
+ function isNodeMismatchAllowed(node, vnode) {
5348
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
5349
+ }
5350
+ function isMismatchAllowedByNode(node) {
5351
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
5352
+ node.getAttribute(allowMismatchAttr),
5353
+ 1 /* CHILDREN */
5354
+ );
5355
+ }
5356
+ function isMismatchAllowedByVNode({ props }) {
5357
+ const allowedAttr = props && props[allowMismatchAttr];
5358
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
5359
+ }
5328
5360
 
5329
5361
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
5330
5362
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -5478,6 +5510,7 @@ function defineAsyncComponent(source) {
5478
5510
  name: "AsyncComponentWrapper",
5479
5511
  __asyncLoader: load,
5480
5512
  __asyncHydrate(el, instance, hydrate) {
5513
+ const wasConnected = el.isConnected;
5481
5514
  let patched = false;
5482
5515
  (instance.bu || (instance.bu = [])).push(() => patched = true);
5483
5516
  const performHydrate = () => {
@@ -5489,6 +5522,7 @@ function defineAsyncComponent(source) {
5489
5522
  }
5490
5523
  return;
5491
5524
  }
5525
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
5492
5526
  hydrate();
5493
5527
  };
5494
5528
  const doHydrate = hydrateStrategy ? () => {
@@ -6338,14 +6372,15 @@ function createSlots(slots, dynamicSlots) {
6338
6372
  return slots;
6339
6373
  }
6340
6374
 
6341
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6375
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
6342
6376
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6343
- const hasProps = Object.keys(props).length > 0;
6344
- if (name !== "default") props.name = name;
6377
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
6378
+ const hasProps = Object.keys(slotProps).length > 0;
6379
+ if (name !== "default") slotProps.name = name;
6345
6380
  return openBlock(), createBlock(
6346
6381
  Fragment,
6347
6382
  null,
6348
- [createVNode("slot", props, fallback && fallback())],
6383
+ [createVNode("slot", slotProps, fallback && fallback())],
6349
6384
  hasProps ? -2 : 64
6350
6385
  );
6351
6386
  }
@@ -6359,26 +6394,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6359
6394
  if (slot && slot._c) {
6360
6395
  slot._d = false;
6361
6396
  }
6397
+ const prevStackSize = blockStack.length;
6362
6398
  openBlock();
6363
- const validSlotContent = slot && ensureValidVNode(slot(props));
6364
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
6365
- // key attached in the `createSlots` helper, respect that
6366
- validSlotContent && validSlotContent.key;
6367
- const rendered = createBlock(
6368
- Fragment,
6369
- {
6370
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6371
- (!validSlotContent && fallback ? "_fb" : "")
6372
- },
6373
- validSlotContent || (fallback ? fallback() : []),
6374
- validSlotContent && slots._ === 1 ? 64 : -2
6375
- );
6399
+ let rendered;
6400
+ try {
6401
+ const validSlotContent = slot && ensureValidVNode(slot(props));
6402
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
6403
+ // key attached in the `createSlots` helper, respect that
6404
+ validSlotContent && validSlotContent.key;
6405
+ rendered = createBlock(
6406
+ Fragment,
6407
+ {
6408
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6409
+ (!validSlotContent && fallback ? "_fb" : "")
6410
+ },
6411
+ validSlotContent || (fallback ? fallback() : []),
6412
+ validSlotContent && slots._ === 1 ? 64 : -2
6413
+ );
6414
+ } catch (err) {
6415
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
6416
+ throw err;
6417
+ } finally {
6418
+ if (slot && slot._c) {
6419
+ slot._d = true;
6420
+ }
6421
+ }
6376
6422
  if (!noSlotted && rendered.scopeId) {
6377
6423
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
6378
6424
  }
6379
- if (slot && slot._c) {
6380
- slot._d = true;
6381
- }
6382
6425
  return rendered;
6383
6426
  }
6384
6427
  function ensureValidVNode(vnodes) {
@@ -7556,7 +7599,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7556
7599
  return vm;
7557
7600
  }
7558
7601
  }
7559
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
7602
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
7560
7603
  Vue.config = singletonApp.config;
7561
7604
  Vue.use = (plugin, ...options) => {
7562
7605
  if (plugin && isFunction(plugin.install)) {
@@ -8417,7 +8460,8 @@ function isEmitListener(options, key) {
8417
8460
  if (key.startsWith(compatModelEventPrefix)) {
8418
8461
  return true;
8419
8462
  }
8420
- key = key.slice(2).replace(/Once$/, "");
8463
+ key = key.slice(2);
8464
+ key = key === "Once" ? key : key.replace(/Once$/, "");
8421
8465
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8422
8466
  }
8423
8467
 
@@ -9734,7 +9778,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9734
9778
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
9735
9779
  }
9736
9780
  parentComponent && toggleRecurse(parentComponent, true);
9737
- if (isHmrUpdating) {
9781
+ if (
9782
+ // HMR updated, force full diff
9783
+ isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
9784
+ // Force full diff when block metadata is unstable.
9785
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
9786
+ ) {
9738
9787
  patchFlag = 0;
9739
9788
  optimized = false;
9740
9789
  dynamicChildren = null;
@@ -11968,6 +12017,10 @@ function normalizeChildren(vnode, children) {
11968
12017
  }
11969
12018
  }
11970
12019
  } else if (isFunction(children)) {
12020
+ if (shapeFlag & (1 | 64)) {
12021
+ normalizeChildren(vnode, { default: children });
12022
+ return;
12023
+ }
11971
12024
  children = { default: children, _ctx: currentRenderingInstance };
11972
12025
  type = 32;
11973
12026
  } else {
@@ -12698,7 +12751,7 @@ function isMemoSame(cached, memo) {
12698
12751
  return true;
12699
12752
  }
12700
12753
 
12701
- const version = "3.5.38";
12754
+ const version = "3.5.40";
12702
12755
  const warn = warn$1 ;
12703
12756
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12704
12757
  const devtools = devtools$1 ;
@@ -13519,16 +13572,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
13519
13572
  }
13520
13573
  }
13521
13574
  }
13522
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
13575
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
13576
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
13523
13577
  function parseName(name) {
13524
13578
  let options;
13525
- if (optionsModifierRE.test(name)) {
13526
- options = {};
13527
- let m;
13528
- while (m = name.match(optionsModifierRE)) {
13529
- name = name.slice(0, name.length - m[0].length);
13530
- options[m[0].toLowerCase()] = true;
13531
- }
13579
+ let m;
13580
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
13581
+ if (!options) options = {};
13582
+ name = name.slice(0, name.length - m[1].length);
13583
+ options[m[1].toLowerCase()] = true;
13532
13584
  }
13533
13585
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
13534
13586
  return [event, options];
@@ -14499,13 +14551,13 @@ const vModelSelect = {
14499
14551
  // <select multiple> value need to be deep traversed
14500
14552
  deep: true,
14501
14553
  created(el, { value, modifiers: { number } }, vnode) {
14502
- const isSetModel = isSet(value);
14554
+ el._modelValue = value;
14503
14555
  addEventListener(el, "change", () => {
14504
14556
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
14505
14557
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
14506
14558
  );
14507
14559
  el[assignKey](
14508
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
14560
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
14509
14561
  );
14510
14562
  el._assigning = true;
14511
14563
  nextTick(() => {
@@ -14519,7 +14571,8 @@ const vModelSelect = {
14519
14571
  mounted(el, { value }) {
14520
14572
  setSelected(el, value);
14521
14573
  },
14522
- beforeUpdate(el, _binding, vnode) {
14574
+ beforeUpdate(el, { value }, vnode) {
14575
+ el._modelValue = value;
14523
14576
  el[assignKey] = getModelAssigner(vnode);
14524
14577
  },
14525
14578
  updated(el, { value }) {
@@ -16458,6 +16511,9 @@ function getUnnormalizedProps(props, callPath = []) {
16458
16511
  return [props, callPath];
16459
16512
  }
16460
16513
  function injectProp(node, prop, context) {
16514
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
16515
+ return;
16516
+ }
16461
16517
  let propsWithInjection;
16462
16518
  let props = node.type === 13 ? node.props : node.arguments[2];
16463
16519
  let callPath = [];
@@ -16515,6 +16571,24 @@ function injectProp(node, prop, context) {
16515
16571
  }
16516
16572
  }
16517
16573
  }
16574
+ function injectSlotKey(node, prop) {
16575
+ var _a, _b, _c;
16576
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
16577
+ return false;
16578
+ }
16579
+ const props = node.arguments[2];
16580
+ if (props && !isString(props)) {
16581
+ const [unnormalizedProps] = getUnnormalizedProps(props);
16582
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
16583
+ return true;
16584
+ }
16585
+ }
16586
+ (_a = node.arguments)[2] || (_a[2] = "{}");
16587
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
16588
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
16589
+ node.arguments[5] = prop.value;
16590
+ return true;
16591
+ }
16518
16592
  function hasProp(prop, props) {
16519
16593
  let result = false;
16520
16594
  if (prop.key.type === 4) {
@@ -20146,7 +20220,7 @@ function rewriteFilter(node, context) {
20146
20220
  if (child.type === 4) {
20147
20221
  parseFilter(child, context);
20148
20222
  } else if (child.type === 8) {
20149
- rewriteFilter(node, context);
20223
+ rewriteFilter(child, context);
20150
20224
  } else if (child.type === 5) {
20151
20225
  rewriteFilter(child.content, context);
20152
20226
  }