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.
@@ -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) => {
@@ -936,7 +936,7 @@ function createReadonlyMethod(type) {
936
936
  toRaw(this)
937
937
  );
938
938
  }
939
- return type === "delete" ? false : this;
939
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
940
940
  };
941
941
  }
942
942
  function createInstrumentations() {
@@ -2207,9 +2207,19 @@ function renderComponentRoot(instance) {
2207
2207
  try {
2208
2208
  if (vnode.shapeFlag & 4) {
2209
2209
  const proxyToUse = withProxy || proxy;
2210
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2211
+ get(target, key, receiver) {
2212
+ warn(
2213
+ `Property '${String(
2214
+ key
2215
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2216
+ );
2217
+ return Reflect.get(target, key, receiver);
2218
+ }
2219
+ }) : proxyToUse;
2210
2220
  result = normalizeVNode(
2211
2221
  render.call(
2212
- proxyToUse,
2222
+ thisProxy,
2213
2223
  proxyToUse,
2214
2224
  renderCache,
2215
2225
  props,
@@ -2820,7 +2830,12 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2820
2830
  if (delayEnter) {
2821
2831
  activeBranch.transition.afterLeave = () => {
2822
2832
  if (pendingId === suspense.pendingId) {
2823
- move(pendingBranch, container2, anchor2, 0);
2833
+ move(
2834
+ pendingBranch,
2835
+ container2,
2836
+ next(activeBranch),
2837
+ 0
2838
+ );
2824
2839
  queuePostFlushCb(effects);
2825
2840
  }
2826
2841
  };
@@ -2867,7 +2882,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2867
2882
  }
2868
2883
  const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
2869
2884
  triggerEvent(vnode2, "onFallback");
2870
- const anchor2 = next(activeBranch);
2871
2885
  const mountFallback = () => {
2872
2886
  if (!suspense.isInFallback) {
2873
2887
  return;
@@ -2876,7 +2890,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2876
2890
  null,
2877
2891
  fallbackVNode,
2878
2892
  container2,
2879
- anchor2,
2893
+ next(activeBranch),
2880
2894
  parentComponent2,
2881
2895
  null,
2882
2896
  // fallback tree will not have suspense context
@@ -3171,6 +3185,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3171
3185
  let onCleanup = (fn) => {
3172
3186
  cleanup = effect.onStop = () => {
3173
3187
  callWithErrorHandling(fn, instance, 4);
3188
+ cleanup = effect.onStop = void 0;
3174
3189
  };
3175
3190
  };
3176
3191
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3641,7 +3656,11 @@ function emptyPlaceholder(vnode) {
3641
3656
  }
3642
3657
  }
3643
3658
  function getKeepAliveChild(vnode) {
3644
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3659
+ return isKeepAlive(vnode) ? (
3660
+ // #7121 ensure get the child component subtree in case
3661
+ // it's been replaced during HMR
3662
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3663
+ ) : vnode;
3645
3664
  }
3646
3665
  function setTransitionHooks(vnode, hooks) {
3647
3666
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -5634,6 +5653,9 @@ function assertType(value, type) {
5634
5653
  };
5635
5654
  }
5636
5655
  function getInvalidTypeMessage(name, value, expectedTypes) {
5656
+ if (expectedTypes.length === 0) {
5657
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5658
+ }
5637
5659
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5638
5660
  const expectedType = expectedTypes[0];
5639
5661
  const receivedType = toRawType(value);
@@ -5903,6 +5925,20 @@ function createHydrationFunctions(rendererInternals) {
5903
5925
  const { type, ref, shapeFlag, patchFlag } = vnode;
5904
5926
  let domType = node.nodeType;
5905
5927
  vnode.el = node;
5928
+ {
5929
+ if (!("__vnode" in node)) {
5930
+ Object.defineProperty(node, "__vnode", {
5931
+ value: vnode,
5932
+ enumerable: false
5933
+ });
5934
+ }
5935
+ if (!("__vueParentComponent" in node)) {
5936
+ Object.defineProperty(node, "__vueParentComponent", {
5937
+ value: parentComponent,
5938
+ enumerable: false
5939
+ });
5940
+ }
5941
+ }
5906
5942
  if (patchFlag === -2) {
5907
5943
  optimized = false;
5908
5944
  vnode.dynamicChildren = null;
@@ -6064,15 +6100,16 @@ function createHydrationFunctions(rendererInternals) {
6064
6100
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6065
6101
  optimized = optimized || !!vnode.dynamicChildren;
6066
6102
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6067
- const forcePatchValue = type === "input" && dirs || type === "option";
6103
+ const forcePatch = type === "input" || type === "option";
6068
6104
  {
6069
6105
  if (dirs) {
6070
6106
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6071
6107
  }
6072
6108
  if (props) {
6073
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6109
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6074
6110
  for (const key in props) {
6075
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6111
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6112
+ key[0] === ".") {
6076
6113
  patchProp(
6077
6114
  el,
6078
6115
  key,
@@ -7829,6 +7866,7 @@ const resolveTarget = (props, select) => {
7829
7866
  }
7830
7867
  };
7831
7868
  const TeleportImpl = {
7869
+ name: "Teleport",
7832
7870
  __isTeleport: true,
7833
7871
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7834
7872
  const {
@@ -8250,7 +8288,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
8250
8288
  if (shapeFlag & 4 && isProxy(type)) {
8251
8289
  type = toRaw(type);
8252
8290
  warn(
8253
- `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\`.`,
8291
+ `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\`.`,
8254
8292
  `
8255
8293
  Component that was made reactive: `,
8256
8294
  type
@@ -8875,9 +8913,9 @@ function initCustomFormatter() {
8875
8913
  return;
8876
8914
  }
8877
8915
  const vueStyle = { style: "color:#3ba776" };
8878
- const numberStyle = { style: "color:#0b1bc9" };
8879
- const stringStyle = { style: "color:#b62e24" };
8880
- const keywordStyle = { style: "color:#9d288c" };
8916
+ const numberStyle = { style: "color:#1677ff" };
8917
+ const stringStyle = { style: "color:#f5222d" };
8918
+ const keywordStyle = { style: "color:#eb2f96" };
8881
8919
  const formatter = {
8882
8920
  header(obj) {
8883
8921
  if (!isObject(obj)) {
@@ -9071,7 +9109,7 @@ function isMemoSame(cached, memo) {
9071
9109
  return true;
9072
9110
  }
9073
9111
 
9074
- const version = "3.3.8";
9112
+ const version = "3.3.10";
9075
9113
  const ssrUtils = null;
9076
9114
  const resolveFilter = null;
9077
9115
  const compatUtils = null;
@@ -9683,7 +9721,8 @@ function patchStopImmediatePropagation(e, value) {
9683
9721
  }
9684
9722
  }
9685
9723
 
9686
- const nativeOnRE = /^on[a-z]/;
9724
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
9725
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
9687
9726
  const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
9688
9727
  if (key === "class") {
9689
9728
  patchClass(el, nextValue, isSVG);
@@ -9717,7 +9756,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
9717
9756
  if (key === "innerHTML" || key === "textContent") {
9718
9757
  return true;
9719
9758
  }
9720
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
9759
+ if (key in el && isNativeOn(key) && isFunction(value)) {
9721
9760
  return true;
9722
9761
  }
9723
9762
  return false;
@@ -9734,7 +9773,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
9734
9773
  if (key === "type" && el.tagName === "TEXTAREA") {
9735
9774
  return false;
9736
9775
  }
9737
- if (nativeOnRE.test(key) && isString(value)) {
9776
+ if (key === "width" || key === "height") {
9777
+ const tag = el.tagName;
9778
+ return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
9779
+ }
9780
+ if (isNativeOn(key) && isString(value)) {
9738
9781
  return false;
9739
9782
  }
9740
9783
  return key in el;
@@ -10216,21 +10259,20 @@ const vModelText = {
10216
10259
  el[assignKey] = getModelAssigner(vnode);
10217
10260
  if (el.composing)
10218
10261
  return;
10262
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10263
+ const newValue = value == null ? "" : value;
10264
+ if (elValue === newValue) {
10265
+ return;
10266
+ }
10219
10267
  if (document.activeElement === el && el.type !== "range") {
10220
10268
  if (lazy) {
10221
10269
  return;
10222
10270
  }
10223
- if (trim && el.value.trim() === value) {
10271
+ if (trim && el.value.trim() === newValue) {
10224
10272
  return;
10225
10273
  }
10226
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10227
- return;
10228
- }
10229
- }
10230
- const newValue = value == null ? "" : value;
10231
- if (el.value !== newValue) {
10232
- el.value = newValue;
10233
10274
  }
10275
+ el.value = newValue;
10234
10276
  }
10235
10277
  };
10236
10278
  const vModelCheckbox = {
@@ -10416,14 +10458,14 @@ const modifierGuards = {
10416
10458
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
10417
10459
  };
10418
10460
  const withModifiers = (fn, modifiers) => {
10419
- return (event, ...args) => {
10461
+ return fn._withMods || (fn._withMods = (event, ...args) => {
10420
10462
  for (let i = 0; i < modifiers.length; i++) {
10421
10463
  const guard = modifierGuards[modifiers[i]];
10422
10464
  if (guard && guard(event, modifiers))
10423
10465
  return;
10424
10466
  }
10425
10467
  return fn(event, ...args);
10426
- };
10468
+ });
10427
10469
  };
10428
10470
  const keyNames = {
10429
10471
  esc: "escape",
@@ -10435,7 +10477,7 @@ const keyNames = {
10435
10477
  delete: "backspace"
10436
10478
  };
10437
10479
  const withKeys = (fn, modifiers) => {
10438
- return (event) => {
10480
+ return fn._withKeys || (fn._withKeys = (event) => {
10439
10481
  if (!("key" in event)) {
10440
10482
  return;
10441
10483
  }
@@ -10443,7 +10485,7 @@ const withKeys = (fn, modifiers) => {
10443
10485
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
10444
10486
  return fn(event);
10445
10487
  }
10446
- };
10488
+ });
10447
10489
  };
10448
10490
 
10449
10491
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);