@vue/compat 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) => {
@@ -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() {
@@ -2729,9 +2729,19 @@ function renderComponentRoot(instance) {
2729
2729
  try {
2730
2730
  if (vnode.shapeFlag & 4) {
2731
2731
  const proxyToUse = withProxy || proxy;
2732
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2733
+ get(target, key, receiver) {
2734
+ warn(
2735
+ `Property '${String(
2736
+ key
2737
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2738
+ );
2739
+ return Reflect.get(target, key, receiver);
2740
+ }
2741
+ }) : proxyToUse;
2732
2742
  result = normalizeVNode(
2733
2743
  render.call(
2734
- proxyToUse,
2744
+ thisProxy,
2735
2745
  proxyToUse,
2736
2746
  renderCache,
2737
2747
  props,
@@ -3362,7 +3372,12 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3362
3372
  if (delayEnter) {
3363
3373
  activeBranch.transition.afterLeave = () => {
3364
3374
  if (pendingId === suspense.pendingId) {
3365
- move(pendingBranch, container2, anchor2, 0);
3375
+ move(
3376
+ pendingBranch,
3377
+ container2,
3378
+ next(activeBranch),
3379
+ 0
3380
+ );
3366
3381
  queuePostFlushCb(effects);
3367
3382
  }
3368
3383
  };
@@ -3409,7 +3424,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3409
3424
  }
3410
3425
  const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
3411
3426
  triggerEvent(vnode2, "onFallback");
3412
- const anchor2 = next(activeBranch);
3413
3427
  const mountFallback = () => {
3414
3428
  if (!suspense.isInFallback) {
3415
3429
  return;
@@ -3418,7 +3432,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3418
3432
  null,
3419
3433
  fallbackVNode,
3420
3434
  container2,
3421
- anchor2,
3435
+ next(activeBranch),
3422
3436
  parentComponent2,
3423
3437
  null,
3424
3438
  // fallback tree will not have suspense context
@@ -3761,6 +3775,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3761
3775
  let onCleanup = (fn) => {
3762
3776
  cleanup = effect.onStop = () => {
3763
3777
  callWithErrorHandling(fn, instance, 4);
3778
+ cleanup = effect.onStop = void 0;
3764
3779
  };
3765
3780
  };
3766
3781
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4237,7 +4252,11 @@ function emptyPlaceholder(vnode) {
4237
4252
  }
4238
4253
  }
4239
4254
  function getKeepAliveChild(vnode) {
4240
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
4255
+ return isKeepAlive(vnode) ? (
4256
+ // #7121 ensure get the child component subtree in case
4257
+ // it's been replaced during HMR
4258
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
4259
+ ) : vnode;
4241
4260
  }
4242
4261
  function setTransitionHooks(vnode, hooks) {
4243
4262
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -6254,7 +6273,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6254
6273
  return vm;
6255
6274
  }
6256
6275
  }
6257
- Vue.version = `2.6.14-compat:${"3.3.8"}`;
6276
+ Vue.version = `2.6.14-compat:${"3.3.10"}`;
6258
6277
  Vue.config = singletonApp.config;
6259
6278
  Vue.use = (p, ...options) => {
6260
6279
  if (p && isFunction(p.install)) {
@@ -7282,6 +7301,9 @@ function assertType(value, type) {
7282
7301
  };
7283
7302
  }
7284
7303
  function getInvalidTypeMessage(name, value, expectedTypes) {
7304
+ if (expectedTypes.length === 0) {
7305
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
7306
+ }
7285
7307
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7286
7308
  const expectedType = expectedTypes[0];
7287
7309
  const receivedType = toRawType(value);
@@ -7553,6 +7575,20 @@ function createHydrationFunctions(rendererInternals) {
7553
7575
  const { type, ref, shapeFlag, patchFlag } = vnode;
7554
7576
  let domType = node.nodeType;
7555
7577
  vnode.el = node;
7578
+ {
7579
+ if (!("__vnode" in node)) {
7580
+ Object.defineProperty(node, "__vnode", {
7581
+ value: vnode,
7582
+ enumerable: false
7583
+ });
7584
+ }
7585
+ if (!("__vueParentComponent" in node)) {
7586
+ Object.defineProperty(node, "__vueParentComponent", {
7587
+ value: parentComponent,
7588
+ enumerable: false
7589
+ });
7590
+ }
7591
+ }
7556
7592
  if (patchFlag === -2) {
7557
7593
  optimized = false;
7558
7594
  vnode.dynamicChildren = null;
@@ -7714,15 +7750,16 @@ function createHydrationFunctions(rendererInternals) {
7714
7750
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7715
7751
  optimized = optimized || !!vnode.dynamicChildren;
7716
7752
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7717
- const forcePatchValue = type === "input" && dirs || type === "option";
7753
+ const forcePatch = type === "input" || type === "option";
7718
7754
  {
7719
7755
  if (dirs) {
7720
7756
  invokeDirectiveHook(vnode, null, parentComponent, "created");
7721
7757
  }
7722
7758
  if (props) {
7723
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
7759
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
7724
7760
  for (const key in props) {
7725
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
7761
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
7762
+ key[0] === ".") {
7726
7763
  patchProp(
7727
7764
  el,
7728
7765
  key,
@@ -9513,6 +9550,7 @@ const resolveTarget = (props, select) => {
9513
9550
  }
9514
9551
  };
9515
9552
  const TeleportImpl = {
9553
+ name: "Teleport",
9516
9554
  __isTeleport: true,
9517
9555
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
9518
9556
  const {
@@ -9992,7 +10030,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
9992
10030
  if (shapeFlag & 4 && isProxy(type)) {
9993
10031
  type = toRaw(type);
9994
10032
  warn(
9995
- `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\`.`,
10033
+ `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\`.`,
9996
10034
  `
9997
10035
  Component that was made reactive: `,
9998
10036
  type
@@ -10632,9 +10670,9 @@ function initCustomFormatter() {
10632
10670
  return;
10633
10671
  }
10634
10672
  const vueStyle = { style: "color:#3ba776" };
10635
- const numberStyle = { style: "color:#0b1bc9" };
10636
- const stringStyle = { style: "color:#b62e24" };
10637
- const keywordStyle = { style: "color:#9d288c" };
10673
+ const numberStyle = { style: "color:#1677ff" };
10674
+ const stringStyle = { style: "color:#f5222d" };
10675
+ const keywordStyle = { style: "color:#eb2f96" };
10638
10676
  const formatter = {
10639
10677
  header(obj) {
10640
10678
  if (!isObject(obj)) {
@@ -10828,7 +10866,7 @@ function isMemoSame(cached, memo) {
10828
10866
  return true;
10829
10867
  }
10830
10868
 
10831
- const version = "3.3.8";
10869
+ const version = "3.3.10";
10832
10870
  const ssrUtils = null;
10833
10871
  const resolveFilter = resolveFilter$1 ;
10834
10872
  const _compatUtils = {
@@ -11527,7 +11565,8 @@ function patchStopImmediatePropagation(e, value) {
11527
11565
  }
11528
11566
  }
11529
11567
 
11530
- const nativeOnRE = /^on[a-z]/;
11568
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
11569
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
11531
11570
  const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
11532
11571
  if (key === "class") {
11533
11572
  patchClass(el, nextValue, isSVG);
@@ -11561,7 +11600,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
11561
11600
  if (key === "innerHTML" || key === "textContent") {
11562
11601
  return true;
11563
11602
  }
11564
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
11603
+ if (key in el && isNativeOn(key) && isFunction(value)) {
11565
11604
  return true;
11566
11605
  }
11567
11606
  return false;
@@ -11578,7 +11617,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
11578
11617
  if (key === "type" && el.tagName === "TEXTAREA") {
11579
11618
  return false;
11580
11619
  }
11581
- if (nativeOnRE.test(key) && isString(value)) {
11620
+ if (key === "width" || key === "height") {
11621
+ const tag = el.tagName;
11622
+ return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
11623
+ }
11624
+ if (isNativeOn(key) && isString(value)) {
11582
11625
  return false;
11583
11626
  }
11584
11627
  return key in el;
@@ -12069,21 +12112,20 @@ const vModelText = {
12069
12112
  el[assignKey] = getModelAssigner(vnode);
12070
12113
  if (el.composing)
12071
12114
  return;
12115
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
12116
+ const newValue = value == null ? "" : value;
12117
+ if (elValue === newValue) {
12118
+ return;
12119
+ }
12072
12120
  if (document.activeElement === el && el.type !== "range") {
12073
12121
  if (lazy) {
12074
12122
  return;
12075
12123
  }
12076
- if (trim && el.value.trim() === value) {
12077
- return;
12078
- }
12079
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
12124
+ if (trim && el.value.trim() === newValue) {
12080
12125
  return;
12081
12126
  }
12082
12127
  }
12083
- const newValue = value == null ? "" : value;
12084
- if (el.value !== newValue) {
12085
- el.value = newValue;
12086
- }
12128
+ el.value = newValue;
12087
12129
  }
12088
12130
  };
12089
12131
  const vModelCheckbox = {
@@ -12269,14 +12311,14 @@ const modifierGuards = {
12269
12311
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
12270
12312
  };
12271
12313
  const withModifiers = (fn, modifiers) => {
12272
- return (event, ...args) => {
12314
+ return fn._withMods || (fn._withMods = (event, ...args) => {
12273
12315
  for (let i = 0; i < modifiers.length; i++) {
12274
12316
  const guard = modifierGuards[modifiers[i]];
12275
12317
  if (guard && guard(event, modifiers))
12276
12318
  return;
12277
12319
  }
12278
12320
  return fn(event, ...args);
12279
- };
12321
+ });
12280
12322
  };
12281
12323
  const keyNames = {
12282
12324
  esc: "escape",
@@ -12304,7 +12346,7 @@ const withKeys = (fn, modifiers) => {
12304
12346
  );
12305
12347
  }
12306
12348
  }
12307
- return (event) => {
12349
+ return fn._withKeys || (fn._withKeys = (event) => {
12308
12350
  if (!("key" in event)) {
12309
12351
  return;
12310
12352
  }
@@ -12332,7 +12374,7 @@ const withKeys = (fn, modifiers) => {
12332
12374
  }
12333
12375
  }
12334
12376
  }
12335
- };
12377
+ });
12336
12378
  };
12337
12379
 
12338
12380
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
@@ -13216,6 +13258,7 @@ function getMemoedVNodeCall(node) {
13216
13258
  return node;
13217
13259
  }
13218
13260
  }
13261
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13219
13262
 
13220
13263
  const deprecationData = {
13221
13264
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -15613,7 +15656,6 @@ function processFor(node, dir, context, processCodegen) {
15613
15656
  onExit();
15614
15657
  };
15615
15658
  }
15616
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
15617
15659
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
15618
15660
  const stripParensRE = /^\(|\)$/g;
15619
15661
  function parseForExpression(input, context) {
@@ -16155,6 +16197,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16155
16197
  if (isEventHandler && isReservedProp(name)) {
16156
16198
  hasVnodeHook = true;
16157
16199
  }
16200
+ if (isEventHandler && value.type === 14) {
16201
+ value = value.arguments[0];
16202
+ }
16158
16203
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
16159
16204
  return;
16160
16205
  }
@@ -16211,7 +16256,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16211
16256
  )
16212
16257
  );
16213
16258
  } else {
16214
- const { name, arg, exp, loc } = prop;
16259
+ const { name, arg, exp, loc, modifiers } = prop;
16215
16260
  const isVBind = name === "bind";
16216
16261
  const isVOn = name === "on";
16217
16262
  if (name === "slot") {
@@ -16304,6 +16349,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
16304
16349
  }
16305
16350
  continue;
16306
16351
  }
16352
+ if (isVBind && modifiers.includes("prop")) {
16353
+ patchFlag |= 32;
16354
+ }
16307
16355
  const directiveTransform = context.directiveTransforms[name];
16308
16356
  if (directiveTransform) {
16309
16357
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -17336,8 +17384,8 @@ const transformModel = (dir, node, context) => {
17336
17384
  );
17337
17385
  }
17338
17386
  function checkDuplicatedValue() {
17339
- const value = findProp(node, "value");
17340
- if (value) {
17387
+ const value = findDir(node, "bind");
17388
+ if (value && isStaticArgOf(value.arg, "value")) {
17341
17389
  context.onError(
17342
17390
  createDOMCompilerError(
17343
17391
  60,