@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
  **/
@@ -401,8 +401,9 @@ class EffectScope {
401
401
  this._isPaused = true;
402
402
  let i, l;
403
403
  if (this.scopes) {
404
- for (i = 0, l = this.scopes.length; i < l; i++) {
405
- this.scopes[i].pause();
404
+ const scopes = this.scopes.slice();
405
+ for (i = 0, l = scopes.length; i < l; i++) {
406
+ scopes[i].pause();
406
407
  }
407
408
  }
408
409
  for (i = 0, l = this.effects.length; i < l; i++) {
@@ -419,12 +420,14 @@ class EffectScope {
419
420
  this._isPaused = false;
420
421
  let i, l;
421
422
  if (this.scopes) {
422
- for (i = 0, l = this.scopes.length; i < l; i++) {
423
- this.scopes[i].resume();
423
+ const scopes = this.scopes.slice();
424
+ for (i = 0, l = scopes.length; i < l; i++) {
425
+ scopes[i].resume();
424
426
  }
425
427
  }
426
- for (i = 0, l = this.effects.length; i < l; i++) {
427
- this.effects[i].resume();
428
+ const effects = this.effects.slice();
429
+ for (i = 0, l = effects.length; i < l; i++) {
430
+ effects[i].resume();
428
431
  }
429
432
  }
430
433
  }
@@ -484,8 +487,9 @@ class EffectScope {
484
487
  }
485
488
  this.cleanups.length = 0;
486
489
  if (this.scopes) {
487
- for (i = 0, l = this.scopes.length; i < l; i++) {
488
- this.scopes[i].stop(true);
490
+ const scopes = this.scopes.slice();
491
+ for (i = 0, l = scopes.length; i < l; i++) {
492
+ scopes[i].stop(true);
489
493
  }
490
494
  this.scopes.length = 0;
491
495
  }
@@ -1336,7 +1340,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1336
1340
  value,
1337
1341
  isRef(target) ? target : receiver
1338
1342
  );
1339
- if (target === toRaw(receiver)) {
1343
+ if (target === toRaw(receiver) && result) {
1340
1344
  if (!hadKey) {
1341
1345
  trigger(target, "add", key, value);
1342
1346
  } else if (hasChanged(value, oldValue)) {
@@ -2611,10 +2615,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
2611
2615
  setBlockTracking(-1);
2612
2616
  }
2613
2617
  const prevInstance = setCurrentRenderingInstance(ctx);
2618
+ const prevStackSize = blockStack.length;
2614
2619
  let res;
2615
2620
  try {
2616
2621
  res = fn(...args);
2617
2622
  } finally {
2623
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
2618
2624
  setCurrentRenderingInstance(prevInstance);
2619
2625
  if (renderFnWithContext._d) {
2620
2626
  setBlockTracking(1);
@@ -3014,11 +3020,9 @@ const TeleportImpl = {
3014
3020
  }
3015
3021
  } else {
3016
3022
  if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
3017
- const nextTarget = n2.target = resolveTarget(
3018
- n2.props,
3019
- querySelector
3020
- );
3023
+ const nextTarget = resolveTarget(n2.props, querySelector);
3021
3024
  if (nextTarget) {
3025
+ n2.target = nextTarget;
3022
3026
  moveTeleport(
3023
3027
  n2,
3024
3028
  nextTarget,
@@ -3050,7 +3054,8 @@ const TeleportImpl = {
3050
3054
  target,
3051
3055
  props
3052
3056
  } = vnode;
3053
- const shouldRemove = doRemove || !isTeleportDisabled(props);
3057
+ const disabled = isTeleportDisabled(props);
3058
+ const shouldRemove = doRemove || !disabled;
3054
3059
  const pendingMount = pendingMounts.get(vnode);
3055
3060
  if (pendingMount) {
3056
3061
  pendingMount.flags |= 8;
@@ -3061,7 +3066,7 @@ const TeleportImpl = {
3061
3066
  hostRemove(targetAnchor);
3062
3067
  }
3063
3068
  doRemove && hostRemove(anchor);
3064
- if (!pendingMount && shapeFlag & 16) {
3069
+ if (!pendingMount && (disabled || target) && shapeFlag & 16) {
3065
3070
  for (let i = 0; i < children.length; i++) {
3066
3071
  const child = children[i];
3067
3072
  unmount(
@@ -3934,9 +3939,18 @@ function createHydrationFunctions(rendererInternals) {
3934
3939
  };
3935
3940
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
3936
3941
  optimized = optimized || !!vnode.dynamicChildren;
3937
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
3942
+ const {
3943
+ type,
3944
+ dynamicProps,
3945
+ props,
3946
+ patchFlag,
3947
+ shapeFlag,
3948
+ dirs,
3949
+ transition
3950
+ } = vnode;
3938
3951
  const forcePatch = type === "input" || type === "option";
3939
- if (forcePatch || patchFlag !== -1) {
3952
+ const hasDynamicProps = !!dynamicProps;
3953
+ if (forcePatch || hasDynamicProps || patchFlag !== -1) {
3940
3954
  if (dirs) {
3941
3955
  invokeDirectiveHook(vnode, null, parentComponent, "created");
3942
3956
  }
@@ -3990,12 +4004,13 @@ function createHydrationFunctions(rendererInternals) {
3990
4004
  }
3991
4005
  }
3992
4006
  if (props) {
3993
- if (forcePatch || !optimized || patchFlag & (16 | 32)) {
4007
+ if (forcePatch || hasDynamicProps || !optimized || patchFlag & (16 | 32)) {
3994
4008
  const isCustomElement = el.tagName.includes("-");
4009
+ const namespace = el.namespaceURI.includes("svg") ? "svg" : el.namespaceURI.includes("MathML") ? "mathml" : void 0;
3995
4010
  for (const key in props) {
3996
4011
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
3997
- key[0] === "." || isCustomElement && !isReservedProp(key)) {
3998
- patchProp(el, key, null, props[key], void 0, parentComponent);
4012
+ key[0] === "." || isCustomElement && !isReservedProp(key) || dynamicProps && dynamicProps.includes(key)) {
4013
+ patchProp(el, key, null, props[key], namespace, parentComponent);
3999
4014
  }
4000
4015
  }
4001
4016
  } else if (props.onClick) {
@@ -4104,7 +4119,7 @@ function createHydrationFunctions(rendererInternals) {
4104
4119
  }
4105
4120
  };
4106
4121
  const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
4107
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
4122
+ if (!isNodeMismatchAllowed(node, vnode)) {
4108
4123
  logMismatchError();
4109
4124
  }
4110
4125
  vnode.el = null;
@@ -4187,7 +4202,12 @@ function isMismatchAllowed(el, allowedType) {
4187
4202
  el = el.parentElement;
4188
4203
  }
4189
4204
  }
4190
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
4205
+ return isMismatchAllowedByAttr(
4206
+ el && el.getAttribute(allowMismatchAttr),
4207
+ allowedType
4208
+ );
4209
+ }
4210
+ function isMismatchAllowedByAttr(allowedAttr, allowedType) {
4191
4211
  if (allowedAttr == null) {
4192
4212
  return false;
4193
4213
  } else if (allowedAttr === "") {
@@ -4200,6 +4220,19 @@ function isMismatchAllowed(el, allowedType) {
4200
4220
  return list.includes(MismatchTypeString[allowedType]);
4201
4221
  }
4202
4222
  }
4223
+ function isNodeMismatchAllowed(node, vnode) {
4224
+ return isMismatchAllowed(node.parentElement, 1 /* CHILDREN */) || isMismatchAllowedByNode(node) || isMismatchAllowedByVNode(vnode);
4225
+ }
4226
+ function isMismatchAllowedByNode(node) {
4227
+ return node.nodeType === 1 && isMismatchAllowedByAttr(
4228
+ node.getAttribute(allowMismatchAttr),
4229
+ 1 /* CHILDREN */
4230
+ );
4231
+ }
4232
+ function isMismatchAllowedByVNode({ props }) {
4233
+ const allowedAttr = props && props[allowMismatchAttr];
4234
+ return typeof allowedAttr === "string" && isMismatchAllowedByAttr(allowedAttr, 1 /* CHILDREN */);
4235
+ }
4203
4236
 
4204
4237
  const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
4205
4238
  const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
@@ -4345,12 +4378,14 @@ function defineAsyncComponent(source) {
4345
4378
  name: "AsyncComponentWrapper",
4346
4379
  __asyncLoader: load,
4347
4380
  __asyncHydrate(el, instance, hydrate) {
4381
+ const wasConnected = el.isConnected;
4348
4382
  let patched = false;
4349
4383
  (instance.bu || (instance.bu = [])).push(() => patched = true);
4350
4384
  const performHydrate = () => {
4351
4385
  if (patched) {
4352
4386
  return;
4353
4387
  }
4388
+ if (!el.parentNode || wasConnected && !el.isConnected) return;
4354
4389
  hydrate();
4355
4390
  };
4356
4391
  const doHydrate = hydrateStrategy ? () => {
@@ -5166,14 +5201,15 @@ function createSlots(slots, dynamicSlots) {
5166
5201
  return slots;
5167
5202
  }
5168
5203
 
5169
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5204
+ function renderSlot(slots, name, props = {}, fallback, noSlotted, branchKey) {
5170
5205
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
5171
- const hasProps = Object.keys(props).length > 0;
5172
- if (name !== "default") props.name = name;
5206
+ const slotProps = branchKey != null && props.key == null ? extend$1({}, props, { key: branchKey }) : props;
5207
+ const hasProps = Object.keys(slotProps).length > 0;
5208
+ if (name !== "default") slotProps.name = name;
5173
5209
  return openBlock(), createBlock(
5174
5210
  Fragment,
5175
5211
  null,
5176
- [createVNode("slot", props, fallback && fallback())],
5212
+ [createVNode("slot", slotProps, fallback && fallback())],
5177
5213
  hasProps ? -2 : 64
5178
5214
  );
5179
5215
  }
@@ -5181,26 +5217,34 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5181
5217
  if (slot && slot._c) {
5182
5218
  slot._d = false;
5183
5219
  }
5220
+ const prevStackSize = blockStack.length;
5184
5221
  openBlock();
5185
- const validSlotContent = slot && ensureValidVNode(slot(props));
5186
- const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
5187
- // key attached in the `createSlots` helper, respect that
5188
- validSlotContent && validSlotContent.key;
5189
- const rendered = createBlock(
5190
- Fragment,
5191
- {
5192
- key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
5193
- (!validSlotContent && fallback ? "_fb" : "")
5194
- },
5195
- validSlotContent || (fallback ? fallback() : []),
5196
- validSlotContent && slots._ === 1 ? 64 : -2
5197
- );
5222
+ let rendered;
5223
+ try {
5224
+ const validSlotContent = slot && ensureValidVNode(slot(props));
5225
+ const slotKey = props.key || branchKey || // slot content array of a dynamic conditional slot may have a branch
5226
+ // key attached in the `createSlots` helper, respect that
5227
+ validSlotContent && validSlotContent.key;
5228
+ rendered = createBlock(
5229
+ Fragment,
5230
+ {
5231
+ key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
5232
+ (!validSlotContent && fallback ? "_fb" : "")
5233
+ },
5234
+ validSlotContent || (fallback ? fallback() : []),
5235
+ validSlotContent && slots._ === 1 ? 64 : -2
5236
+ );
5237
+ } catch (err) {
5238
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
5239
+ throw err;
5240
+ } finally {
5241
+ if (slot && slot._c) {
5242
+ slot._d = true;
5243
+ }
5244
+ }
5198
5245
  if (!noSlotted && rendered.scopeId) {
5199
5246
  rendered.slotScopeIds = [rendered.scopeId + "-s"];
5200
5247
  }
5201
- if (slot && slot._c) {
5202
- slot._d = true;
5203
- }
5204
5248
  return rendered;
5205
5249
  }
5206
5250
  function ensureValidVNode(vnodes) {
@@ -6125,7 +6169,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6125
6169
  return vm;
6126
6170
  }
6127
6171
  }
6128
- Vue.version = `2.6.14-compat:${"3.5.38"}`;
6172
+ Vue.version = `2.6.14-compat:${"3.5.40"}`;
6129
6173
  Vue.config = singletonApp.config;
6130
6174
  Vue.use = (plugin, ...options) => {
6131
6175
  if (plugin && isFunction(plugin.install)) {
@@ -6810,7 +6854,8 @@ function isEmitListener(options, key) {
6810
6854
  if (key.startsWith(compatModelEventPrefix)) {
6811
6855
  return true;
6812
6856
  }
6813
- key = key.slice(2).replace(/Once$/, "");
6857
+ key = key.slice(2);
6858
+ key = key === "Once" ? key : key.replace(/Once$/, "");
6814
6859
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
6815
6860
  }
6816
6861
 
@@ -7809,6 +7854,15 @@ function baseCreateRenderer(options, createHydrationFns) {
7809
7854
  invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
7810
7855
  }
7811
7856
  parentComponent && toggleRecurse(parentComponent, true);
7857
+ if (
7858
+ // #6385 the old vnode may be a user-wrapped non-isomorphic block
7859
+ // Force full diff when block metadata is unstable.
7860
+ dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)
7861
+ ) {
7862
+ patchFlag = 0;
7863
+ optimized = false;
7864
+ dynamicChildren = null;
7865
+ }
7812
7866
  if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
7813
7867
  hostSetElementText(el, "");
7814
7868
  }
@@ -9870,6 +9924,10 @@ function normalizeChildren(vnode, children) {
9870
9924
  }
9871
9925
  }
9872
9926
  } else if (isFunction(children)) {
9927
+ if (shapeFlag & (1 | 64)) {
9928
+ normalizeChildren(vnode, { default: children });
9929
+ return;
9930
+ }
9873
9931
  children = { default: children, _ctx: currentRenderingInstance };
9874
9932
  type = 32;
9875
9933
  } else {
@@ -10279,7 +10337,7 @@ function isMemoSame(cached, memo) {
10279
10337
  return true;
10280
10338
  }
10281
10339
 
10282
- const version = "3.5.38";
10340
+ const version = "3.5.40";
10283
10341
  const warn$1 = NOOP;
10284
10342
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10285
10343
  const devtools = void 0;
@@ -11009,16 +11067,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
11009
11067
  }
11010
11068
  }
11011
11069
  }
11012
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
11070
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
11071
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
11013
11072
  function parseName(name) {
11014
11073
  let options;
11015
- if (optionsModifierRE.test(name)) {
11016
- options = {};
11017
- let m;
11018
- while (m = name.match(optionsModifierRE)) {
11019
- name = name.slice(0, name.length - m[0].length);
11020
- options[m[0].toLowerCase()] = true;
11021
- }
11074
+ let m;
11075
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
11076
+ if (!options) options = {};
11077
+ name = name.slice(0, name.length - m[1].length);
11078
+ options[m[1].toLowerCase()] = true;
11022
11079
  }
11023
11080
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
11024
11081
  return [event, options];
@@ -11913,13 +11970,13 @@ const vModelSelect = {
11913
11970
  // <select multiple> value need to be deep traversed
11914
11971
  deep: true,
11915
11972
  created(el, { value, modifiers: { number } }, vnode) {
11916
- const isSetModel = isSet(value);
11973
+ el._modelValue = value;
11917
11974
  addEventListener(el, "change", () => {
11918
11975
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
11919
11976
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
11920
11977
  );
11921
11978
  el[assignKey](
11922
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
11979
+ el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
11923
11980
  );
11924
11981
  el._assigning = true;
11925
11982
  nextTick(() => {
@@ -11933,7 +11990,8 @@ const vModelSelect = {
11933
11990
  mounted(el, { value }) {
11934
11991
  setSelected(el, value);
11935
11992
  },
11936
- beforeUpdate(el, _binding, vnode) {
11993
+ beforeUpdate(el, { value }, vnode) {
11994
+ el._modelValue = value;
11937
11995
  el[assignKey] = getModelAssigner(vnode);
11938
11996
  },
11939
11997
  updated(el, { value }) {
@@ -14172,6 +14230,9 @@ function getUnnormalizedProps(props, callPath = []) {
14172
14230
  return [props, callPath];
14173
14231
  }
14174
14232
  function injectProp(node, prop, context) {
14233
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
14234
+ return;
14235
+ }
14175
14236
  let propsWithInjection;
14176
14237
  let props = node.type === 13 ? node.props : node.arguments[2];
14177
14238
  let callPath = [];
@@ -14229,6 +14290,24 @@ function injectProp(node, prop, context) {
14229
14290
  }
14230
14291
  }
14231
14292
  }
14293
+ function injectSlotKey(node, prop) {
14294
+ var _a, _b, _c;
14295
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
14296
+ return false;
14297
+ }
14298
+ const props = node.arguments[2];
14299
+ if (props && !isString(props)) {
14300
+ const [unnormalizedProps] = getUnnormalizedProps(props);
14301
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
14302
+ return true;
14303
+ }
14304
+ }
14305
+ (_a = node.arguments)[2] || (_a[2] = "{}");
14306
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
14307
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
14308
+ node.arguments[5] = prop.value;
14309
+ return true;
14310
+ }
14232
14311
  function hasProp(prop, props) {
14233
14312
  let result = false;
14234
14313
  if (prop.key.type === 4) {
@@ -18377,7 +18456,7 @@ function rewriteFilter(node, context) {
18377
18456
  if (child.type === 4) {
18378
18457
  parseFilter(child, context);
18379
18458
  } else if (child.type === 8) {
18380
- rewriteFilter(node, context);
18459
+ rewriteFilter(child, context);
18381
18460
  } else if (child.type === 5) {
18382
18461
  rewriteFilter(child.content, context);
18383
18462
  }