@vue/compat 3.4.0-alpha.1 → 3.4.0-alpha.2

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.
@@ -2,12 +2,8 @@ var Vue = (function () {
2
2
  'use strict';
3
3
 
4
4
  function makeMap(str, expectsLowerCase) {
5
- const map = /* @__PURE__ */ Object.create(null);
6
- const list = str.split(",");
7
- for (let i = 0; i < list.length; i++) {
8
- map[list[i]] = true;
9
- }
10
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
5
+ const set = new Set(str.split(","));
6
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
11
7
  }
12
8
 
13
9
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -964,7 +960,7 @@ var Vue = (function () {
964
960
  toRaw(this)
965
961
  );
966
962
  }
967
- return type === "delete" ? false : this;
963
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
968
964
  };
969
965
  }
970
966
  function createInstrumentations() {
@@ -1220,9 +1216,10 @@ var Vue = (function () {
1220
1216
  this.dep = void 0;
1221
1217
  this.__v_isRef = true;
1222
1218
  this["__v_isReadonly"] = false;
1223
- this.effect = new ReactiveEffect(getter, () => {
1224
- triggerRefValue(this, 1);
1225
- });
1219
+ this.effect = new ReactiveEffect(
1220
+ () => getter(this._value),
1221
+ () => triggerRefValue(this, 1)
1222
+ );
1226
1223
  this.effect.computed = this;
1227
1224
  this.effect.active = this._cacheable = !isSSR;
1228
1225
  this["__v_isReadonly"] = isReadonly;
@@ -2706,9 +2703,19 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
2706
2703
  try {
2707
2704
  if (vnode.shapeFlag & 4) {
2708
2705
  const proxyToUse = withProxy || proxy;
2706
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2707
+ get(target, key, receiver) {
2708
+ warn(
2709
+ `Property '${String(
2710
+ key
2711
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2712
+ );
2713
+ return Reflect.get(target, key, receiver);
2714
+ }
2715
+ }) : proxyToUse;
2709
2716
  result = normalizeVNode(
2710
2717
  render.call(
2711
- proxyToUse,
2718
+ thisProxy,
2712
2719
  proxyToUse,
2713
2720
  renderCache,
2714
2721
  props,
@@ -2959,6 +2966,65 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
2959
2966
  }
2960
2967
  }
2961
2968
 
2969
+ const COMPONENTS = "components";
2970
+ const DIRECTIVES = "directives";
2971
+ const FILTERS = "filters";
2972
+ function resolveComponent(name, maybeSelfReference) {
2973
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2974
+ }
2975
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2976
+ function resolveDynamicComponent(component) {
2977
+ if (isString(component)) {
2978
+ return resolveAsset(COMPONENTS, component, false) || component;
2979
+ } else {
2980
+ return component || NULL_DYNAMIC_COMPONENT;
2981
+ }
2982
+ }
2983
+ function resolveDirective(name) {
2984
+ return resolveAsset(DIRECTIVES, name);
2985
+ }
2986
+ function resolveFilter$1(name) {
2987
+ return resolveAsset(FILTERS, name);
2988
+ }
2989
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2990
+ const instance = currentRenderingInstance || currentInstance;
2991
+ if (instance) {
2992
+ const Component = instance.type;
2993
+ if (type === COMPONENTS) {
2994
+ const selfName = getComponentName(
2995
+ Component,
2996
+ false
2997
+ /* do not include inferred name to avoid breaking existing code */
2998
+ );
2999
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3000
+ return Component;
3001
+ }
3002
+ }
3003
+ const res = (
3004
+ // local registration
3005
+ // check instance[type] first which is resolved for options API
3006
+ resolve(instance[type] || Component[type], name) || // global registration
3007
+ resolve(instance.appContext[type], name)
3008
+ );
3009
+ if (!res && maybeSelfReference) {
3010
+ return Component;
3011
+ }
3012
+ if (warnMissing && !res) {
3013
+ const extra = type === COMPONENTS ? `
3014
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3015
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3016
+ }
3017
+ return res;
3018
+ } else {
3019
+ warn(
3020
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3021
+ );
3022
+ }
3023
+ }
3024
+ function resolve(registry, name) {
3025
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3026
+ }
3027
+
2962
3028
  const isSuspense = (type) => type.__isSuspense;
2963
3029
  const SuspenseImpl = {
2964
3030
  name: "Suspense",
@@ -3493,7 +3559,7 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
3493
3559
  }
3494
3560
  if (isArray(s)) {
3495
3561
  const singleChild = filterSingleRoot(s);
3496
- if (!singleChild) {
3562
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3497
3563
  warn(`<Suspense> slots expect a single root node.`);
3498
3564
  }
3499
3565
  s = singleChild;
@@ -3691,6 +3757,7 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
3691
3757
  let onCleanup = (fn) => {
3692
3758
  cleanup = effect.onStop = () => {
3693
3759
  callWithErrorHandling(fn, instance, 4);
3760
+ cleanup = effect.onStop = void 0;
3694
3761
  };
3695
3762
  };
3696
3763
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4168,7 +4235,11 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
4168
4235
  }
4169
4236
  }
4170
4237
  function getKeepAliveChild(vnode) {
4171
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4238
+ return isKeepAlive(vnode) ? (
4239
+ // #7121 ensure get the child component subtree in case
4240
+ // it's been replaced during HMR
4241
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4242
+ ) : vnode;
4172
4243
  }
4173
4244
  function setTransitionHooks(vnode, hooks) {
4174
4245
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4684,65 +4755,6 @@ Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
4684
4755
  return listeners;
4685
4756
  }
4686
4757
 
4687
- const COMPONENTS = "components";
4688
- const DIRECTIVES = "directives";
4689
- const FILTERS = "filters";
4690
- function resolveComponent(name, maybeSelfReference) {
4691
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4692
- }
4693
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4694
- function resolveDynamicComponent(component) {
4695
- if (isString(component)) {
4696
- return resolveAsset(COMPONENTS, component, false) || component;
4697
- } else {
4698
- return component || NULL_DYNAMIC_COMPONENT;
4699
- }
4700
- }
4701
- function resolveDirective(name) {
4702
- return resolveAsset(DIRECTIVES, name);
4703
- }
4704
- function resolveFilter$1(name) {
4705
- return resolveAsset(FILTERS, name);
4706
- }
4707
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4708
- const instance = currentRenderingInstance || currentInstance;
4709
- if (instance) {
4710
- const Component = instance.type;
4711
- if (type === COMPONENTS) {
4712
- const selfName = getComponentName(
4713
- Component,
4714
- false
4715
- /* do not include inferred name to avoid breaking existing code */
4716
- );
4717
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4718
- return Component;
4719
- }
4720
- }
4721
- const res = (
4722
- // local registration
4723
- // check instance[type] first which is resolved for options API
4724
- resolve(instance[type] || Component[type], name) || // global registration
4725
- resolve(instance.appContext[type], name)
4726
- );
4727
- if (!res && maybeSelfReference) {
4728
- return Component;
4729
- }
4730
- if (warnMissing && !res) {
4731
- const extra = type === COMPONENTS ? `
4732
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4733
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4734
- }
4735
- return res;
4736
- } else {
4737
- warn(
4738
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4739
- );
4740
- }
4741
- }
4742
- function resolve(registry, name) {
4743
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4744
- }
4745
-
4746
4758
  function convertLegacyRenderFn(instance) {
4747
4759
  const Component2 = instance.type;
4748
4760
  const render = Component2.render;
@@ -6248,7 +6260,7 @@ If this is a native custom element, make sure to exclude it from component resol
6248
6260
  return vm;
6249
6261
  }
6250
6262
  }
6251
- Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6263
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.2"}`;
6252
6264
  Vue.config = singletonApp.config;
6253
6265
  Vue.use = (p, ...options) => {
6254
6266
  if (p && isFunction(p.install)) {
@@ -7276,6 +7288,9 @@ If you want to remount the same app, move your app creation logic into a factory
7276
7288
  };
7277
7289
  }
7278
7290
  function getInvalidTypeMessage(name, value, expectedTypes) {
7291
+ if (expectedTypes.length === 0) {
7292
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7293
+ }
7279
7294
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7280
7295
  const expectedType = expectedTypes[0];
7281
7296
  const receivedType = toRawType(value);
@@ -7547,6 +7562,20 @@ If you want to remount the same app, move your app creation logic into a factory
7547
7562
  const { type, ref, shapeFlag, patchFlag } = vnode;
7548
7563
  let domType = node.nodeType;
7549
7564
  vnode.el = node;
7565
+ {
7566
+ if (!("__vnode" in node)) {
7567
+ Object.defineProperty(node, "__vnode", {
7568
+ value: vnode,
7569
+ enumerable: false
7570
+ });
7571
+ }
7572
+ if (!("__vueParentComponent" in node)) {
7573
+ Object.defineProperty(node, "__vueParentComponent", {
7574
+ value: parentComponent,
7575
+ enumerable: false
7576
+ });
7577
+ }
7578
+ }
7550
7579
  if (patchFlag === -2) {
7551
7580
  optimized = false;
7552
7581
  vnode.dynamicChildren = null;
@@ -7577,15 +7606,15 @@ If you want to remount the same app, move your app creation logic into a factory
7577
7606
  }
7578
7607
  break;
7579
7608
  case Comment:
7580
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7581
- if (node.tagName.toLowerCase() === "template") {
7582
- const content = vnode.el.content.firstChild;
7583
- replaceNode(content, node, parentComponent);
7584
- vnode.el = node = content;
7585
- nextNode = nextSibling(node);
7586
- } else {
7587
- nextNode = onMismatch();
7588
- }
7609
+ if (isTemplateNode(node)) {
7610
+ nextNode = nextSibling(node);
7611
+ replaceNode(
7612
+ vnode.el = node.content.firstChild,
7613
+ node,
7614
+ parentComponent
7615
+ );
7616
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7617
+ nextNode = onMismatch();
7589
7618
  } else {
7590
7619
  nextNode = nextSibling(node);
7591
7620
  }
@@ -7708,15 +7737,16 @@ If you want to remount the same app, move your app creation logic into a factory
7708
7737
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7709
7738
  optimized = optimized || !!vnode.dynamicChildren;
7710
7739
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7711
- const forcePatchValue = type === "input" && dirs || type === "option";
7740
+ const forcePatch = type === "input" || type === "option";
7712
7741
  {
7713
7742
  if (dirs) {
7714
7743
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7715
7744
  }
7716
7745
  if (props) {
7717
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7746
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7718
7747
  for (const key in props) {
7719
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7748
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7749
+ key[0] === ".") {
7720
7750
  patchProp(
7721
7751
  el,
7722
7752
  key,
@@ -7929,8 +7959,7 @@ If you want to remount the same app, move your app creation logic into a factory
7929
7959
  let parent = parentComponent;
7930
7960
  while (parent) {
7931
7961
  if (parent.vnode.el === oldNode) {
7932
- parent.vnode.el = newNode;
7933
- parent.subTree.el = newNode;
7962
+ parent.vnode.el = parent.subTree.el = newNode;
7934
7963
  }
7935
7964
  parent = parent.parent;
7936
7965
  }
@@ -9514,6 +9543,7 @@ If you want to remount the same app, move your app creation logic into a factory
9514
9543
  }
9515
9544
  };
9516
9545
  const TeleportImpl = {
9546
+ name: "Teleport",
9517
9547
  __isTeleport: true,
9518
9548
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9519
9549
  const {
@@ -9993,7 +10023,7 @@ If you want to remount the same app, move your app creation logic into a factory
9993
10023
  if (shapeFlag & 4 && isProxy(type)) {
9994
10024
  type = toRaw(type);
9995
10025
  warn(
9996
- `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
10026
+ `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
9997
10027
  `
9998
10028
  Component that was made reactive: `,
9999
10029
  type
@@ -10823,7 +10853,7 @@ Component that was made reactive: `,
10823
10853
  return true;
10824
10854
  }
10825
10855
 
10826
- const version = "3.4.0-alpha.1";
10856
+ const version = "3.4.0-alpha.2";
10827
10857
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10828
10858
  const ssrUtils = null;
10829
10859
  const resolveFilter = resolveFilter$1 ;
@@ -12053,21 +12083,20 @@ Component that was made reactive: `,
12053
12083
  el[assignKey] = getModelAssigner(vnode);
12054
12084
  if (el.composing)
12055
12085
  return;
12086
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12087
+ const newValue = value == null ? "" : value;
12088
+ if (elValue === newValue) {
12089
+ return;
12090
+ }
12056
12091
  if (document.activeElement === el && el.type !== "range") {
12057
12092
  if (lazy) {
12058
12093
  return;
12059
12094
  }
12060
- if (trim && el.value.trim() === value) {
12095
+ if (trim && el.value.trim() === newValue) {
12061
12096
  return;
12062
12097
  }
12063
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12064
- return;
12065
- }
12066
- }
12067
- const newValue = value == null ? "" : value;
12068
- if (el.value !== newValue) {
12069
- el.value = newValue;
12070
12098
  }
12099
+ el.value = newValue;
12071
12100
  }
12072
12101
  };
12073
12102
  const vModelCheckbox = {