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.
@@ -1,5 +1,3 @@
1
1
  if (typeof require !== 'undefined') {
2
- try {
3
- require('@vue/compiler-sfc').registerTS(() => require('typescript'))
4
- } catch (e) {}
2
+ require('@vue/compiler-sfc').registerTS(() => require('typescript'))
5
3
  }
package/dist/vue.cjs.js CHANGED
@@ -19,7 +19,15 @@ function _interopNamespaceDefault(e) {
19
19
 
20
20
  var runtimeDom__namespace = /*#__PURE__*/_interopNamespaceDefault(runtimeDom);
21
21
 
22
- const compileCache = /* @__PURE__ */ Object.create(null);
22
+ const compileCache = /* @__PURE__ */ new WeakMap();
23
+ function getCache(options) {
24
+ let c = compileCache.get(options != null ? options : shared.EMPTY_OBJ);
25
+ if (!c) {
26
+ c = /* @__PURE__ */ Object.create(null);
27
+ compileCache.set(options != null ? options : shared.EMPTY_OBJ, c);
28
+ }
29
+ return c;
30
+ }
23
31
  function compileToFunction(template, options) {
24
32
  if (!shared.isString(template)) {
25
33
  if (template.nodeType) {
@@ -30,7 +38,8 @@ function compileToFunction(template, options) {
30
38
  }
31
39
  }
32
40
  const key = template;
33
- const cached = compileCache[key];
41
+ const cache = getCache(options);
42
+ const cached = cache[key];
34
43
  if (cached) {
35
44
  return cached;
36
45
  }
@@ -65,7 +74,7 @@ ${codeFrame}` : message);
65
74
  }
66
75
  const render = new Function("Vue", code)(runtimeDom__namespace);
67
76
  render._rc = true;
68
- return compileCache[key] = render;
77
+ return cache[key] = render;
69
78
  }
70
79
  runtimeDom.registerRuntimeCompiler(compileToFunction);
71
80
 
@@ -19,7 +19,15 @@ function _interopNamespaceDefault(e) {
19
19
 
20
20
  var runtimeDom__namespace = /*#__PURE__*/_interopNamespaceDefault(runtimeDom);
21
21
 
22
- const compileCache = /* @__PURE__ */ Object.create(null);
22
+ const compileCache = /* @__PURE__ */ new WeakMap();
23
+ function getCache(options) {
24
+ let c = compileCache.get(options != null ? options : shared.EMPTY_OBJ);
25
+ if (!c) {
26
+ c = /* @__PURE__ */ Object.create(null);
27
+ compileCache.set(options != null ? options : shared.EMPTY_OBJ, c);
28
+ }
29
+ return c;
30
+ }
23
31
  function compileToFunction(template, options) {
24
32
  if (!shared.isString(template)) {
25
33
  if (template.nodeType) {
@@ -29,7 +37,8 @@ function compileToFunction(template, options) {
29
37
  }
30
38
  }
31
39
  const key = template;
32
- const cached = compileCache[key];
40
+ const cache = getCache(options);
41
+ const cached = cache[key];
33
42
  if (cached) {
34
43
  return cached;
35
44
  }
@@ -51,7 +60,7 @@ function compileToFunction(template, options) {
51
60
  const { code } = compilerDom.compile(template, opts);
52
61
  const render = new Function("Vue", code)(runtimeDom__namespace);
53
62
  render._rc = true;
54
- return compileCache[key] = render;
63
+ return cache[key] = render;
55
64
  }
56
65
  runtimeDom.registerRuntimeCompiler(compileToFunction);
57
66
 
@@ -12,8 +12,8 @@ const EMPTY_ARR = Object.freeze([]) ;
12
12
  const NOOP = () => {
13
13
  };
14
14
  const NO = () => false;
15
- const onRE = /^on[^a-z]/;
16
- const isOn = (key) => onRE.test(key);
15
+ const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
16
+ (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
17
17
  const isModelListener = (key) => key.startsWith("onUpdate:");
18
18
  const extend = Object.assign;
19
19
  const remove = (arr, el) => {
@@ -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,
@@ -2885,7 +2895,12 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2885
2895
  if (delayEnter) {
2886
2896
  activeBranch.transition.afterLeave = () => {
2887
2897
  if (pendingId === suspense.pendingId) {
2888
- move(pendingBranch, container2, anchor2, 0);
2898
+ move(
2899
+ pendingBranch,
2900
+ container2,
2901
+ next(activeBranch),
2902
+ 0
2903
+ );
2889
2904
  queuePostFlushCb(effects);
2890
2905
  }
2891
2906
  };
@@ -2932,7 +2947,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2932
2947
  }
2933
2948
  const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
2934
2949
  triggerEvent(vnode2, "onFallback");
2935
- const anchor2 = next(activeBranch);
2936
2950
  const mountFallback = () => {
2937
2951
  if (!suspense.isInFallback) {
2938
2952
  return;
@@ -2941,7 +2955,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2941
2955
  null,
2942
2956
  fallbackVNode,
2943
2957
  container2,
2944
- anchor2,
2958
+ next(activeBranch),
2945
2959
  parentComponent2,
2946
2960
  null,
2947
2961
  // fallback tree will not have suspense context
@@ -3236,6 +3250,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3236
3250
  let onCleanup = (fn) => {
3237
3251
  cleanup = effect.onStop = () => {
3238
3252
  callWithErrorHandling(fn, instance, 4);
3253
+ cleanup = effect.onStop = void 0;
3239
3254
  };
3240
3255
  };
3241
3256
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3706,7 +3721,11 @@ function emptyPlaceholder(vnode) {
3706
3721
  }
3707
3722
  }
3708
3723
  function getKeepAliveChild(vnode) {
3709
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3724
+ return isKeepAlive(vnode) ? (
3725
+ // #7121 ensure get the child component subtree in case
3726
+ // it's been replaced during HMR
3727
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3728
+ ) : vnode;
3710
3729
  }
3711
3730
  function setTransitionHooks(vnode, hooks) {
3712
3731
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -5699,6 +5718,9 @@ function assertType(value, type) {
5699
5718
  };
5700
5719
  }
5701
5720
  function getInvalidTypeMessage(name, value, expectedTypes) {
5721
+ if (expectedTypes.length === 0) {
5722
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5723
+ }
5702
5724
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5703
5725
  const expectedType = expectedTypes[0];
5704
5726
  const receivedType = toRawType(value);
@@ -5968,6 +5990,20 @@ function createHydrationFunctions(rendererInternals) {
5968
5990
  const { type, ref, shapeFlag, patchFlag } = vnode;
5969
5991
  let domType = node.nodeType;
5970
5992
  vnode.el = node;
5993
+ {
5994
+ if (!("__vnode" in node)) {
5995
+ Object.defineProperty(node, "__vnode", {
5996
+ value: vnode,
5997
+ enumerable: false
5998
+ });
5999
+ }
6000
+ if (!("__vueParentComponent" in node)) {
6001
+ Object.defineProperty(node, "__vueParentComponent", {
6002
+ value: parentComponent,
6003
+ enumerable: false
6004
+ });
6005
+ }
6006
+ }
5971
6007
  if (patchFlag === -2) {
5972
6008
  optimized = false;
5973
6009
  vnode.dynamicChildren = null;
@@ -6129,15 +6165,16 @@ function createHydrationFunctions(rendererInternals) {
6129
6165
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6130
6166
  optimized = optimized || !!vnode.dynamicChildren;
6131
6167
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6132
- const forcePatchValue = type === "input" && dirs || type === "option";
6168
+ const forcePatch = type === "input" || type === "option";
6133
6169
  {
6134
6170
  if (dirs) {
6135
6171
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6136
6172
  }
6137
6173
  if (props) {
6138
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6174
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6139
6175
  for (const key in props) {
6140
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6176
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6177
+ key[0] === ".") {
6141
6178
  patchProp(
6142
6179
  el,
6143
6180
  key,
@@ -7894,6 +7931,7 @@ const resolveTarget = (props, select) => {
7894
7931
  }
7895
7932
  };
7896
7933
  const TeleportImpl = {
7934
+ name: "Teleport",
7897
7935
  __isTeleport: true,
7898
7936
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7899
7937
  const {
@@ -8315,7 +8353,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
8315
8353
  if (shapeFlag & 4 && isProxy(type)) {
8316
8354
  type = toRaw(type);
8317
8355
  warn(
8318
- `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\`.`,
8356
+ `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\`.`,
8319
8357
  `
8320
8358
  Component that was made reactive: `,
8321
8359
  type
@@ -8940,9 +8978,9 @@ function initCustomFormatter() {
8940
8978
  return;
8941
8979
  }
8942
8980
  const vueStyle = { style: "color:#3ba776" };
8943
- const numberStyle = { style: "color:#0b1bc9" };
8944
- const stringStyle = { style: "color:#b62e24" };
8945
- const keywordStyle = { style: "color:#9d288c" };
8981
+ const numberStyle = { style: "color:#1677ff" };
8982
+ const stringStyle = { style: "color:#f5222d" };
8983
+ const keywordStyle = { style: "color:#eb2f96" };
8946
8984
  const formatter = {
8947
8985
  header(obj) {
8948
8986
  if (!isObject(obj)) {
@@ -9136,7 +9174,7 @@ function isMemoSame(cached, memo) {
9136
9174
  return true;
9137
9175
  }
9138
9176
 
9139
- const version = "3.3.8";
9177
+ const version = "3.3.10";
9140
9178
  const ssrUtils = null;
9141
9179
  const resolveFilter = null;
9142
9180
  const compatUtils = null;
@@ -9748,7 +9786,8 @@ function patchStopImmediatePropagation(e, value) {
9748
9786
  }
9749
9787
  }
9750
9788
 
9751
- const nativeOnRE = /^on[a-z]/;
9789
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
9790
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
9752
9791
  const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
9753
9792
  if (key === "class") {
9754
9793
  patchClass(el, nextValue, isSVG);
@@ -9782,7 +9821,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
9782
9821
  if (key === "innerHTML" || key === "textContent") {
9783
9822
  return true;
9784
9823
  }
9785
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
9824
+ if (key in el && isNativeOn(key) && isFunction(value)) {
9786
9825
  return true;
9787
9826
  }
9788
9827
  return false;
@@ -9799,7 +9838,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
9799
9838
  if (key === "type" && el.tagName === "TEXTAREA") {
9800
9839
  return false;
9801
9840
  }
9802
- if (nativeOnRE.test(key) && isString(value)) {
9841
+ if (key === "width" || key === "height") {
9842
+ const tag = el.tagName;
9843
+ return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
9844
+ }
9845
+ if (isNativeOn(key) && isString(value)) {
9803
9846
  return false;
9804
9847
  }
9805
9848
  return key in el;
@@ -10281,21 +10324,20 @@ const vModelText = {
10281
10324
  el[assignKey] = getModelAssigner(vnode);
10282
10325
  if (el.composing)
10283
10326
  return;
10327
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10328
+ const newValue = value == null ? "" : value;
10329
+ if (elValue === newValue) {
10330
+ return;
10331
+ }
10284
10332
  if (document.activeElement === el && el.type !== "range") {
10285
10333
  if (lazy) {
10286
10334
  return;
10287
10335
  }
10288
- if (trim && el.value.trim() === value) {
10336
+ if (trim && el.value.trim() === newValue) {
10289
10337
  return;
10290
10338
  }
10291
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10292
- return;
10293
- }
10294
- }
10295
- const newValue = value == null ? "" : value;
10296
- if (el.value !== newValue) {
10297
- el.value = newValue;
10298
10339
  }
10340
+ el.value = newValue;
10299
10341
  }
10300
10342
  };
10301
10343
  const vModelCheckbox = {
@@ -10481,14 +10523,14 @@ const modifierGuards = {
10481
10523
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
10482
10524
  };
10483
10525
  const withModifiers = (fn, modifiers) => {
10484
- return (event, ...args) => {
10526
+ return fn._withMods || (fn._withMods = (event, ...args) => {
10485
10527
  for (let i = 0; i < modifiers.length; i++) {
10486
10528
  const guard = modifierGuards[modifiers[i]];
10487
10529
  if (guard && guard(event, modifiers))
10488
10530
  return;
10489
10531
  }
10490
10532
  return fn(event, ...args);
10491
- };
10533
+ });
10492
10534
  };
10493
10535
  const keyNames = {
10494
10536
  esc: "escape",
@@ -10500,7 +10542,7 @@ const keyNames = {
10500
10542
  delete: "backspace"
10501
10543
  };
10502
10544
  const withKeys = (fn, modifiers) => {
10503
- return (event) => {
10545
+ return fn._withKeys || (fn._withKeys = (event) => {
10504
10546
  if (!("key" in event)) {
10505
10547
  return;
10506
10548
  }
@@ -10508,7 +10550,7 @@ const withKeys = (fn, modifiers) => {
10508
10550
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
10509
10551
  return fn(event);
10510
10552
  }
10511
- };
10553
+ });
10512
10554
  };
10513
10555
 
10514
10556
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
@@ -11360,6 +11402,7 @@ function getMemoedVNodeCall(node) {
11360
11402
  return node;
11361
11403
  }
11362
11404
  }
11405
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
11363
11406
 
11364
11407
  const decodeRE = /&(gt|lt|amp|apos|quot);/g;
11365
11408
  const decodeMap = {
@@ -13588,7 +13631,6 @@ function processFor(node, dir, context, processCodegen) {
13588
13631
  onExit();
13589
13632
  };
13590
13633
  }
13591
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13592
13634
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
13593
13635
  const stripParensRE = /^\(|\)$/g;
13594
13636
  function parseForExpression(input, context) {
@@ -14124,6 +14166,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14124
14166
  if (isEventHandler && isReservedProp(name)) {
14125
14167
  hasVnodeHook = true;
14126
14168
  }
14169
+ if (isEventHandler && value.type === 14) {
14170
+ value = value.arguments[0];
14171
+ }
14127
14172
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
14128
14173
  return;
14129
14174
  }
@@ -14177,7 +14222,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14177
14222
  )
14178
14223
  );
14179
14224
  } else {
14180
- const { name, arg, exp, loc } = prop;
14225
+ const { name, arg, exp, loc, modifiers } = prop;
14181
14226
  const isVBind = name === "bind";
14182
14227
  const isVOn = name === "on";
14183
14228
  if (name === "slot") {
@@ -14237,6 +14282,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14237
14282
  }
14238
14283
  continue;
14239
14284
  }
14285
+ if (isVBind && modifiers.includes("prop")) {
14286
+ patchFlag |= 32;
14287
+ }
14240
14288
  const directiveTransform = context.directiveTransforms[name];
14241
14289
  if (directiveTransform) {
14242
14290
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -15122,8 +15170,8 @@ const transformModel = (dir, node, context) => {
15122
15170
  );
15123
15171
  }
15124
15172
  function checkDuplicatedValue() {
15125
- const value = findProp(node, "value");
15126
- if (value) {
15173
+ const value = findDir(node, "bind");
15174
+ if (value && isStaticArgOf(value.arg, "value")) {
15127
15175
  context.onError(
15128
15176
  createDOMCompilerError(
15129
15177
  60,
@@ -15391,7 +15439,15 @@ function compile(template, options = {}) {
15391
15439
  {
15392
15440
  initDev();
15393
15441
  }
15394
- const compileCache = /* @__PURE__ */ Object.create(null);
15442
+ const compileCache = /* @__PURE__ */ new WeakMap();
15443
+ function getCache(options) {
15444
+ let c = compileCache.get(options != null ? options : EMPTY_OBJ);
15445
+ if (!c) {
15446
+ c = /* @__PURE__ */ Object.create(null);
15447
+ compileCache.set(options != null ? options : EMPTY_OBJ, c);
15448
+ }
15449
+ return c;
15450
+ }
15395
15451
  function compileToFunction(template, options) {
15396
15452
  if (!isString(template)) {
15397
15453
  if (template.nodeType) {
@@ -15402,7 +15458,8 @@ function compileToFunction(template, options) {
15402
15458
  }
15403
15459
  }
15404
15460
  const key = template;
15405
- const cached = compileCache[key];
15461
+ const cache = getCache(options);
15462
+ const cached = cache[key];
15406
15463
  if (cached) {
15407
15464
  return cached;
15408
15465
  }
@@ -15437,7 +15494,7 @@ ${codeFrame}` : message);
15437
15494
  }
15438
15495
  const render = new Function("Vue", code)(runtimeDom);
15439
15496
  render._rc = true;
15440
- return compileCache[key] = render;
15497
+ return cache[key] = render;
15441
15498
  }
15442
15499
  registerRuntimeCompiler(compileToFunction);
15443
15500