vue 3.3.8 → 3.3.10

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.
@@ -2,7 +2,7 @@ import * as runtimeDom from '@vue/runtime-dom';
2
2
  import { initCustomFormatter, registerRuntimeCompiler, warn } from '@vue/runtime-dom';
3
3
  export * from '@vue/runtime-dom';
4
4
  import { compile } from '@vue/compiler-dom';
5
- import { isString, NOOP, extend, generateCodeFrame } from '@vue/shared';
5
+ import { isString, NOOP, extend, generateCodeFrame, EMPTY_OBJ } from '@vue/shared';
6
6
 
7
7
  function initDev() {
8
8
  {
@@ -13,7 +13,15 @@ function initDev() {
13
13
  if (!!(process.env.NODE_ENV !== "production")) {
14
14
  initDev();
15
15
  }
16
- const compileCache = /* @__PURE__ */ Object.create(null);
16
+ const compileCache = /* @__PURE__ */ new WeakMap();
17
+ function getCache(options) {
18
+ let c = compileCache.get(options != null ? options : EMPTY_OBJ);
19
+ if (!c) {
20
+ c = /* @__PURE__ */ Object.create(null);
21
+ compileCache.set(options != null ? options : EMPTY_OBJ, c);
22
+ }
23
+ return c;
24
+ }
17
25
  function compileToFunction(template, options) {
18
26
  if (!isString(template)) {
19
27
  if (template.nodeType) {
@@ -24,7 +32,8 @@ function compileToFunction(template, options) {
24
32
  }
25
33
  }
26
34
  const key = template;
27
- const cached = compileCache[key];
35
+ const cache = getCache(options);
36
+ const cached = cache[key];
28
37
  if (cached) {
29
38
  return cached;
30
39
  }
@@ -59,7 +68,7 @@ ${codeFrame}` : message);
59
68
  }
60
69
  const render = new Function("Vue", code)(runtimeDom);
61
70
  render._rc = true;
62
- return compileCache[key] = render;
71
+ return cache[key] = render;
63
72
  }
64
73
  registerRuntimeCompiler(compileToFunction);
65
74
 
@@ -15,8 +15,8 @@ var Vue = (function (exports) {
15
15
  const NOOP = () => {
16
16
  };
17
17
  const NO = () => false;
18
- const onRE = /^on[^a-z]/;
19
- const isOn = (key) => onRE.test(key);
18
+ const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
19
+ (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
20
20
  const isModelListener = (key) => key.startsWith("onUpdate:");
21
21
  const extend = Object.assign;
22
22
  const remove = (arr, el) => {
@@ -107,7 +107,7 @@ var Vue = (function (exports) {
107
107
  [4]: `STYLE`,
108
108
  [8]: `PROPS`,
109
109
  [16]: `FULL_PROPS`,
110
- [32]: `HYDRATE_EVENTS`,
110
+ [32]: `NEED_HYDRATION`,
111
111
  [64]: `STABLE_FRAGMENT`,
112
112
  [128]: `KEYED_FRAGMENT`,
113
113
  [256]: `UNKEYED_FRAGMENT`,
@@ -1004,7 +1004,7 @@ var Vue = (function (exports) {
1004
1004
  toRaw(this)
1005
1005
  );
1006
1006
  }
1007
- return type === "delete" ? false : this;
1007
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1008
1008
  };
1009
1009
  }
1010
1010
  function createInstrumentations() {
@@ -2275,9 +2275,19 @@ var Vue = (function (exports) {
2275
2275
  try {
2276
2276
  if (vnode.shapeFlag & 4) {
2277
2277
  const proxyToUse = withProxy || proxy;
2278
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2279
+ get(target, key, receiver) {
2280
+ warn(
2281
+ `Property '${String(
2282
+ key
2283
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2284
+ );
2285
+ return Reflect.get(target, key, receiver);
2286
+ }
2287
+ }) : proxyToUse;
2278
2288
  result = normalizeVNode(
2279
2289
  render.call(
2280
- proxyToUse,
2290
+ thisProxy,
2281
2291
  proxyToUse,
2282
2292
  renderCache,
2283
2293
  props,
@@ -2888,7 +2898,12 @@ If this is a native custom element, make sure to exclude it from component resol
2888
2898
  if (delayEnter) {
2889
2899
  activeBranch.transition.afterLeave = () => {
2890
2900
  if (pendingId === suspense.pendingId) {
2891
- move(pendingBranch, container2, anchor2, 0);
2901
+ move(
2902
+ pendingBranch,
2903
+ container2,
2904
+ next(activeBranch),
2905
+ 0
2906
+ );
2892
2907
  queuePostFlushCb(effects);
2893
2908
  }
2894
2909
  };
@@ -2935,7 +2950,6 @@ If this is a native custom element, make sure to exclude it from component resol
2935
2950
  }
2936
2951
  const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
2937
2952
  triggerEvent(vnode2, "onFallback");
2938
- const anchor2 = next(activeBranch);
2939
2953
  const mountFallback = () => {
2940
2954
  if (!suspense.isInFallback) {
2941
2955
  return;
@@ -2944,7 +2958,7 @@ If this is a native custom element, make sure to exclude it from component resol
2944
2958
  null,
2945
2959
  fallbackVNode,
2946
2960
  container2,
2947
- anchor2,
2961
+ next(activeBranch),
2948
2962
  parentComponent2,
2949
2963
  null,
2950
2964
  // fallback tree will not have suspense context
@@ -3239,6 +3253,7 @@ If this is a native custom element, make sure to exclude it from component resol
3239
3253
  let onCleanup = (fn) => {
3240
3254
  cleanup = effect.onStop = () => {
3241
3255
  callWithErrorHandling(fn, instance, 4);
3256
+ cleanup = effect.onStop = void 0;
3242
3257
  };
3243
3258
  };
3244
3259
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3709,7 +3724,11 @@ If this is a native custom element, make sure to exclude it from component resol
3709
3724
  }
3710
3725
  }
3711
3726
  function getKeepAliveChild(vnode) {
3712
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3727
+ return isKeepAlive(vnode) ? (
3728
+ // #7121 ensure get the child component subtree in case
3729
+ // it's been replaced during HMR
3730
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3731
+ ) : vnode;
3713
3732
  }
3714
3733
  function setTransitionHooks(vnode, hooks) {
3715
3734
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -5702,6 +5721,9 @@ If you want to remount the same app, move your app creation logic into a factory
5702
5721
  };
5703
5722
  }
5704
5723
  function getInvalidTypeMessage(name, value, expectedTypes) {
5724
+ if (expectedTypes.length === 0) {
5725
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5726
+ }
5705
5727
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5706
5728
  const expectedType = expectedTypes[0];
5707
5729
  const receivedType = toRawType(value);
@@ -5971,6 +5993,20 @@ If you want to remount the same app, move your app creation logic into a factory
5971
5993
  const { type, ref, shapeFlag, patchFlag } = vnode;
5972
5994
  let domType = node.nodeType;
5973
5995
  vnode.el = node;
5996
+ {
5997
+ if (!("__vnode" in node)) {
5998
+ Object.defineProperty(node, "__vnode", {
5999
+ value: vnode,
6000
+ enumerable: false
6001
+ });
6002
+ }
6003
+ if (!("__vueParentComponent" in node)) {
6004
+ Object.defineProperty(node, "__vueParentComponent", {
6005
+ value: parentComponent,
6006
+ enumerable: false
6007
+ });
6008
+ }
6009
+ }
5974
6010
  if (patchFlag === -2) {
5975
6011
  optimized = false;
5976
6012
  vnode.dynamicChildren = null;
@@ -6132,15 +6168,16 @@ If you want to remount the same app, move your app creation logic into a factory
6132
6168
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6133
6169
  optimized = optimized || !!vnode.dynamicChildren;
6134
6170
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6135
- const forcePatchValue = type === "input" && dirs || type === "option";
6171
+ const forcePatch = type === "input" || type === "option";
6136
6172
  {
6137
6173
  if (dirs) {
6138
6174
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6139
6175
  }
6140
6176
  if (props) {
6141
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6177
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6142
6178
  for (const key in props) {
6143
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6179
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6180
+ key[0] === ".") {
6144
6181
  patchProp(
6145
6182
  el,
6146
6183
  key,
@@ -7897,6 +7934,7 @@ If you want to remount the same app, move your app creation logic into a factory
7897
7934
  }
7898
7935
  };
7899
7936
  const TeleportImpl = {
7937
+ name: "Teleport",
7900
7938
  __isTeleport: true,
7901
7939
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7902
7940
  const {
@@ -8318,7 +8356,7 @@ If you want to remount the same app, move your app creation logic into a factory
8318
8356
  if (shapeFlag & 4 && isProxy(type)) {
8319
8357
  type = toRaw(type);
8320
8358
  warn(
8321
- `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\`.`,
8359
+ `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\`.`,
8322
8360
  `
8323
8361
  Component that was made reactive: `,
8324
8362
  type
@@ -8937,9 +8975,9 @@ Component that was made reactive: `,
8937
8975
  return;
8938
8976
  }
8939
8977
  const vueStyle = { style: "color:#3ba776" };
8940
- const numberStyle = { style: "color:#0b1bc9" };
8941
- const stringStyle = { style: "color:#b62e24" };
8942
- const keywordStyle = { style: "color:#9d288c" };
8978
+ const numberStyle = { style: "color:#1677ff" };
8979
+ const stringStyle = { style: "color:#f5222d" };
8980
+ const keywordStyle = { style: "color:#eb2f96" };
8943
8981
  const formatter = {
8944
8982
  header(obj) {
8945
8983
  if (!isObject(obj)) {
@@ -9133,7 +9171,7 @@ Component that was made reactive: `,
9133
9171
  return true;
9134
9172
  }
9135
9173
 
9136
- const version = "3.3.8";
9174
+ const version = "3.3.10";
9137
9175
  const ssrUtils = null;
9138
9176
  const resolveFilter = null;
9139
9177
  const compatUtils = null;
@@ -9745,7 +9783,8 @@ Component that was made reactive: `,
9745
9783
  }
9746
9784
  }
9747
9785
 
9748
- const nativeOnRE = /^on[a-z]/;
9786
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
9787
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
9749
9788
  const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
9750
9789
  if (key === "class") {
9751
9790
  patchClass(el, nextValue, isSVG);
@@ -9779,7 +9818,7 @@ Component that was made reactive: `,
9779
9818
  if (key === "innerHTML" || key === "textContent") {
9780
9819
  return true;
9781
9820
  }
9782
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
9821
+ if (key in el && isNativeOn(key) && isFunction(value)) {
9783
9822
  return true;
9784
9823
  }
9785
9824
  return false;
@@ -9796,7 +9835,11 @@ Component that was made reactive: `,
9796
9835
  if (key === "type" && el.tagName === "TEXTAREA") {
9797
9836
  return false;
9798
9837
  }
9799
- if (nativeOnRE.test(key) && isString(value)) {
9838
+ if (key === "width" || key === "height") {
9839
+ const tag = el.tagName;
9840
+ return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
9841
+ }
9842
+ if (isNativeOn(key) && isString(value)) {
9800
9843
  return false;
9801
9844
  }
9802
9845
  return key in el;
@@ -10266,21 +10309,20 @@ Component that was made reactive: `,
10266
10309
  el[assignKey] = getModelAssigner(vnode);
10267
10310
  if (el.composing)
10268
10311
  return;
10312
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10313
+ const newValue = value == null ? "" : value;
10314
+ if (elValue === newValue) {
10315
+ return;
10316
+ }
10269
10317
  if (document.activeElement === el && el.type !== "range") {
10270
10318
  if (lazy) {
10271
10319
  return;
10272
10320
  }
10273
- if (trim && el.value.trim() === value) {
10321
+ if (trim && el.value.trim() === newValue) {
10274
10322
  return;
10275
10323
  }
10276
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10277
- return;
10278
- }
10279
- }
10280
- const newValue = value == null ? "" : value;
10281
- if (el.value !== newValue) {
10282
- el.value = newValue;
10283
10324
  }
10325
+ el.value = newValue;
10284
10326
  }
10285
10327
  };
10286
10328
  const vModelCheckbox = {
@@ -10466,14 +10508,14 @@ Component that was made reactive: `,
10466
10508
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
10467
10509
  };
10468
10510
  const withModifiers = (fn, modifiers) => {
10469
- return (event, ...args) => {
10511
+ return fn._withMods || (fn._withMods = (event, ...args) => {
10470
10512
  for (let i = 0; i < modifiers.length; i++) {
10471
10513
  const guard = modifierGuards[modifiers[i]];
10472
10514
  if (guard && guard(event, modifiers))
10473
10515
  return;
10474
10516
  }
10475
10517
  return fn(event, ...args);
10476
- };
10518
+ });
10477
10519
  };
10478
10520
  const keyNames = {
10479
10521
  esc: "escape",
@@ -10485,7 +10527,7 @@ Component that was made reactive: `,
10485
10527
  delete: "backspace"
10486
10528
  };
10487
10529
  const withKeys = (fn, modifiers) => {
10488
- return (event) => {
10530
+ return fn._withKeys || (fn._withKeys = (event) => {
10489
10531
  if (!("key" in event)) {
10490
10532
  return;
10491
10533
  }
@@ -10493,7 +10535,7 @@ Component that was made reactive: `,
10493
10535
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
10494
10536
  return fn(event);
10495
10537
  }
10496
- };
10538
+ });
10497
10539
  };
10498
10540
 
10499
10541
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
@@ -11188,6 +11230,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
11188
11230
  return node;
11189
11231
  }
11190
11232
  }
11233
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
11191
11234
 
11192
11235
  const decodeRE = /&(gt|lt|amp|apos|quot);/g;
11193
11236
  const decodeMap = {
@@ -13416,7 +13459,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13416
13459
  onExit();
13417
13460
  };
13418
13461
  }
13419
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13420
13462
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
13421
13463
  const stripParensRE = /^\(|\)$/g;
13422
13464
  function parseForExpression(input, context) {
@@ -13952,6 +13994,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
13952
13994
  if (isEventHandler && isReservedProp(name)) {
13953
13995
  hasVnodeHook = true;
13954
13996
  }
13997
+ if (isEventHandler && value.type === 14) {
13998
+ value = value.arguments[0];
13999
+ }
13955
14000
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
13956
14001
  return;
13957
14002
  }
@@ -14005,7 +14050,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14005
14050
  )
14006
14051
  );
14007
14052
  } else {
14008
- const { name, arg, exp, loc } = prop;
14053
+ const { name, arg, exp, loc, modifiers } = prop;
14009
14054
  const isVBind = name === "bind";
14010
14055
  const isVOn = name === "on";
14011
14056
  if (name === "slot") {
@@ -14065,6 +14110,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14065
14110
  }
14066
14111
  continue;
14067
14112
  }
14113
+ if (isVBind && modifiers.includes("prop")) {
14114
+ patchFlag |= 32;
14115
+ }
14068
14116
  const directiveTransform = context.directiveTransforms[name];
14069
14117
  if (directiveTransform) {
14070
14118
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -14950,8 +14998,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
14950
14998
  );
14951
14999
  }
14952
15000
  function checkDuplicatedValue() {
14953
- const value = findProp(node, "value");
14954
- if (value) {
15001
+ const value = findDir(node, "bind");
15002
+ if (value && isStaticArgOf(value.arg, "value")) {
14955
15003
  context.onError(
14956
15004
  createDOMCompilerError(
14957
15005
  60,
@@ -15219,7 +15267,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15219
15267
  {
15220
15268
  initDev();
15221
15269
  }
15222
- const compileCache = /* @__PURE__ */ Object.create(null);
15270
+ const compileCache = /* @__PURE__ */ new WeakMap();
15271
+ function getCache(options) {
15272
+ let c = compileCache.get(options != null ? options : EMPTY_OBJ);
15273
+ if (!c) {
15274
+ c = /* @__PURE__ */ Object.create(null);
15275
+ compileCache.set(options != null ? options : EMPTY_OBJ, c);
15276
+ }
15277
+ return c;
15278
+ }
15223
15279
  function compileToFunction(template, options) {
15224
15280
  if (!isString(template)) {
15225
15281
  if (template.nodeType) {
@@ -15230,7 +15286,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
15230
15286
  }
15231
15287
  }
15232
15288
  const key = template;
15233
- const cached = compileCache[key];
15289
+ const cache = getCache(options);
15290
+ const cached = cache[key];
15234
15291
  if (cached) {
15235
15292
  return cached;
15236
15293
  }
@@ -15265,7 +15322,7 @@ ${codeFrame}` : message);
15265
15322
  }
15266
15323
  const render = new Function(code)() ;
15267
15324
  render._rc = true;
15268
- return compileCache[key] = render;
15325
+ return cache[key] = render;
15269
15326
  }
15270
15327
  registerRuntimeCompiler(compileToFunction);
15271
15328