@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.
package/dist/vue.cjs.js CHANGED
@@ -114,7 +114,7 @@ const PatchFlagNames = {
114
114
  [4]: `STYLE`,
115
115
  [8]: `PROPS`,
116
116
  [16]: `FULL_PROPS`,
117
- [32]: `HYDRATE_EVENTS`,
117
+ [32]: `NEED_HYDRATION`,
118
118
  [64]: `STABLE_FRAGMENT`,
119
119
  [128]: `KEYED_FRAGMENT`,
120
120
  [256]: `UNKEYED_FRAGMENT`,
@@ -1074,7 +1074,7 @@ function createReadonlyMethod(type) {
1074
1074
  toRaw(this)
1075
1075
  );
1076
1076
  }
1077
- return type === "delete" ? false : this;
1077
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1078
1078
  };
1079
1079
  }
1080
1080
  function createInstrumentations() {
@@ -2802,9 +2802,19 @@ function renderComponentRoot(instance) {
2802
2802
  try {
2803
2803
  if (vnode.shapeFlag & 4) {
2804
2804
  const proxyToUse = withProxy || proxy;
2805
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2806
+ get(target, key, receiver) {
2807
+ warn(
2808
+ `Property '${String(
2809
+ key
2810
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2811
+ );
2812
+ return Reflect.get(target, key, receiver);
2813
+ }
2814
+ }) : proxyToUse;
2805
2815
  result = normalizeVNode(
2806
2816
  render.call(
2807
- proxyToUse,
2817
+ thisProxy,
2808
2818
  proxyToUse,
2809
2819
  renderCache,
2810
2820
  props,
@@ -3055,6 +3065,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
3055
3065
  }
3056
3066
  }
3057
3067
 
3068
+ const COMPONENTS = "components";
3069
+ const DIRECTIVES = "directives";
3070
+ const FILTERS = "filters";
3071
+ function resolveComponent(name, maybeSelfReference) {
3072
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3073
+ }
3074
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3075
+ function resolveDynamicComponent(component) {
3076
+ if (isString(component)) {
3077
+ return resolveAsset(COMPONENTS, component, false) || component;
3078
+ } else {
3079
+ return component || NULL_DYNAMIC_COMPONENT;
3080
+ }
3081
+ }
3082
+ function resolveDirective(name) {
3083
+ return resolveAsset(DIRECTIVES, name);
3084
+ }
3085
+ function resolveFilter$1(name) {
3086
+ return resolveAsset(FILTERS, name);
3087
+ }
3088
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3089
+ const instance = currentRenderingInstance || currentInstance;
3090
+ if (instance) {
3091
+ const Component = instance.type;
3092
+ if (type === COMPONENTS) {
3093
+ const selfName = getComponentName(
3094
+ Component,
3095
+ false
3096
+ /* do not include inferred name to avoid breaking existing code */
3097
+ );
3098
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3099
+ return Component;
3100
+ }
3101
+ }
3102
+ const res = (
3103
+ // local registration
3104
+ // check instance[type] first which is resolved for options API
3105
+ resolve(instance[type] || Component[type], name) || // global registration
3106
+ resolve(instance.appContext[type], name)
3107
+ );
3108
+ if (!res && maybeSelfReference) {
3109
+ return Component;
3110
+ }
3111
+ if (warnMissing && !res) {
3112
+ const extra = type === COMPONENTS ? `
3113
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3114
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3115
+ }
3116
+ return res;
3117
+ } else {
3118
+ warn(
3119
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3120
+ );
3121
+ }
3122
+ }
3123
+ function resolve(registry, name) {
3124
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3125
+ }
3126
+
3058
3127
  const isSuspense = (type) => type.__isSuspense;
3059
3128
  const SuspenseImpl = {
3060
3129
  name: "Suspense",
@@ -3589,7 +3658,7 @@ function normalizeSuspenseSlot(s) {
3589
3658
  }
3590
3659
  if (isArray(s)) {
3591
3660
  const singleChild = filterSingleRoot(s);
3592
- if (!singleChild) {
3661
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3593
3662
  warn(`<Suspense> slots expect a single root node.`);
3594
3663
  }
3595
3664
  s = singleChild;
@@ -3775,6 +3844,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3775
3844
  let onCleanup = (fn) => {
3776
3845
  cleanup = effect.onStop = () => {
3777
3846
  callWithErrorHandling(fn, instance, 4);
3847
+ cleanup = effect.onStop = void 0;
3778
3848
  };
3779
3849
  };
3780
3850
  let ssrCleanup;
@@ -4272,7 +4342,11 @@ function emptyPlaceholder(vnode) {
4272
4342
  }
4273
4343
  }
4274
4344
  function getKeepAliveChild(vnode) {
4275
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4345
+ return isKeepAlive(vnode) ? (
4346
+ // #7121 ensure get the child component subtree in case
4347
+ // it's been replaced during HMR
4348
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4349
+ ) : vnode;
4276
4350
  }
4277
4351
  function setTransitionHooks(vnode, hooks) {
4278
4352
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4793,65 +4867,6 @@ function getCompatListeners(instance) {
4793
4867
  return listeners;
4794
4868
  }
4795
4869
 
4796
- const COMPONENTS = "components";
4797
- const DIRECTIVES = "directives";
4798
- const FILTERS = "filters";
4799
- function resolveComponent(name, maybeSelfReference) {
4800
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4801
- }
4802
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4803
- function resolveDynamicComponent(component) {
4804
- if (isString(component)) {
4805
- return resolveAsset(COMPONENTS, component, false) || component;
4806
- } else {
4807
- return component || NULL_DYNAMIC_COMPONENT;
4808
- }
4809
- }
4810
- function resolveDirective(name) {
4811
- return resolveAsset(DIRECTIVES, name);
4812
- }
4813
- function resolveFilter$1(name) {
4814
- return resolveAsset(FILTERS, name);
4815
- }
4816
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4817
- const instance = currentRenderingInstance || currentInstance;
4818
- if (instance) {
4819
- const Component = instance.type;
4820
- if (type === COMPONENTS) {
4821
- const selfName = getComponentName(
4822
- Component,
4823
- false
4824
- /* do not include inferred name to avoid breaking existing code */
4825
- );
4826
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4827
- return Component;
4828
- }
4829
- }
4830
- const res = (
4831
- // local registration
4832
- // check instance[type] first which is resolved for options API
4833
- resolve(instance[type] || Component[type], name) || // global registration
4834
- resolve(instance.appContext[type], name)
4835
- );
4836
- if (!res && maybeSelfReference) {
4837
- return Component;
4838
- }
4839
- if (warnMissing && !res) {
4840
- const extra = type === COMPONENTS ? `
4841
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4842
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4843
- }
4844
- return res;
4845
- } else {
4846
- warn(
4847
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4848
- );
4849
- }
4850
- }
4851
- function resolve(registry, name) {
4852
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4853
- }
4854
-
4855
4870
  function convertLegacyRenderFn(instance) {
4856
4871
  const Component2 = instance.type;
4857
4872
  const render = Component2.render;
@@ -6354,7 +6369,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6354
6369
  return vm;
6355
6370
  }
6356
6371
  }
6357
- Vue.version = `2.6.14-compat:${"3.3.7"}`;
6372
+ Vue.version = `2.6.14-compat:${"3.3.9"}`;
6358
6373
  Vue.config = singletonApp.config;
6359
6374
  Vue.use = (p, ...options) => {
6360
6375
  if (p && isFunction(p.install)) {
@@ -7382,6 +7397,9 @@ function assertType(value, type) {
7382
7397
  };
7383
7398
  }
7384
7399
  function getInvalidTypeMessage(name, value, expectedTypes) {
7400
+ if (expectedTypes.length === 0) {
7401
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7402
+ }
7385
7403
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7386
7404
  const expectedType = expectedTypes[0];
7387
7405
  const receivedType = toRawType(value);
@@ -7653,6 +7671,20 @@ function createHydrationFunctions(rendererInternals) {
7653
7671
  const { type, ref, shapeFlag, patchFlag } = vnode;
7654
7672
  let domType = node.nodeType;
7655
7673
  vnode.el = node;
7674
+ {
7675
+ if (!("__vnode" in node)) {
7676
+ Object.defineProperty(node, "__vnode", {
7677
+ value: vnode,
7678
+ enumerable: false
7679
+ });
7680
+ }
7681
+ if (!("__vueParentComponent" in node)) {
7682
+ Object.defineProperty(node, "__vueParentComponent", {
7683
+ value: parentComponent,
7684
+ enumerable: false
7685
+ });
7686
+ }
7687
+ }
7656
7688
  if (patchFlag === -2) {
7657
7689
  optimized = false;
7658
7690
  vnode.dynamicChildren = null;
@@ -7683,15 +7715,15 @@ function createHydrationFunctions(rendererInternals) {
7683
7715
  }
7684
7716
  break;
7685
7717
  case Comment:
7686
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7687
- if (node.tagName.toLowerCase() === "template") {
7688
- const content = vnode.el.content.firstChild;
7689
- replaceNode(content, node, parentComponent);
7690
- vnode.el = node = content;
7691
- nextNode = nextSibling(node);
7692
- } else {
7693
- nextNode = onMismatch();
7694
- }
7718
+ if (isTemplateNode(node)) {
7719
+ nextNode = nextSibling(node);
7720
+ replaceNode(
7721
+ vnode.el = node.content.firstChild,
7722
+ node,
7723
+ parentComponent
7724
+ );
7725
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7726
+ nextNode = onMismatch();
7695
7727
  } else {
7696
7728
  nextNode = nextSibling(node);
7697
7729
  }
@@ -7814,15 +7846,16 @@ function createHydrationFunctions(rendererInternals) {
7814
7846
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7815
7847
  optimized = optimized || !!vnode.dynamicChildren;
7816
7848
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7817
- const forcePatchValue = type === "input" && dirs || type === "option";
7849
+ const forcePatch = type === "input" || type === "option";
7818
7850
  {
7819
7851
  if (dirs) {
7820
7852
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7821
7853
  }
7822
7854
  if (props) {
7823
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7855
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7824
7856
  for (const key in props) {
7825
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7857
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7858
+ key[0] === ".") {
7826
7859
  patchProp(
7827
7860
  el,
7828
7861
  key,
@@ -8035,8 +8068,7 @@ function createHydrationFunctions(rendererInternals) {
8035
8068
  let parent = parentComponent;
8036
8069
  while (parent) {
8037
8070
  if (parent.vnode.el === oldNode) {
8038
- parent.vnode.el = newNode;
8039
- parent.subTree.el = newNode;
8071
+ parent.vnode.el = parent.subTree.el = newNode;
8040
8072
  }
8041
8073
  parent = parent.parent;
8042
8074
  }
@@ -9614,6 +9646,7 @@ const resolveTarget = (props, select) => {
9614
9646
  }
9615
9647
  };
9616
9648
  const TeleportImpl = {
9649
+ name: "Teleport",
9617
9650
  __isTeleport: true,
9618
9651
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9619
9652
  const {
@@ -10093,7 +10126,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
10093
10126
  if (shapeFlag & 4 && isProxy(type)) {
10094
10127
  type = toRaw(type);
10095
10128
  warn(
10096
- `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\`.`,
10129
+ `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\`.`,
10097
10130
  `
10098
10131
  Component that was made reactive: `,
10099
10132
  type
@@ -10941,7 +10974,7 @@ function isMemoSame(cached, memo) {
10941
10974
  return true;
10942
10975
  }
10943
10976
 
10944
- const version = "3.3.7";
10977
+ const version = "3.3.9";
10945
10978
  const _ssrUtils = {
10946
10979
  createComponentInstance,
10947
10980
  setupComponent,
@@ -12142,21 +12175,20 @@ const vModelText = {
12142
12175
  el[assignKey] = getModelAssigner(vnode);
12143
12176
  if (el.composing)
12144
12177
  return;
12178
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12179
+ const newValue = value == null ? "" : value;
12180
+ if (elValue === newValue) {
12181
+ return;
12182
+ }
12145
12183
  if (document.activeElement === el && el.type !== "range") {
12146
12184
  if (lazy) {
12147
12185
  return;
12148
12186
  }
12149
- if (trim && el.value.trim() === value) {
12150
- return;
12151
- }
12152
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12187
+ if (trim && el.value.trim() === newValue) {
12153
12188
  return;
12154
12189
  }
12155
12190
  }
12156
- const newValue = value == null ? "" : value;
12157
- if (el.value !== newValue) {
12158
- el.value = newValue;
12159
- }
12191
+ el.value = newValue;
12160
12192
  }
12161
12193
  };
12162
12194
  const vModelCheckbox = {
@@ -13302,6 +13334,7 @@ function getMemoedVNodeCall(node) {
13302
13334
  return node;
13303
13335
  }
13304
13336
  }
13337
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13305
13338
 
13306
13339
  const deprecationData = {
13307
13340
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -15552,6 +15585,15 @@ function walkBlockDeclarations(block, onIdent) {
15552
15585
  if (stmt.declare || !stmt.id)
15553
15586
  continue;
15554
15587
  onIdent(stmt.id);
15588
+ } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
15589
+ const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
15590
+ if (variable && variable.type === "VariableDeclaration") {
15591
+ for (const decl of variable.declarations) {
15592
+ for (const id of extractIdentifiers(decl.id)) {
15593
+ onIdent(id);
15594
+ }
15595
+ }
15596
+ }
15555
15597
  }
15556
15598
  }
15557
15599
  }
@@ -15804,8 +15846,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
15804
15846
  const isScopeVarReference = context.identifiers[rawExp];
15805
15847
  const isAllowedGlobal = isGloballyAllowed(rawExp);
15806
15848
  const isLiteral = isLiteralWhitelisted(rawExp);
15807
- if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
15808
- if (isConst(bindingMetadata[node.content])) {
15849
+ if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
15850
+ if (isConst(bindingMetadata[rawExp])) {
15809
15851
  node.constType = 1;
15810
15852
  }
15811
15853
  node.content = rewriteIdentifier(rawExp);
@@ -16342,7 +16384,6 @@ function processFor(node, dir, context, processCodegen) {
16342
16384
  onExit();
16343
16385
  };
16344
16386
  }
16345
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
16346
16387
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
16347
16388
  const stripParensRE = /^\(|\)$/g;
16348
16389
  function parseForExpression(input, context) {
@@ -17024,7 +17065,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17024
17065
  )
17025
17066
  );
17026
17067
  } else {
17027
- const { name, arg, exp, loc } = prop;
17068
+ const { name, arg, exp, loc, modifiers } = prop;
17028
17069
  const isVBind = name === "bind";
17029
17070
  const isVOn = name === "on";
17030
17071
  if (name === "slot") {
@@ -17117,6 +17158,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
17117
17158
  }
17118
17159
  continue;
17119
17160
  }
17161
+ if (isVBind && modifiers.includes("prop")) {
17162
+ patchFlag |= 32;
17163
+ }
17120
17164
  const directiveTransform = context.directiveTransforms[name];
17121
17165
  if (directiveTransform) {
17122
17166
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -20526,8 +20570,8 @@ const transformModel = (dir, node, context) => {
20526
20570
  );
20527
20571
  }
20528
20572
  function checkDuplicatedValue() {
20529
- const value = findProp(node, "value");
20530
- if (value) {
20573
+ const value = findDir(node, "bind");
20574
+ if (value && isStaticArgOf(value.arg, "value")) {
20531
20575
  context.onError(
20532
20576
  createDOMCompilerError(
20533
20577
  60,