@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 = 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;
@@ -2703,9 +2700,19 @@ function renderComponentRoot(instance) {
2703
2700
  try {
2704
2701
  if (vnode.shapeFlag & 4) {
2705
2702
  const proxyToUse = withProxy || proxy;
2703
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2704
+ get(target, key, receiver) {
2705
+ warn(
2706
+ `Property '${String(
2707
+ key
2708
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2709
+ );
2710
+ return Reflect.get(target, key, receiver);
2711
+ }
2712
+ }) : proxyToUse;
2706
2713
  result = normalizeVNode(
2707
2714
  render.call(
2708
- proxyToUse,
2715
+ thisProxy,
2709
2716
  proxyToUse,
2710
2717
  renderCache,
2711
2718
  props,
@@ -2956,6 +2963,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
2956
2963
  }
2957
2964
  }
2958
2965
 
2966
+ const COMPONENTS = "components";
2967
+ const DIRECTIVES = "directives";
2968
+ const FILTERS = "filters";
2969
+ function resolveComponent(name, maybeSelfReference) {
2970
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2971
+ }
2972
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2973
+ function resolveDynamicComponent(component) {
2974
+ if (isString(component)) {
2975
+ return resolveAsset(COMPONENTS, component, false) || component;
2976
+ } else {
2977
+ return component || NULL_DYNAMIC_COMPONENT;
2978
+ }
2979
+ }
2980
+ function resolveDirective(name) {
2981
+ return resolveAsset(DIRECTIVES, name);
2982
+ }
2983
+ function resolveFilter$1(name) {
2984
+ return resolveAsset(FILTERS, name);
2985
+ }
2986
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2987
+ const instance = currentRenderingInstance || currentInstance;
2988
+ if (instance) {
2989
+ const Component = instance.type;
2990
+ if (type === COMPONENTS) {
2991
+ const selfName = getComponentName(
2992
+ Component,
2993
+ false
2994
+ /* do not include inferred name to avoid breaking existing code */
2995
+ );
2996
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2997
+ return Component;
2998
+ }
2999
+ }
3000
+ const res = (
3001
+ // local registration
3002
+ // check instance[type] first which is resolved for options API
3003
+ resolve(instance[type] || Component[type], name) || // global registration
3004
+ resolve(instance.appContext[type], name)
3005
+ );
3006
+ if (!res && maybeSelfReference) {
3007
+ return Component;
3008
+ }
3009
+ if (warnMissing && !res) {
3010
+ const extra = type === COMPONENTS ? `
3011
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3012
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3013
+ }
3014
+ return res;
3015
+ } else {
3016
+ warn(
3017
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3018
+ );
3019
+ }
3020
+ }
3021
+ function resolve(registry, name) {
3022
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3023
+ }
3024
+
2959
3025
  const isSuspense = (type) => type.__isSuspense;
2960
3026
  const SuspenseImpl = {
2961
3027
  name: "Suspense",
@@ -3490,7 +3556,7 @@ function normalizeSuspenseSlot(s) {
3490
3556
  }
3491
3557
  if (isArray(s)) {
3492
3558
  const singleChild = filterSingleRoot(s);
3493
- if (!singleChild) {
3559
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3494
3560
  warn(`<Suspense> slots expect a single root node.`);
3495
3561
  }
3496
3562
  s = singleChild;
@@ -3688,6 +3754,7 @@ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger
3688
3754
  let onCleanup = (fn) => {
3689
3755
  cleanup = effect.onStop = () => {
3690
3756
  callWithErrorHandling(fn, instance, 4);
3757
+ cleanup = effect.onStop = void 0;
3691
3758
  };
3692
3759
  };
3693
3760
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4165,7 +4232,11 @@ function emptyPlaceholder(vnode) {
4165
4232
  }
4166
4233
  }
4167
4234
  function getKeepAliveChild(vnode) {
4168
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4235
+ return isKeepAlive(vnode) ? (
4236
+ // #7121 ensure get the child component subtree in case
4237
+ // it's been replaced during HMR
4238
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4239
+ ) : vnode;
4169
4240
  }
4170
4241
  function setTransitionHooks(vnode, hooks) {
4171
4242
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4681,65 +4752,6 @@ function getCompatListeners(instance) {
4681
4752
  return listeners;
4682
4753
  }
4683
4754
 
4684
- const COMPONENTS = "components";
4685
- const DIRECTIVES = "directives";
4686
- const FILTERS = "filters";
4687
- function resolveComponent(name, maybeSelfReference) {
4688
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4689
- }
4690
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4691
- function resolveDynamicComponent(component) {
4692
- if (isString(component)) {
4693
- return resolveAsset(COMPONENTS, component, false) || component;
4694
- } else {
4695
- return component || NULL_DYNAMIC_COMPONENT;
4696
- }
4697
- }
4698
- function resolveDirective(name) {
4699
- return resolveAsset(DIRECTIVES, name);
4700
- }
4701
- function resolveFilter$1(name) {
4702
- return resolveAsset(FILTERS, name);
4703
- }
4704
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4705
- const instance = currentRenderingInstance || currentInstance;
4706
- if (instance) {
4707
- const Component = instance.type;
4708
- if (type === COMPONENTS) {
4709
- const selfName = getComponentName(
4710
- Component,
4711
- false
4712
- /* do not include inferred name to avoid breaking existing code */
4713
- );
4714
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4715
- return Component;
4716
- }
4717
- }
4718
- const res = (
4719
- // local registration
4720
- // check instance[type] first which is resolved for options API
4721
- resolve(instance[type] || Component[type], name) || // global registration
4722
- resolve(instance.appContext[type], name)
4723
- );
4724
- if (!res && maybeSelfReference) {
4725
- return Component;
4726
- }
4727
- if (warnMissing && !res) {
4728
- const extra = type === COMPONENTS ? `
4729
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4730
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4731
- }
4732
- return res;
4733
- } else {
4734
- warn(
4735
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4736
- );
4737
- }
4738
- }
4739
- function resolve(registry, name) {
4740
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4741
- }
4742
-
4743
4755
  function convertLegacyRenderFn(instance) {
4744
4756
  const Component2 = instance.type;
4745
4757
  const render = Component2.render;
@@ -6245,7 +6257,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6245
6257
  return vm;
6246
6258
  }
6247
6259
  }
6248
- Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6260
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.3"}`;
6249
6261
  Vue.config = singletonApp.config;
6250
6262
  Vue.use = (p, ...options) => {
6251
6263
  if (p && isFunction(p.install)) {
@@ -7273,6 +7285,9 @@ function assertType(value, type) {
7273
7285
  };
7274
7286
  }
7275
7287
  function getInvalidTypeMessage(name, value, expectedTypes) {
7288
+ if (expectedTypes.length === 0) {
7289
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7290
+ }
7276
7291
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7277
7292
  const expectedType = expectedTypes[0];
7278
7293
  const receivedType = toRawType(value);
@@ -7544,6 +7559,20 @@ function createHydrationFunctions(rendererInternals) {
7544
7559
  const { type, ref, shapeFlag, patchFlag } = vnode;
7545
7560
  let domType = node.nodeType;
7546
7561
  vnode.el = node;
7562
+ {
7563
+ if (!("__vnode" in node)) {
7564
+ Object.defineProperty(node, "__vnode", {
7565
+ value: vnode,
7566
+ enumerable: false
7567
+ });
7568
+ }
7569
+ if (!("__vueParentComponent" in node)) {
7570
+ Object.defineProperty(node, "__vueParentComponent", {
7571
+ value: parentComponent,
7572
+ enumerable: false
7573
+ });
7574
+ }
7575
+ }
7547
7576
  if (patchFlag === -2) {
7548
7577
  optimized = false;
7549
7578
  vnode.dynamicChildren = null;
@@ -7574,15 +7603,15 @@ function createHydrationFunctions(rendererInternals) {
7574
7603
  }
7575
7604
  break;
7576
7605
  case Comment:
7577
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7578
- if (node.tagName.toLowerCase() === "template") {
7579
- const content = vnode.el.content.firstChild;
7580
- replaceNode(content, node, parentComponent);
7581
- vnode.el = node = content;
7582
- nextNode = nextSibling(node);
7583
- } else {
7584
- nextNode = onMismatch();
7585
- }
7606
+ if (isTemplateNode(node)) {
7607
+ nextNode = nextSibling(node);
7608
+ replaceNode(
7609
+ vnode.el = node.content.firstChild,
7610
+ node,
7611
+ parentComponent
7612
+ );
7613
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7614
+ nextNode = onMismatch();
7586
7615
  } else {
7587
7616
  nextNode = nextSibling(node);
7588
7617
  }
@@ -7705,15 +7734,16 @@ function createHydrationFunctions(rendererInternals) {
7705
7734
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7706
7735
  optimized = optimized || !!vnode.dynamicChildren;
7707
7736
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7708
- const forcePatchValue = type === "input" && dirs || type === "option";
7737
+ const forcePatch = type === "input" || type === "option";
7709
7738
  {
7710
7739
  if (dirs) {
7711
7740
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7712
7741
  }
7713
7742
  if (props) {
7714
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7743
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7715
7744
  for (const key in props) {
7716
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7745
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7746
+ key[0] === ".") {
7717
7747
  patchProp(
7718
7748
  el,
7719
7749
  key,
@@ -7926,8 +7956,7 @@ function createHydrationFunctions(rendererInternals) {
7926
7956
  let parent = parentComponent;
7927
7957
  while (parent) {
7928
7958
  if (parent.vnode.el === oldNode) {
7929
- parent.vnode.el = newNode;
7930
- parent.subTree.el = newNode;
7959
+ parent.vnode.el = parent.subTree.el = newNode;
7931
7960
  }
7932
7961
  parent = parent.parent;
7933
7962
  }
@@ -9511,6 +9540,7 @@ const resolveTarget = (props, select) => {
9511
9540
  }
9512
9541
  };
9513
9542
  const TeleportImpl = {
9543
+ name: "Teleport",
9514
9544
  __isTeleport: true,
9515
9545
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9516
9546
  const {
@@ -9990,7 +10020,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
9990
10020
  if (shapeFlag & 4 && isProxy(type)) {
9991
10021
  type = toRaw(type);
9992
10022
  warn(
9993
- `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\`.`,
10023
+ `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\`.`,
9994
10024
  `
9995
10025
  Component that was made reactive: `,
9996
10026
  type
@@ -10826,7 +10856,7 @@ function isMemoSame(cached, memo) {
10826
10856
  return true;
10827
10857
  }
10828
10858
 
10829
- const version = "3.4.0-alpha.1";
10859
+ const version = "3.4.0-alpha.3";
10830
10860
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10831
10861
  const ssrUtils = null;
10832
10862
  const resolveFilter = resolveFilter$1 ;
@@ -12068,21 +12098,20 @@ const vModelText = {
12068
12098
  el[assignKey] = getModelAssigner(vnode);
12069
12099
  if (el.composing)
12070
12100
  return;
12101
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12102
+ const newValue = value == null ? "" : value;
12103
+ if (elValue === newValue) {
12104
+ return;
12105
+ }
12071
12106
  if (document.activeElement === el && el.type !== "range") {
12072
12107
  if (lazy) {
12073
12108
  return;
12074
12109
  }
12075
- if (trim && el.value.trim() === value) {
12110
+ if (trim && el.value.trim() === newValue) {
12076
12111
  return;
12077
12112
  }
12078
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12079
- return;
12080
- }
12081
- }
12082
- const newValue = value == null ? "" : value;
12083
- if (el.value !== newValue) {
12084
- el.value = newValue;
12085
12113
  }
12114
+ el.value = newValue;
12086
12115
  }
12087
12116
  };
12088
12117
  const vModelCheckbox = {