@vue/compat 3.3.7 → 3.3.9

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.
@@ -104,7 +104,7 @@ const PatchFlagNames = {
104
104
  [4]: `STYLE`,
105
105
  [8]: `PROPS`,
106
106
  [16]: `FULL_PROPS`,
107
- [32]: `HYDRATE_EVENTS`,
107
+ [32]: `NEED_HYDRATION`,
108
108
  [64]: `STABLE_FRAGMENT`,
109
109
  [128]: `KEYED_FRAGMENT`,
110
110
  [256]: `UNKEYED_FRAGMENT`,
@@ -1001,7 +1001,7 @@ function createReadonlyMethod(type) {
1001
1001
  toRaw(this)
1002
1002
  );
1003
1003
  }
1004
- return type === "delete" ? false : this;
1004
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1005
1005
  };
1006
1006
  }
1007
1007
  function createInstrumentations() {
@@ -2729,9 +2729,19 @@ function renderComponentRoot(instance) {
2729
2729
  try {
2730
2730
  if (vnode.shapeFlag & 4) {
2731
2731
  const proxyToUse = withProxy || proxy;
2732
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2733
+ get(target, key, receiver) {
2734
+ warn(
2735
+ `Property '${String(
2736
+ key
2737
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2738
+ );
2739
+ return Reflect.get(target, key, receiver);
2740
+ }
2741
+ }) : proxyToUse;
2732
2742
  result = normalizeVNode(
2733
2743
  render.call(
2734
- proxyToUse,
2744
+ thisProxy,
2735
2745
  proxyToUse,
2736
2746
  renderCache,
2737
2747
  props,
@@ -2982,6 +2992,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
2982
2992
  }
2983
2993
  }
2984
2994
 
2995
+ const COMPONENTS = "components";
2996
+ const DIRECTIVES = "directives";
2997
+ const FILTERS = "filters";
2998
+ function resolveComponent(name, maybeSelfReference) {
2999
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3000
+ }
3001
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3002
+ function resolveDynamicComponent(component) {
3003
+ if (isString(component)) {
3004
+ return resolveAsset(COMPONENTS, component, false) || component;
3005
+ } else {
3006
+ return component || NULL_DYNAMIC_COMPONENT;
3007
+ }
3008
+ }
3009
+ function resolveDirective(name) {
3010
+ return resolveAsset(DIRECTIVES, name);
3011
+ }
3012
+ function resolveFilter$1(name) {
3013
+ return resolveAsset(FILTERS, name);
3014
+ }
3015
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3016
+ const instance = currentRenderingInstance || currentInstance;
3017
+ if (instance) {
3018
+ const Component = instance.type;
3019
+ if (type === COMPONENTS) {
3020
+ const selfName = getComponentName(
3021
+ Component,
3022
+ false
3023
+ /* do not include inferred name to avoid breaking existing code */
3024
+ );
3025
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3026
+ return Component;
3027
+ }
3028
+ }
3029
+ const res = (
3030
+ // local registration
3031
+ // check instance[type] first which is resolved for options API
3032
+ resolve(instance[type] || Component[type], name) || // global registration
3033
+ resolve(instance.appContext[type], name)
3034
+ );
3035
+ if (!res && maybeSelfReference) {
3036
+ return Component;
3037
+ }
3038
+ if (warnMissing && !res) {
3039
+ const extra = type === COMPONENTS ? `
3040
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3041
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3042
+ }
3043
+ return res;
3044
+ } else {
3045
+ warn(
3046
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3047
+ );
3048
+ }
3049
+ }
3050
+ function resolve(registry, name) {
3051
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3052
+ }
3053
+
2985
3054
  const isSuspense = (type) => type.__isSuspense;
2986
3055
  const SuspenseImpl = {
2987
3056
  name: "Suspense",
@@ -3516,7 +3585,7 @@ function normalizeSuspenseSlot(s) {
3516
3585
  }
3517
3586
  if (isArray(s)) {
3518
3587
  const singleChild = filterSingleRoot(s);
3519
- if (!singleChild) {
3588
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3520
3589
  warn(`<Suspense> slots expect a single root node.`);
3521
3590
  }
3522
3591
  s = singleChild;
@@ -3702,6 +3771,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3702
3771
  let onCleanup = (fn) => {
3703
3772
  cleanup = effect.onStop = () => {
3704
3773
  callWithErrorHandling(fn, instance, 4);
3774
+ cleanup = effect.onStop = void 0;
3705
3775
  };
3706
3776
  };
3707
3777
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4178,7 +4248,11 @@ function emptyPlaceholder(vnode) {
4178
4248
  }
4179
4249
  }
4180
4250
  function getKeepAliveChild(vnode) {
4181
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4251
+ return isKeepAlive(vnode) ? (
4252
+ // #7121 ensure get the child component subtree in case
4253
+ // it's been replaced during HMR
4254
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4255
+ ) : vnode;
4182
4256
  }
4183
4257
  function setTransitionHooks(vnode, hooks) {
4184
4258
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4693,65 +4767,6 @@ function getCompatListeners(instance) {
4693
4767
  return listeners;
4694
4768
  }
4695
4769
 
4696
- const COMPONENTS = "components";
4697
- const DIRECTIVES = "directives";
4698
- const FILTERS = "filters";
4699
- function resolveComponent(name, maybeSelfReference) {
4700
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4701
- }
4702
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4703
- function resolveDynamicComponent(component) {
4704
- if (isString(component)) {
4705
- return resolveAsset(COMPONENTS, component, false) || component;
4706
- } else {
4707
- return component || NULL_DYNAMIC_COMPONENT;
4708
- }
4709
- }
4710
- function resolveDirective(name) {
4711
- return resolveAsset(DIRECTIVES, name);
4712
- }
4713
- function resolveFilter$1(name) {
4714
- return resolveAsset(FILTERS, name);
4715
- }
4716
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4717
- const instance = currentRenderingInstance || currentInstance;
4718
- if (instance) {
4719
- const Component = instance.type;
4720
- if (type === COMPONENTS) {
4721
- const selfName = getComponentName(
4722
- Component,
4723
- false
4724
- /* do not include inferred name to avoid breaking existing code */
4725
- );
4726
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4727
- return Component;
4728
- }
4729
- }
4730
- const res = (
4731
- // local registration
4732
- // check instance[type] first which is resolved for options API
4733
- resolve(instance[type] || Component[type], name) || // global registration
4734
- resolve(instance.appContext[type], name)
4735
- );
4736
- if (!res && maybeSelfReference) {
4737
- return Component;
4738
- }
4739
- if (warnMissing && !res) {
4740
- const extra = type === COMPONENTS ? `
4741
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4742
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4743
- }
4744
- return res;
4745
- } else {
4746
- warn(
4747
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4748
- );
4749
- }
4750
- }
4751
- function resolve(registry, name) {
4752
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4753
- }
4754
-
4755
4770
  function convertLegacyRenderFn(instance) {
4756
4771
  const Component2 = instance.type;
4757
4772
  const render = Component2.render;
@@ -6254,7 +6269,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6254
6269
  return vm;
6255
6270
  }
6256
6271
  }
6257
- Vue.version = `2.6.14-compat:${"3.3.7"}`;
6272
+ Vue.version = `2.6.14-compat:${"3.3.9"}`;
6258
6273
  Vue.config = singletonApp.config;
6259
6274
  Vue.use = (p, ...options) => {
6260
6275
  if (p && isFunction(p.install)) {
@@ -7282,6 +7297,9 @@ function assertType(value, type) {
7282
7297
  };
7283
7298
  }
7284
7299
  function getInvalidTypeMessage(name, value, expectedTypes) {
7300
+ if (expectedTypes.length === 0) {
7301
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7302
+ }
7285
7303
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7286
7304
  const expectedType = expectedTypes[0];
7287
7305
  const receivedType = toRawType(value);
@@ -7553,6 +7571,20 @@ function createHydrationFunctions(rendererInternals) {
7553
7571
  const { type, ref, shapeFlag, patchFlag } = vnode;
7554
7572
  let domType = node.nodeType;
7555
7573
  vnode.el = node;
7574
+ {
7575
+ if (!("__vnode" in node)) {
7576
+ Object.defineProperty(node, "__vnode", {
7577
+ value: vnode,
7578
+ enumerable: false
7579
+ });
7580
+ }
7581
+ if (!("__vueParentComponent" in node)) {
7582
+ Object.defineProperty(node, "__vueParentComponent", {
7583
+ value: parentComponent,
7584
+ enumerable: false
7585
+ });
7586
+ }
7587
+ }
7556
7588
  if (patchFlag === -2) {
7557
7589
  optimized = false;
7558
7590
  vnode.dynamicChildren = null;
@@ -7583,15 +7615,15 @@ function createHydrationFunctions(rendererInternals) {
7583
7615
  }
7584
7616
  break;
7585
7617
  case Comment:
7586
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7587
- if (node.tagName.toLowerCase() === "template") {
7588
- const content = vnode.el.content.firstChild;
7589
- replaceNode(content, node, parentComponent);
7590
- vnode.el = node = content;
7591
- nextNode = nextSibling(node);
7592
- } else {
7593
- nextNode = onMismatch();
7594
- }
7618
+ if (isTemplateNode(node)) {
7619
+ nextNode = nextSibling(node);
7620
+ replaceNode(
7621
+ vnode.el = node.content.firstChild,
7622
+ node,
7623
+ parentComponent
7624
+ );
7625
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7626
+ nextNode = onMismatch();
7595
7627
  } else {
7596
7628
  nextNode = nextSibling(node);
7597
7629
  }
@@ -7714,15 +7746,16 @@ function createHydrationFunctions(rendererInternals) {
7714
7746
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7715
7747
  optimized = optimized || !!vnode.dynamicChildren;
7716
7748
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7717
- const forcePatchValue = type === "input" && dirs || type === "option";
7749
+ const forcePatch = type === "input" || type === "option";
7718
7750
  {
7719
7751
  if (dirs) {
7720
7752
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7721
7753
  }
7722
7754
  if (props) {
7723
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7755
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7724
7756
  for (const key in props) {
7725
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7757
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7758
+ key[0] === ".") {
7726
7759
  patchProp(
7727
7760
  el,
7728
7761
  key,
@@ -7935,8 +7968,7 @@ function createHydrationFunctions(rendererInternals) {
7935
7968
  let parent = parentComponent;
7936
7969
  while (parent) {
7937
7970
  if (parent.vnode.el === oldNode) {
7938
- parent.vnode.el = newNode;
7939
- parent.subTree.el = newNode;
7971
+ parent.vnode.el = parent.subTree.el = newNode;
7940
7972
  }
7941
7973
  parent = parent.parent;
7942
7974
  }
@@ -9514,6 +9546,7 @@ const resolveTarget = (props, select) => {
9514
9546
  }
9515
9547
  };
9516
9548
  const TeleportImpl = {
9549
+ name: "Teleport",
9517
9550
  __isTeleport: true,
9518
9551
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9519
9552
  const {
@@ -9993,7 +10026,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
9993
10026
  if (shapeFlag & 4 && isProxy(type)) {
9994
10027
  type = toRaw(type);
9995
10028
  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\`.`,
10029
+ `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
10030
  `
9998
10031
  Component that was made reactive: `,
9999
10032
  type
@@ -10829,7 +10862,7 @@ function isMemoSame(cached, memo) {
10829
10862
  return true;
10830
10863
  }
10831
10864
 
10832
- const version = "3.3.7";
10865
+ const version = "3.3.9";
10833
10866
  const ssrUtils = null;
10834
10867
  const resolveFilter = resolveFilter$1 ;
10835
10868
  const _compatUtils = {
@@ -12070,21 +12103,20 @@ const vModelText = {
12070
12103
  el[assignKey] = getModelAssigner(vnode);
12071
12104
  if (el.composing)
12072
12105
  return;
12106
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12107
+ const newValue = value == null ? "" : value;
12108
+ if (elValue === newValue) {
12109
+ return;
12110
+ }
12073
12111
  if (document.activeElement === el && el.type !== "range") {
12074
12112
  if (lazy) {
12075
12113
  return;
12076
12114
  }
12077
- if (trim && el.value.trim() === value) {
12078
- return;
12079
- }
12080
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12115
+ if (trim && el.value.trim() === newValue) {
12081
12116
  return;
12082
12117
  }
12083
12118
  }
12084
- const newValue = value == null ? "" : value;
12085
- if (el.value !== newValue) {
12086
- el.value = newValue;
12087
- }
12119
+ el.value = newValue;
12088
12120
  }
12089
12121
  };
12090
12122
  const vModelCheckbox = {
@@ -13217,6 +13249,7 @@ function getMemoedVNodeCall(node) {
13217
13249
  return node;
13218
13250
  }
13219
13251
  }
13252
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13220
13253
 
13221
13254
  const deprecationData = {
13222
13255
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -15614,7 +15647,6 @@ function processFor(node, dir, context, processCodegen) {
15614
15647
  onExit();
15615
15648
  };
15616
15649
  }
15617
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
15618
15650
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
15619
15651
  const stripParensRE = /^\(|\)$/g;
15620
15652
  function parseForExpression(input, context) {
@@ -16212,7 +16244,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16212
16244
  )
16213
16245
  );
16214
16246
  } else {
16215
- const { name, arg, exp, loc } = prop;
16247
+ const { name, arg, exp, loc, modifiers } = prop;
16216
16248
  const isVBind = name === "bind";
16217
16249
  const isVOn = name === "on";
16218
16250
  if (name === "slot") {
@@ -16305,6 +16337,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16305
16337
  }
16306
16338
  continue;
16307
16339
  }
16340
+ if (isVBind && modifiers.includes("prop")) {
16341
+ patchFlag |= 32;
16342
+ }
16308
16343
  const directiveTransform = context.directiveTransforms[name];
16309
16344
  if (directiveTransform) {
16310
16345
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -17337,8 +17372,8 @@ const transformModel = (dir, node, context) => {
17337
17372
  );
17338
17373
  }
17339
17374
  function checkDuplicatedValue() {
17340
- const value = findProp(node, "value");
17341
- if (value) {
17375
+ const value = findDir(node, "bind");
17376
+ if (value && isStaticArgOf(value.arg, "value")) {
17342
17377
  context.onError(
17343
17378
  createDOMCompilerError(
17344
17379
  60,