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

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,10 +1,6 @@
1
1
  function makeMap(str, expectsLowerCase) {
2
- const map = /* @__PURE__ */ Object.create(null);
3
- const list = str.split(",");
4
- for (let i = 0; i < list.length; i++) {
5
- map[list[i]] = true;
6
- }
7
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
2
+ const set = new Set(str.split(","));
3
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
4
  }
9
5
 
10
6
  const EMPTY_OBJ = !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
@@ -961,7 +957,7 @@ function createReadonlyMethod(type) {
961
957
  toRaw(this)
962
958
  );
963
959
  }
964
- return type === "delete" ? false : this;
960
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
965
961
  };
966
962
  }
967
963
  function createInstrumentations() {
@@ -1217,9 +1213,10 @@ class ComputedRefImpl {
1217
1213
  this.dep = void 0;
1218
1214
  this.__v_isRef = true;
1219
1215
  this["__v_isReadonly"] = false;
1220
- this.effect = new ReactiveEffect(getter, () => {
1221
- triggerRefValue(this, 1);
1222
- });
1216
+ this.effect = new ReactiveEffect(
1217
+ () => getter(this._value),
1218
+ () => triggerRefValue(this, 1)
1219
+ );
1223
1220
  this.effect.computed = this;
1224
1221
  this.effect.active = this._cacheable = !isSSR;
1225
1222
  this["__v_isReadonly"] = isReadonly;
@@ -1615,7 +1612,7 @@ function handleError(err, instance, type, throwInDev = true) {
1615
1612
  if (instance) {
1616
1613
  let cur = instance.parent;
1617
1614
  const exposedInstance = instance.proxy;
1618
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : type;
1615
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : `https://vuejs.org/errors/#runtime-${type}`;
1619
1616
  while (cur) {
1620
1617
  const errorCapturedHooks = cur.ec;
1621
1618
  if (errorCapturedHooks) {
@@ -2712,9 +2709,19 @@ function renderComponentRoot(instance) {
2712
2709
  try {
2713
2710
  if (vnode.shapeFlag & 4) {
2714
2711
  const proxyToUse = withProxy || proxy;
2712
+ const thisProxy = !!(process.env.NODE_ENV !== "production") && setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2713
+ get(target, key, receiver) {
2714
+ warn(
2715
+ `Property '${String(
2716
+ key
2717
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2718
+ );
2719
+ return Reflect.get(target, key, receiver);
2720
+ }
2721
+ }) : proxyToUse;
2715
2722
  result = normalizeVNode(
2716
2723
  render.call(
2717
- proxyToUse,
2724
+ thisProxy,
2718
2725
  proxyToUse,
2719
2726
  renderCache,
2720
2727
  props,
@@ -2965,6 +2972,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
2965
2972
  }
2966
2973
  }
2967
2974
 
2975
+ const COMPONENTS = "components";
2976
+ const DIRECTIVES = "directives";
2977
+ const FILTERS = "filters";
2978
+ function resolveComponent(name, maybeSelfReference) {
2979
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2980
+ }
2981
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2982
+ function resolveDynamicComponent(component) {
2983
+ if (isString(component)) {
2984
+ return resolveAsset(COMPONENTS, component, false) || component;
2985
+ } else {
2986
+ return component || NULL_DYNAMIC_COMPONENT;
2987
+ }
2988
+ }
2989
+ function resolveDirective(name) {
2990
+ return resolveAsset(DIRECTIVES, name);
2991
+ }
2992
+ function resolveFilter$1(name) {
2993
+ return resolveAsset(FILTERS, name);
2994
+ }
2995
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2996
+ const instance = currentRenderingInstance || currentInstance;
2997
+ if (instance) {
2998
+ const Component = instance.type;
2999
+ if (type === COMPONENTS) {
3000
+ const selfName = getComponentName(
3001
+ Component,
3002
+ false
3003
+ /* do not include inferred name to avoid breaking existing code */
3004
+ );
3005
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3006
+ return Component;
3007
+ }
3008
+ }
3009
+ const res = (
3010
+ // local registration
3011
+ // check instance[type] first which is resolved for options API
3012
+ resolve(instance[type] || Component[type], name) || // global registration
3013
+ resolve(instance.appContext[type], name)
3014
+ );
3015
+ if (!res && maybeSelfReference) {
3016
+ return Component;
3017
+ }
3018
+ if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
3019
+ const extra = type === COMPONENTS ? `
3020
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3021
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3022
+ }
3023
+ return res;
3024
+ } else if (!!(process.env.NODE_ENV !== "production")) {
3025
+ warn(
3026
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3027
+ );
3028
+ }
3029
+ }
3030
+ function resolve(registry, name) {
3031
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3032
+ }
3033
+
2968
3034
  const isSuspense = (type) => type.__isSuspense;
2969
3035
  const SuspenseImpl = {
2970
3036
  name: "Suspense",
@@ -3499,7 +3565,7 @@ function normalizeSuspenseSlot(s) {
3499
3565
  }
3500
3566
  if (isArray(s)) {
3501
3567
  const singleChild = filterSingleRoot(s);
3502
- if (!!(process.env.NODE_ENV !== "production") && !singleChild) {
3568
+ if (!!(process.env.NODE_ENV !== "production") && !singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3503
3569
  warn(`<Suspense> slots expect a single root node.`);
3504
3570
  }
3505
3571
  s = singleChild;
@@ -3697,6 +3763,7 @@ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger
3697
3763
  let onCleanup = (fn) => {
3698
3764
  cleanup = effect.onStop = () => {
3699
3765
  callWithErrorHandling(fn, instance, 4);
3766
+ cleanup = effect.onStop = void 0;
3700
3767
  };
3701
3768
  };
3702
3769
  let ssrCleanup;
@@ -4197,7 +4264,11 @@ function emptyPlaceholder(vnode) {
4197
4264
  }
4198
4265
  }
4199
4266
  function getKeepAliveChild(vnode) {
4200
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4267
+ return isKeepAlive(vnode) ? (
4268
+ // #7121 ensure get the child component subtree in case
4269
+ // it's been replaced during HMR
4270
+ !!(process.env.NODE_ENV !== "production") && vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4271
+ ) : vnode;
4201
4272
  }
4202
4273
  function setTransitionHooks(vnode, hooks) {
4203
4274
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4719,65 +4790,6 @@ function getCompatListeners(instance) {
4719
4790
  return listeners;
4720
4791
  }
4721
4792
 
4722
- const COMPONENTS = "components";
4723
- const DIRECTIVES = "directives";
4724
- const FILTERS = "filters";
4725
- function resolveComponent(name, maybeSelfReference) {
4726
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4727
- }
4728
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4729
- function resolveDynamicComponent(component) {
4730
- if (isString(component)) {
4731
- return resolveAsset(COMPONENTS, component, false) || component;
4732
- } else {
4733
- return component || NULL_DYNAMIC_COMPONENT;
4734
- }
4735
- }
4736
- function resolveDirective(name) {
4737
- return resolveAsset(DIRECTIVES, name);
4738
- }
4739
- function resolveFilter$1(name) {
4740
- return resolveAsset(FILTERS, name);
4741
- }
4742
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4743
- const instance = currentRenderingInstance || currentInstance;
4744
- if (instance) {
4745
- const Component = instance.type;
4746
- if (type === COMPONENTS) {
4747
- const selfName = getComponentName(
4748
- Component,
4749
- false
4750
- /* do not include inferred name to avoid breaking existing code */
4751
- );
4752
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4753
- return Component;
4754
- }
4755
- }
4756
- const res = (
4757
- // local registration
4758
- // check instance[type] first which is resolved for options API
4759
- resolve(instance[type] || Component[type], name) || // global registration
4760
- resolve(instance.appContext[type], name)
4761
- );
4762
- if (!res && maybeSelfReference) {
4763
- return Component;
4764
- }
4765
- if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
4766
- const extra = type === COMPONENTS ? `
4767
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4768
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4769
- }
4770
- return res;
4771
- } else if (!!(process.env.NODE_ENV !== "production")) {
4772
- warn(
4773
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4774
- );
4775
- }
4776
- }
4777
- function resolve(registry, name) {
4778
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4779
- }
4780
-
4781
4793
  function convertLegacyRenderFn(instance) {
4782
4794
  const Component2 = instance.type;
4783
4795
  const render = Component2.render;
@@ -6285,7 +6297,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6285
6297
  return vm;
6286
6298
  }
6287
6299
  }
6288
- Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6300
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.3"}`;
6289
6301
  Vue.config = singletonApp.config;
6290
6302
  Vue.use = (p, ...options) => {
6291
6303
  if (p && isFunction(p.install)) {
@@ -7316,6 +7328,9 @@ function assertType(value, type) {
7316
7328
  };
7317
7329
  }
7318
7330
  function getInvalidTypeMessage(name, value, expectedTypes) {
7331
+ if (expectedTypes.length === 0) {
7332
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7333
+ }
7319
7334
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7320
7335
  const expectedType = expectedTypes[0];
7321
7336
  const receivedType = toRawType(value);
@@ -7587,6 +7602,20 @@ function createHydrationFunctions(rendererInternals) {
7587
7602
  const { type, ref, shapeFlag, patchFlag } = vnode;
7588
7603
  let domType = node.nodeType;
7589
7604
  vnode.el = node;
7605
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
7606
+ if (!("__vnode" in node)) {
7607
+ Object.defineProperty(node, "__vnode", {
7608
+ value: vnode,
7609
+ enumerable: false
7610
+ });
7611
+ }
7612
+ if (!("__vueParentComponent" in node)) {
7613
+ Object.defineProperty(node, "__vueParentComponent", {
7614
+ value: parentComponent,
7615
+ enumerable: false
7616
+ });
7617
+ }
7618
+ }
7590
7619
  if (patchFlag === -2) {
7591
7620
  optimized = false;
7592
7621
  vnode.dynamicChildren = null;
@@ -7617,15 +7646,15 @@ function createHydrationFunctions(rendererInternals) {
7617
7646
  }
7618
7647
  break;
7619
7648
  case Comment:
7620
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7621
- if (node.tagName.toLowerCase() === "template") {
7622
- const content = vnode.el.content.firstChild;
7623
- replaceNode(content, node, parentComponent);
7624
- vnode.el = node = content;
7625
- nextNode = nextSibling(node);
7626
- } else {
7627
- nextNode = onMismatch();
7628
- }
7649
+ if (isTemplateNode(node)) {
7650
+ nextNode = nextSibling(node);
7651
+ replaceNode(
7652
+ vnode.el = node.content.firstChild,
7653
+ node,
7654
+ parentComponent
7655
+ );
7656
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7657
+ nextNode = onMismatch();
7629
7658
  } else {
7630
7659
  nextNode = nextSibling(node);
7631
7660
  }
@@ -7748,15 +7777,16 @@ function createHydrationFunctions(rendererInternals) {
7748
7777
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7749
7778
  optimized = optimized || !!vnode.dynamicChildren;
7750
7779
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7751
- const forcePatchValue = type === "input" && dirs || type === "option";
7752
- if (!!(process.env.NODE_ENV !== "production") || forcePatchValue || patchFlag !== -1) {
7780
+ const forcePatch = type === "input" || type === "option";
7781
+ if (!!(process.env.NODE_ENV !== "production") || forcePatch || patchFlag !== -1) {
7753
7782
  if (dirs) {
7754
7783
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7755
7784
  }
7756
7785
  if (props) {
7757
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7786
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7758
7787
  for (const key in props) {
7759
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7788
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7789
+ key[0] === ".") {
7760
7790
  patchProp(
7761
7791
  el,
7762
7792
  key,
@@ -7969,8 +7999,7 @@ function createHydrationFunctions(rendererInternals) {
7969
7999
  let parent = parentComponent;
7970
8000
  while (parent) {
7971
8001
  if (parent.vnode.el === oldNode) {
7972
- parent.vnode.el = newNode;
7973
- parent.subTree.el = newNode;
8002
+ parent.vnode.el = parent.subTree.el = newNode;
7974
8003
  }
7975
8004
  parent = parent.parent;
7976
8005
  }
@@ -9588,6 +9617,7 @@ const resolveTarget = (props, select) => {
9588
9617
  }
9589
9618
  };
9590
9619
  const TeleportImpl = {
9620
+ name: "Teleport",
9591
9621
  __isTeleport: true,
9592
9622
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9593
9623
  const {
@@ -10067,7 +10097,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
10067
10097
  if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && isProxy(type)) {
10068
10098
  type = toRaw(type);
10069
10099
  warn(
10070
- `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\`.`,
10100
+ `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\`.`,
10071
10101
  `
10072
10102
  Component that was made reactive: `,
10073
10103
  type
@@ -10931,7 +10961,7 @@ function isMemoSame(cached, memo) {
10931
10961
  return true;
10932
10962
  }
10933
10963
 
10934
- const version = "3.4.0-alpha.1";
10964
+ const version = "3.4.0-alpha.3";
10935
10965
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10936
10966
  const _ssrUtils = {
10937
10967
  createComponentInstance,
@@ -12188,21 +12218,20 @@ const vModelText = {
12188
12218
  el[assignKey] = getModelAssigner(vnode);
12189
12219
  if (el.composing)
12190
12220
  return;
12221
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12222
+ const newValue = value == null ? "" : value;
12223
+ if (elValue === newValue) {
12224
+ return;
12225
+ }
12191
12226
  if (document.activeElement === el && el.type !== "range") {
12192
12227
  if (lazy) {
12193
12228
  return;
12194
12229
  }
12195
- if (trim && el.value.trim() === value) {
12230
+ if (trim && el.value.trim() === newValue) {
12196
12231
  return;
12197
12232
  }
12198
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12199
- return;
12200
- }
12201
- }
12202
- const newValue = value == null ? "" : value;
12203
- if (el.value !== newValue) {
12204
- el.value = newValue;
12205
12233
  }
12234
+ el.value = newValue;
12206
12235
  }
12207
12236
  };
12208
12237
  const vModelCheckbox = {