@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
  }
@@ -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)) {
@@ -3384,10 +3388,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
3384
3388
  setBlockTracking(-1);
3385
3389
  }
3386
3390
  const prevInstance = setCurrentRenderingInstance(ctx);
3391
+ const prevStackSize = blockStack.length;
3387
3392
  let res;
3388
3393
  try {
3389
3394
  res = fn(...args);
3390
3395
  } finally {
3396
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
3391
3397
  setCurrentRenderingInstance(prevInstance);
3392
3398
  if (renderFnWithContext._d) {
3393
3399
  setBlockTracking(1);
@@ -3850,11 +3856,9 @@ const TeleportImpl = {
3850
3856
  }
3851
3857
  } else {
3852
3858
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3853
- const nextTarget = n2.target = resolveTarget(
3854
- n2.props,
3855
- querySelector
3856
- );
3859
+ const nextTarget = resolveTarget(n2.props, querySelector);
3857
3860
  if (nextTarget) {
3861
+ n2.target = nextTarget;
3858
3862
  moveTeleport(
3859
3863
  n2,
3860
3864
  nextTarget,
@@ -3892,7 +3896,8 @@ const TeleportImpl = {
3892
3896
  target,
3893
3897
  props
3894
3898
  } = vnode;
3895
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3899
+ const disabled = isTeleportDisabled(props);
3900
+ const shouldRemove = doRemove || !disabled;
3896
3901
  const pendingMount = pendingMounts.get(vnode);
3897
3902
  if (pendingMount) {
3898
3903
  pendingMount.flags |= 8;
@@ -3903,7 +3908,7 @@ const TeleportImpl = {
3903
3908
  hostRemove(targetAnchor);
3904
3909
  }
3905
3910
  doRemove && hostRemove(anchor);
3906
- if (!pendingMount && shapeFlag & 16) {
3911
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3907
3912
  for (let i = 0; i < children.length; i++) {
3908
3913
  const child = children[i];
3909
3914
  unmount(
@@ -4841,7 +4846,15 @@ function createHydrationFunctions(rendererInternals) {
4841
4846
  };
4842
4847
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4843
4848
  optimized = optimized || !!vnode.dynamicChildren;
4844
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
4849
+ const {
4850
+ type,
4851
+ dynamicProps,
4852
+ props,
4853
+ patchFlag,
4854
+ shapeFlag,
4855
+ dirs,
4856
+ transition
4857
+ } = vnode;
4845
4858
  const forcePatch = type === "input" || type === "option";
4846
4859
  {
4847
4860
  if (dirs) {
@@ -4912,6 +4925,7 @@ Server rendered element contains more child nodes than client vdom.`
4912
4925
  if (props) {
4913
4926
  {
4914
4927
  const isCustomElement = el.tagName.includes("-");
4928
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
4915
4929
  for (const key in props) {
4916
4930
  if (// #11189 skip if this node has directives that have created hooks
4917
4931
  // as it could have mutated the DOM in any possible way
@@ -4919,8 +4933,8 @@ Server rendered element contains more child nodes than client vdom.`
4919
4933
  logMismatchError();
4920
4934
  }
4921
4935
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4922
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
4923
- patchProp(el, key, null, props[key], void 0, parentComponent);
4936
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
4937
+ patchProp(el, key, null, props[key], namespace, parentComponent);
4924
4938
  }
4925
4939
  }
4926
4940
  }
@@ -5024,7 +5038,7 @@ Server rendered element contains fewer child nodes than client vdom.`
5024
5038
  }
5025
5039
  };
5026
5040
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5027
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
5041
+ if (!isNodeMismatchAllowed(node, vnode)) {
5028
5042
  warn$1(
5029
5043
  `Hydration node mismatch:
5030
5044
  - rendered on server:`,
@@ -5239,7 +5253,12 @@ function isMismatchAllowed(el, allowedType) {
5239
5253
  el = el.parentElement;
5240
5254
  }
5241
5255
  }
5242
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
5256
+ return isMismatchAllowedByAttr(
5257
+ el && el.getAttribute(allowMismatchAttr),
5258
+ allowedType
5259
+ );
5260
+ }
5261
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
5243
5262
  if (allowedAttr == null) {
5244
5263
  return false;
5245
5264
  } else if (allowedAttr === "") {
@@ -5252,6 +5271,19 @@ function isMismatchAllowed(el, allowedType) {
5252
5271
  return list.includes(MismatchTypeString[allowedType]);
5253
5272
  }
5254
5273
  }
5274
+ function isNodeMismatchAllowed(node, vnode) {
5275
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
5276
+ }
5277
+ function isMismatchAllowedByNode(node) {
5278
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
5279
+ node.getAttribute(allowMismatchAttr),
5280
+ 1 /* CHILDREN */
5281
+ );
5282
+ }
5283
+ function isMismatchAllowedByVNode({ props }) {
5284
+ const allowedAttr = props && props[allowMismatchAttr];
5285
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
5286
+ }
5255
5287
 
5256
5288
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
5257
5289
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -5405,6 +5437,7 @@ function defineAsyncComponent(source) {
5405
5437
  name: "AsyncComponentWrapper",
5406
5438
  __asyncLoader: load,
5407
5439
  __asyncHydrate(el, instance, hydrate) {
5440
+ const wasConnected = el.isConnected;
5408
5441
  let patched = false;
5409
5442
  (instance.bu || (instance.bu = [])).push(() => patched = true);
5410
5443
  const performHydrate = () => {
@@ -5416,6 +5449,7 @@ function defineAsyncComponent(source) {
5416
5449
  }
5417
5450
  return;
5418
5451
  }
5452
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
5419
5453
  hydrate();
5420
5454
  };
5421
5455
  const doHydrate = hydrateStrategy ? () => {
@@ -6265,14 +6299,15 @@ function createSlots(slots, dynamicSlots) {
6265
6299
  return slots;
6266
6300
  }
6267
6301
 
6268
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6302
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
6269
6303
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6270
- const hasProps = Object.keys(props).length > 0;
6271
- if (name !== "default") props.name = name;
6304
+ const slotProps = branchKey != null && props.key == null ? extend({}, props, { key: branchKey }) : props;
6305
+ const hasProps = Object.keys(slotProps).length > 0;
6306
+ if (name !== "default") slotProps.name = name;
6272
6307
  return openBlock(), createBlock(
6273
6308
  Fragment,
6274
6309
  null,
6275
- [createVNode("slot", props, fallback && fallback())],
6310
+ [createVNode("slot", slotProps, fallback && fallback())],
6276
6311
  hasProps ? -2 : 64
6277
6312
  );
6278
6313
  }
@@ -6286,26 +6321,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6286
6321
  if (slot && slot._c) {
6287
6322
  slot._d = false;
6288
6323
  }
6324
+ const prevStackSize = blockStack.length;
6289
6325
  openBlock();
6290
- const validSlotContent = slot && ensureValidVNode(slot(props));
6291
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
6292
- // key attached in the `createSlots` helper, respect that
6293
- validSlotContent && validSlotContent.key;
6294
- const rendered = createBlock(
6295
- Fragment,
6296
- {
6297
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6298
- (!validSlotContent && fallback ? "_fb" : "")
6299
- },
6300
- validSlotContent || (fallback ? fallback() : []),
6301
- validSlotContent && slots._ === 1 ? 64 : -2
6302
- );
6326
+ let rendered;
6327
+ try {
6328
+ const validSlotContent = slot && ensureValidVNode(slot(props));
6329
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
6330
+ // key attached in the `createSlots` helper, respect that
6331
+ validSlotContent && validSlotContent.key;
6332
+ rendered = createBlock(
6333
+ Fragment,
6334
+ {
6335
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
6336
+ (!validSlotContent && fallback ? "_fb" : "")
6337
+ },
6338
+ validSlotContent || (fallback ? fallback() : []),
6339
+ validSlotContent && slots._ === 1 ? 64 : -2
6340
+ );
6341
+ } catch (err) {
6342
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
6343
+ throw err;
6344
+ } finally {
6345
+ if (slot && slot._c) {
6346
+ slot._d = true;
6347
+ }
6348
+ }
6303
6349
  if (!noSlotted && rendered.scopeId) {
6304
6350
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
6305
6351
  }
6306
- if (slot && slot._c) {
6307
- slot._d = true;
6308
- }
6309
6352
  return rendered;
6310
6353
  }
6311
6354
  function ensureValidVNode(vnodes) {
@@ -7483,7 +7526,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7483
7526
  return vm;
7484
7527
  }
7485
7528
  }
7486
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
7529
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
7487
7530
  Vue.config = singletonApp.config;
7488
7531
  Vue.use = (plugin, ...options) => {
7489
7532
  if (plugin && isFunction(plugin.install)) {
@@ -8344,7 +8387,8 @@ function isEmitListener(options, key) {
8344
8387
  if (key.startsWith(compatModelEventPrefix)) {
8345
8388
  return true;
8346
8389
  }
8347
- key = key.slice(2).replace(/Once$/, "");
8390
+ key = key.slice(2);
8391
+ key = key === "Once" ? key : key.replace(/Once$/, "");
8348
8392
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8349
8393
  }
8350
8394
 
@@ -9661,7 +9705,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9661
9705
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
9662
9706
  }
9663
9707
  parentComponent && toggleRecurse(parentComponent, true);
9664
- if (isHmrUpdating) {
9708
+ if (
9709
+ // HMR updated, force full diff
9710
+ isHmrUpdating || // #6385 the old vnode may be a user-wrapped non-isomorphic block
9711
+ // Force full diff when block metadata is unstable.
9712
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
9713
+ ) {
9665
9714
  patchFlag = 0;
9666
9715
  optimized = false;
9667
9716
  dynamicChildren = null;
@@ -11895,6 +11944,10 @@ function normalizeChildren(vnode, children) {
11895
11944
  }
11896
11945
  }
11897
11946
  } else if (isFunction(children)) {
11947
+ if (shapeFlag & (1 | 64)) {
11948
+ normalizeChildren(vnode, { default: children });
11949
+ return;
11950
+ }
11898
11951
  children = { default: children, _ctx: currentRenderingInstance };
11899
11952
  type = 32;
11900
11953
  } else {
@@ -12625,7 +12678,7 @@ function isMemoSame(cached, memo) {
12625
12678
  return true;
12626
12679
  }
12627
12680
 
12628
- const version = "3.5.38";
12681
+ const version = "3.5.40";
12629
12682
  const warn = warn$1 ;
12630
12683
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12631
12684
  const devtools = devtools$1 ;
@@ -13446,16 +13499,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
13446
13499
  }
13447
13500
  }
13448
13501
  }
13449
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
13502
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
13503
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
13450
13504
  function parseName(name) {
13451
13505
  let options;
13452
- if (optionsModifierRE.test(name)) {
13453
- options = {};
13454
- let m;
13455
- while (m = name.match(optionsModifierRE)) {
13456
- name = name.slice(0, name.length - m[0].length);
13457
- options[m[0].toLowerCase()] = true;
13458
- }
13506
+ let m;
13507
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
13508
+ if (!options) options = {};
13509
+ name = name.slice(0, name.length - m[1].length);
13510
+ options[m[1].toLowerCase()] = true;
13459
13511
  }
13460
13512
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
13461
13513
  return [event, options];
@@ -14426,13 +14478,13 @@ const vModelSelect = {
14426
14478
  // <select multiple> value need to be deep traversed
14427
14479
  deep: true,
14428
14480
  created(el, { value, modifiers: { number } }, vnode) {
14429
- const isSetModel = isSet(value);
14481
+ el._modelValue = value;
14430
14482
  addEventListener(el, "change", () => {
14431
14483
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
14432
14484
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
14433
14485
  );
14434
14486
  el[assignKey](
14435
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
14487
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
14436
14488
  );
14437
14489
  el._assigning = true;
14438
14490
  nextTick(() => {
@@ -14446,7 +14498,8 @@ const vModelSelect = {
14446
14498
  mounted(el, { value }) {
14447
14499
  setSelected(el, value);
14448
14500
  },
14449
- beforeUpdate(el, _binding, vnode) {
14501
+ beforeUpdate(el, { value }, vnode) {
14502
+ el._modelValue = value;
14450
14503
  el[assignKey] = getModelAssigner(vnode);
14451
14504
  },
14452
14505
  updated(el, { value }) {