vue 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() {
@@ -2272,9 +2272,19 @@ function renderComponentRoot(instance) {
2272
2272
  try {
2273
2273
  if (vnode.shapeFlag & 4) {
2274
2274
  const proxyToUse = withProxy || proxy;
2275
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2276
+ get(target, key, receiver) {
2277
+ warn(
2278
+ `Property '${String(
2279
+ key
2280
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2281
+ );
2282
+ return Reflect.get(target, key, receiver);
2283
+ }
2284
+ }) : proxyToUse;
2275
2285
  result = normalizeVNode(
2276
2286
  render.call(
2277
- proxyToUse,
2287
+ thisProxy,
2278
2288
  proxyToUse,
2279
2289
  renderCache,
2280
2290
  props,
@@ -2509,6 +2519,61 @@ function updateHOCHostEl({ vnode, parent }, el) {
2509
2519
  }
2510
2520
  }
2511
2521
 
2522
+ const COMPONENTS = "components";
2523
+ const DIRECTIVES = "directives";
2524
+ function resolveComponent(name, maybeSelfReference) {
2525
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2526
+ }
2527
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2528
+ function resolveDynamicComponent(component) {
2529
+ if (isString(component)) {
2530
+ return resolveAsset(COMPONENTS, component, false) || component;
2531
+ } else {
2532
+ return component || NULL_DYNAMIC_COMPONENT;
2533
+ }
2534
+ }
2535
+ function resolveDirective(name) {
2536
+ return resolveAsset(DIRECTIVES, name);
2537
+ }
2538
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2539
+ const instance = currentRenderingInstance || currentInstance;
2540
+ if (instance) {
2541
+ const Component = instance.type;
2542
+ if (type === COMPONENTS) {
2543
+ const selfName = getComponentName(
2544
+ Component,
2545
+ false
2546
+ /* do not include inferred name to avoid breaking existing code */
2547
+ );
2548
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2549
+ return Component;
2550
+ }
2551
+ }
2552
+ const res = (
2553
+ // local registration
2554
+ // check instance[type] first which is resolved for options API
2555
+ resolve(instance[type] || Component[type], name) || // global registration
2556
+ resolve(instance.appContext[type], name)
2557
+ );
2558
+ if (!res && maybeSelfReference) {
2559
+ return Component;
2560
+ }
2561
+ if (warnMissing && !res) {
2562
+ const extra = type === COMPONENTS ? `
2563
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
2564
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
2565
+ }
2566
+ return res;
2567
+ } else {
2568
+ warn(
2569
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
2570
+ );
2571
+ }
2572
+ }
2573
+ function resolve(registry, name) {
2574
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2575
+ }
2576
+
2512
2577
  const isSuspense = (type) => type.__isSuspense;
2513
2578
  const SuspenseImpl = {
2514
2579
  name: "Suspense",
@@ -3043,7 +3108,7 @@ function normalizeSuspenseSlot(s) {
3043
3108
  }
3044
3109
  if (isArray(s)) {
3045
3110
  const singleChild = filterSingleRoot(s);
3046
- if (!singleChild) {
3111
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3047
3112
  warn(`<Suspense> slots expect a single root node.`);
3048
3113
  }
3049
3114
  s = singleChild;
@@ -3181,6 +3246,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3181
3246
  let onCleanup = (fn) => {
3182
3247
  cleanup = effect.onStop = () => {
3183
3248
  callWithErrorHandling(fn, instance, 4);
3249
+ cleanup = effect.onStop = void 0;
3184
3250
  };
3185
3251
  };
3186
3252
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3651,7 +3717,11 @@ function emptyPlaceholder(vnode) {
3651
3717
  }
3652
3718
  }
3653
3719
  function getKeepAliveChild(vnode) {
3654
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3720
+ return isKeepAlive(vnode) ? (
3721
+ // #7121 ensure get the child component subtree in case
3722
+ // it's been replaced during HMR
3723
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3724
+ ) : vnode;
3655
3725
  }
3656
3726
  function setTransitionHooks(vnode, hooks) {
3657
3727
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4128,61 +4198,6 @@ function onErrorCaptured(hook, target = currentInstance) {
4128
4198
  injectHook("ec", hook, target);
4129
4199
  }
4130
4200
 
4131
- const COMPONENTS = "components";
4132
- const DIRECTIVES = "directives";
4133
- function resolveComponent(name, maybeSelfReference) {
4134
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4135
- }
4136
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4137
- function resolveDynamicComponent(component) {
4138
- if (isString(component)) {
4139
- return resolveAsset(COMPONENTS, component, false) || component;
4140
- } else {
4141
- return component || NULL_DYNAMIC_COMPONENT;
4142
- }
4143
- }
4144
- function resolveDirective(name) {
4145
- return resolveAsset(DIRECTIVES, name);
4146
- }
4147
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4148
- const instance = currentRenderingInstance || currentInstance;
4149
- if (instance) {
4150
- const Component = instance.type;
4151
- if (type === COMPONENTS) {
4152
- const selfName = getComponentName(
4153
- Component,
4154
- false
4155
- /* do not include inferred name to avoid breaking existing code */
4156
- );
4157
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4158
- return Component;
4159
- }
4160
- }
4161
- const res = (
4162
- // local registration
4163
- // check instance[type] first which is resolved for options API
4164
- resolve(instance[type] || Component[type], name) || // global registration
4165
- resolve(instance.appContext[type], name)
4166
- );
4167
- if (!res && maybeSelfReference) {
4168
- return Component;
4169
- }
4170
- if (warnMissing && !res) {
4171
- const extra = type === COMPONENTS ? `
4172
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4173
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4174
- }
4175
- return res;
4176
- } else {
4177
- warn(
4178
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4179
- );
4180
- }
4181
- }
4182
- function resolve(registry, name) {
4183
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4184
- }
4185
-
4186
4201
  function renderList(source, renderItem, cache, index) {
4187
4202
  let ret;
4188
4203
  const cached = cache && cache[index];
@@ -5699,6 +5714,9 @@ function assertType(value, type) {
5699
5714
  };
5700
5715
  }
5701
5716
  function getInvalidTypeMessage(name, value, expectedTypes) {
5717
+ if (expectedTypes.length === 0) {
5718
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5719
+ }
5702
5720
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5703
5721
  const expectedType = expectedTypes[0];
5704
5722
  const receivedType = toRawType(value);
@@ -5968,6 +5986,20 @@ function createHydrationFunctions(rendererInternals) {
5968
5986
  const { type, ref, shapeFlag, patchFlag } = vnode;
5969
5987
  let domType = node.nodeType;
5970
5988
  vnode.el = node;
5989
+ {
5990
+ if (!("__vnode" in node)) {
5991
+ Object.defineProperty(node, "__vnode", {
5992
+ value: vnode,
5993
+ enumerable: false
5994
+ });
5995
+ }
5996
+ if (!("__vueParentComponent" in node)) {
5997
+ Object.defineProperty(node, "__vueParentComponent", {
5998
+ value: parentComponent,
5999
+ enumerable: false
6000
+ });
6001
+ }
6002
+ }
5971
6003
  if (patchFlag === -2) {
5972
6004
  optimized = false;
5973
6005
  vnode.dynamicChildren = null;
@@ -5998,15 +6030,15 @@ function createHydrationFunctions(rendererInternals) {
5998
6030
  }
5999
6031
  break;
6000
6032
  case Comment:
6001
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6002
- if (node.tagName.toLowerCase() === "template") {
6003
- const content = vnode.el.content.firstChild;
6004
- replaceNode(content, node, parentComponent);
6005
- vnode.el = node = content;
6006
- nextNode = nextSibling(node);
6007
- } else {
6008
- nextNode = onMismatch();
6009
- }
6033
+ if (isTemplateNode(node)) {
6034
+ nextNode = nextSibling(node);
6035
+ replaceNode(
6036
+ vnode.el = node.content.firstChild,
6037
+ node,
6038
+ parentComponent
6039
+ );
6040
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6041
+ nextNode = onMismatch();
6010
6042
  } else {
6011
6043
  nextNode = nextSibling(node);
6012
6044
  }
@@ -6129,15 +6161,16 @@ function createHydrationFunctions(rendererInternals) {
6129
6161
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6130
6162
  optimized = optimized || !!vnode.dynamicChildren;
6131
6163
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6132
- const forcePatchValue = type === "input" && dirs || type === "option";
6164
+ const forcePatch = type === "input" || type === "option";
6133
6165
  {
6134
6166
  if (dirs) {
6135
6167
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6136
6168
  }
6137
6169
  if (props) {
6138
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6170
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6139
6171
  for (const key in props) {
6140
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6172
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6173
+ key[0] === ".") {
6141
6174
  patchProp(
6142
6175
  el,
6143
6176
  key,
@@ -6350,8 +6383,7 @@ function createHydrationFunctions(rendererInternals) {
6350
6383
  let parent = parentComponent;
6351
6384
  while (parent) {
6352
6385
  if (parent.vnode.el === oldNode) {
6353
- parent.vnode.el = newNode;
6354
- parent.subTree.el = newNode;
6386
+ parent.vnode.el = parent.subTree.el = newNode;
6355
6387
  }
6356
6388
  parent = parent.parent;
6357
6389
  }
@@ -7895,6 +7927,7 @@ const resolveTarget = (props, select) => {
7895
7927
  }
7896
7928
  };
7897
7929
  const TeleportImpl = {
7930
+ name: "Teleport",
7898
7931
  __isTeleport: true,
7899
7932
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7900
7933
  const {
@@ -8316,7 +8349,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
8316
8349
  if (shapeFlag & 4 && isProxy(type)) {
8317
8350
  type = toRaw(type);
8318
8351
  warn(
8319
- `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\`.`,
8352
+ `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\`.`,
8320
8353
  `
8321
8354
  Component that was made reactive: `,
8322
8355
  type
@@ -9137,7 +9170,7 @@ function isMemoSame(cached, memo) {
9137
9170
  return true;
9138
9171
  }
9139
9172
 
9140
- const version = "3.3.7";
9173
+ const version = "3.3.9";
9141
9174
  const ssrUtils = null;
9142
9175
  const resolveFilter = null;
9143
9176
  const compatUtils = null;
@@ -10282,21 +10315,20 @@ const vModelText = {
10282
10315
  el[assignKey] = getModelAssigner(vnode);
10283
10316
  if (el.composing)
10284
10317
  return;
10318
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10319
+ const newValue = value == null ? "" : value;
10320
+ if (elValue === newValue) {
10321
+ return;
10322
+ }
10285
10323
  if (document.activeElement === el && el.type !== "range") {
10286
10324
  if (lazy) {
10287
10325
  return;
10288
10326
  }
10289
- if (trim && el.value.trim() === value) {
10327
+ if (trim && el.value.trim() === newValue) {
10290
10328
  return;
10291
10329
  }
10292
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10293
- return;
10294
- }
10295
- }
10296
- const newValue = value == null ? "" : value;
10297
- if (el.value !== newValue) {
10298
- el.value = newValue;
10299
10330
  }
10331
+ el.value = newValue;
10300
10332
  }
10301
10333
  };
10302
10334
  const vModelCheckbox = {
@@ -11361,6 +11393,7 @@ function getMemoedVNodeCall(node) {
11361
11393
  return node;
11362
11394
  }
11363
11395
  }
11396
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
11364
11397
 
11365
11398
  const decodeRE = /&(gt|lt|amp|apos|quot);/g;
11366
11399
  const decodeMap = {
@@ -13589,7 +13622,6 @@ function processFor(node, dir, context, processCodegen) {
13589
13622
  onExit();
13590
13623
  };
13591
13624
  }
13592
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13593
13625
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
13594
13626
  const stripParensRE = /^\(|\)$/g;
13595
13627
  function parseForExpression(input, context) {
@@ -14178,7 +14210,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14178
14210
  )
14179
14211
  );
14180
14212
  } else {
14181
- const { name, arg, exp, loc } = prop;
14213
+ const { name, arg, exp, loc, modifiers } = prop;
14182
14214
  const isVBind = name === "bind";
14183
14215
  const isVOn = name === "on";
14184
14216
  if (name === "slot") {
@@ -14238,6 +14270,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14238
14270
  }
14239
14271
  continue;
14240
14272
  }
14273
+ if (isVBind && modifiers.includes("prop")) {
14274
+ patchFlag |= 32;
14275
+ }
14241
14276
  const directiveTransform = context.directiveTransforms[name];
14242
14277
  if (directiveTransform) {
14243
14278
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -15123,8 +15158,8 @@ const transformModel = (dir, node, context) => {
15123
15158
  );
15124
15159
  }
15125
15160
  function checkDuplicatedValue() {
15126
- const value = findProp(node, "value");
15127
- if (value) {
15161
+ const value = findDir(node, "bind");
15162
+ if (value && isStaticArgOf(value.arg, "value")) {
15128
15163
  context.onError(
15129
15164
  createDOMCompilerError(
15130
15165
  60,