@vue/compat 3.5.16 → 3.5.18

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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.16
2
+ * @vue/compat v3.5.18
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -137,7 +137,7 @@ const PatchFlagNames = {
137
137
  [512]: `NEED_PATCH`,
138
138
  [1024]: `DYNAMIC_SLOTS`,
139
139
  [2048]: `DEV_ROOT_FRAGMENT`,
140
- [-1]: `HOISTED`,
140
+ [-1]: `CACHED`,
141
141
  [-2]: `BAIL`
142
142
  };
143
143
 
@@ -437,6 +437,24 @@ const stringifySymbol = (v, i = "") => {
437
437
  );
438
438
  };
439
439
 
440
+ function normalizeCssVarValue(value) {
441
+ if (value == null) {
442
+ return "initial";
443
+ }
444
+ if (typeof value === "string") {
445
+ return value === "" ? " " : value;
446
+ }
447
+ if (typeof value !== "number" || !Number.isFinite(value)) {
448
+ {
449
+ console.warn(
450
+ "[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:",
451
+ value
452
+ );
453
+ }
454
+ }
455
+ return String(value);
456
+ }
457
+
440
458
  function warn$2(msg, ...args) {
441
459
  console.warn(`[Vue warn] ${msg}`, ...args);
442
460
  }
@@ -910,6 +928,7 @@ class Link {
910
928
  }
911
929
  }
912
930
  class Dep {
931
+ // TODO isolatedDeclarations "__v_skip"
913
932
  constructor(computed) {
914
933
  this.computed = computed;
915
934
  this.version = 0;
@@ -930,6 +949,10 @@ class Dep {
930
949
  * Subscriber counter
931
950
  */
932
951
  this.sc = 0;
952
+ /**
953
+ * @internal
954
+ */
955
+ this.__v_skip = true;
933
956
  {
934
957
  this.subsHead = void 0;
935
958
  }
@@ -5030,10 +5053,8 @@ function resolveCssVars(instance, vnode, expectedMap) {
5030
5053
  if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
5031
5054
  const cssVars = instance.getCssVars();
5032
5055
  for (const key in cssVars) {
5033
- expectedMap.set(
5034
- `--${getEscapedCssVarName(key)}`,
5035
- String(cssVars[key])
5036
- );
5056
+ const value = normalizeCssVarValue(cssVars[key]);
5057
+ expectedMap.set(`--${getEscapedCssVarName(key)}`, value);
5037
5058
  }
5038
5059
  }
5039
5060
  if (vnode === root && instance.parent) {
@@ -5064,7 +5085,7 @@ function isMismatchAllowed(el, allowedType) {
5064
5085
  if (allowedType === 0 /* TEXT */ && list.includes("children")) {
5065
5086
  return true;
5066
5087
  }
5067
- return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
5088
+ return list.includes(MismatchTypeString[allowedType]);
5068
5089
  }
5069
5090
  }
5070
5091
 
@@ -5222,16 +5243,19 @@ function defineAsyncComponent(source) {
5222
5243
  __asyncLoader: load,
5223
5244
  __asyncHydrate(el, instance, hydrate) {
5224
5245
  let patched = false;
5225
- const doHydrate = hydrateStrategy ? () => {
5226
- const performHydrate = () => {
5227
- if (patched) {
5246
+ (instance.bu || (instance.bu = [])).push(() => patched = true);
5247
+ const performHydrate = () => {
5248
+ if (patched) {
5249
+ {
5228
5250
  warn$1(
5229
- `Skipping lazy hydration for component '${getComponentName(resolvedComp)}': it was updated before lazy hydration performed.`
5251
+ `Skipping lazy hydration for component '${getComponentName(resolvedComp) || resolvedComp.__file}': it was updated before lazy hydration performed.`
5230
5252
  );
5231
- return;
5232
5253
  }
5233
- hydrate();
5234
- };
5254
+ return;
5255
+ }
5256
+ hydrate();
5257
+ };
5258
+ const doHydrate = hydrateStrategy ? () => {
5235
5259
  const teardown = hydrateStrategy(
5236
5260
  performHydrate,
5237
5261
  (cb) => forEachElement(el, cb)
@@ -5239,8 +5263,7 @@ function defineAsyncComponent(source) {
5239
5263
  if (teardown) {
5240
5264
  (instance.bum || (instance.bum = [])).push(teardown);
5241
5265
  }
5242
- (instance.u || (instance.u = [])).push(() => patched = true);
5243
- } : hydrate;
5266
+ } : performHydrate;
5244
5267
  if (resolvedComp) {
5245
5268
  doHydrate();
5246
5269
  } else {
@@ -6659,15 +6682,15 @@ function withDefaults(props, defaults) {
6659
6682
  return null;
6660
6683
  }
6661
6684
  function useSlots() {
6662
- return getContext().slots;
6685
+ return getContext("useSlots").slots;
6663
6686
  }
6664
6687
  function useAttrs() {
6665
- return getContext().attrs;
6688
+ return getContext("useAttrs").attrs;
6666
6689
  }
6667
- function getContext() {
6690
+ function getContext(calledFunctionName) {
6668
6691
  const i = getCurrentInstance();
6669
6692
  if (!i) {
6670
- warn$1(`useContext() called without active instance.`);
6693
+ warn$1(`${calledFunctionName}() called without active instance.`);
6671
6694
  }
6672
6695
  return i.setupContext || (i.setupContext = createSetupContext(i));
6673
6696
  }
@@ -6926,7 +6949,8 @@ function applyOptions(instance) {
6926
6949
  expose.forEach((key) => {
6927
6950
  Object.defineProperty(exposed, key, {
6928
6951
  get: () => publicThis[key],
6929
- set: (val) => publicThis[key] = val
6952
+ set: (val) => publicThis[key] = val,
6953
+ enumerable: true
6930
6954
  });
6931
6955
  });
6932
6956
  } else if (!instance.exposed) {
@@ -7251,7 +7275,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7251
7275
  return vm;
7252
7276
  }
7253
7277
  }
7254
- Vue.version = `2.6.14-compat:${"3.5.16"}`;
7278
+ Vue.version = `2.6.14-compat:${"3.5.18"}`;
7255
7279
  Vue.config = singletonApp.config;
7256
7280
  Vue.use = (plugin, ...options) => {
7257
7281
  if (plugin && isFunction(plugin.install)) {
@@ -7843,7 +7867,7 @@ function provide(key, value) {
7843
7867
  }
7844
7868
  }
7845
7869
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
7846
- const instance = currentInstance || currentRenderingInstance;
7870
+ const instance = getCurrentInstance();
7847
7871
  if (instance || currentApp) {
7848
7872
  let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
7849
7873
  if (provides && key in provides) {
@@ -7858,7 +7882,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
7858
7882
  }
7859
7883
  }
7860
7884
  function hasInjectionContext() {
7861
- return !!(currentInstance || currentRenderingInstance || currentApp);
7885
+ return !!(getCurrentInstance() || currentApp);
7862
7886
  }
7863
7887
 
7864
7888
  function createPropsDefaultThis(instance, rawProps, propKey) {
@@ -8344,7 +8368,7 @@ function isBoolean(...args) {
8344
8368
  return args.some((elem) => elem.toLowerCase() === "boolean");
8345
8369
  }
8346
8370
 
8347
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
8371
+ const isInternalKey = (key) => key === "_" || key === "__" || key === "_ctx" || key === "$stable";
8348
8372
  const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
8349
8373
  const normalizeSlot = (key, rawSlot, ctx) => {
8350
8374
  if (rawSlot._n) {
@@ -8398,6 +8422,8 @@ const assignSlots = (slots, children, optimized) => {
8398
8422
  const initSlots = (instance, children, optimized) => {
8399
8423
  const slots = instance.slots = createInternalObject();
8400
8424
  if (instance.vnode.shapeFlag & 32) {
8425
+ const cacheIndexes = children.__;
8426
+ if (cacheIndexes) def(slots, "__", cacheIndexes, true);
8401
8427
  const type = children._;
8402
8428
  if (type) {
8403
8429
  assignSlots(slots, children, optimized);
@@ -8609,6 +8635,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8609
8635
  }
8610
8636
  if (ref != null && parentComponent) {
8611
8637
  setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
8638
+ } else if (ref == null && n1 && n1.ref != null) {
8639
+ setRef(n1.ref, null, parentSuspense, n1, true);
8612
8640
  }
8613
8641
  };
8614
8642
  const processText = (n1, n2, container, anchor) => {
@@ -9083,6 +9111,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9083
9111
  if (!initialVNode.el) {
9084
9112
  const placeholder = instance.subTree = createVNode(Comment);
9085
9113
  processCommentNode(null, placeholder, container, anchor);
9114
+ initialVNode.placeholder = placeholder.el;
9086
9115
  }
9087
9116
  } else {
9088
9117
  setupRenderEffect(
@@ -9172,7 +9201,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9172
9201
  hydrateSubTree();
9173
9202
  }
9174
9203
  } else {
9175
- if (root.ce) {
9204
+ if (root.ce && // @ts-expect-error _def is private
9205
+ root.ce._def.shadowRoot !== false) {
9176
9206
  root.ce._injectChildStyle(type);
9177
9207
  }
9178
9208
  {
@@ -9607,7 +9637,11 @@ function baseCreateRenderer(options, createHydrationFns) {
9607
9637
  for (i = toBePatched - 1; i >= 0; i--) {
9608
9638
  const nextIndex = s2 + i;
9609
9639
  const nextChild = c2[nextIndex];
9610
- const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
9640
+ const anchorVNode = c2[nextIndex + 1];
9641
+ const anchor = nextIndex + 1 < l2 ? (
9642
+ // #13559, fallback to el placeholder for unresolved async component
9643
+ anchorVNode.el || anchorVNode.placeholder
9644
+ ) : parentAnchor;
9611
9645
  if (newIndexToOldIndexMap[i] === 0) {
9612
9646
  patch(
9613
9647
  null,
@@ -10268,8 +10302,9 @@ function emit(instance, event, ...rawArgs) {
10268
10302
  }
10269
10303
  }
10270
10304
  let args = rawArgs;
10271
- const isModelListener = event.startsWith("update:");
10272
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
10305
+ const isCompatModelListener = compatModelEventPrefix + event in props;
10306
+ const isModelListener = isCompatModelListener || event.startsWith("update:");
10307
+ const modifiers = isCompatModelListener ? props.modelModifiers : isModelListener && getModelModifiers(props, event.slice(7));
10273
10308
  if (modifiers) {
10274
10309
  if (modifiers.trim) {
10275
10310
  args = rawArgs.map((a) => isString(a) ? a.trim() : a);
@@ -11601,6 +11636,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
11601
11636
  suspense: vnode.suspense,
11602
11637
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
11603
11638
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
11639
+ placeholder: vnode.placeholder,
11604
11640
  el: vnode.el,
11605
11641
  anchor: vnode.anchor,
11606
11642
  ctx: vnode.ctx,
@@ -12407,7 +12443,7 @@ function isMemoSame(cached, memo) {
12407
12443
  return true;
12408
12444
  }
12409
12445
 
12410
- const version = "3.5.16";
12446
+ const version = "3.5.18";
12411
12447
  const warn = warn$1 ;
12412
12448
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12413
12449
  const devtools = devtools$1 ;
@@ -13431,9 +13467,10 @@ class VueElement extends BaseClass {
13431
13467
  };
13432
13468
  const asyncDef = this._def.__asyncLoader;
13433
13469
  if (asyncDef) {
13434
- this._pendingResolve = asyncDef().then(
13435
- (def) => resolve(this._def = def, true)
13436
- );
13470
+ this._pendingResolve = asyncDef().then((def) => {
13471
+ def.configureApp = this._def.configureApp;
13472
+ resolve(this._def = def, true);
13473
+ });
13437
13474
  } else {
13438
13475
  resolve(this._def);
13439
13476
  }
@@ -15474,7 +15511,7 @@ class Tokenizer {
15474
15511
  this.buffer = input;
15475
15512
  while (this.index < this.buffer.length) {
15476
15513
  const c = this.buffer.charCodeAt(this.index);
15477
- if (c === 10) {
15514
+ if (c === 10 && this.state !== 33) {
15478
15515
  this.newlines.push(this.index);
15479
15516
  }
15480
15517
  switch (this.state) {
@@ -15897,14 +15934,15 @@ function isReferencedIdentifier(id, parent, parentStack) {
15897
15934
  if (id.name === "arguments") {
15898
15935
  return false;
15899
15936
  }
15900
- if (isReferenced(id, parent)) {
15937
+ if (isReferenced(id, parent, parentStack[parentStack.length - 2])) {
15901
15938
  return true;
15902
15939
  }
15903
15940
  switch (parent.type) {
15904
15941
  case "AssignmentExpression":
15905
15942
  case "AssignmentPattern":
15906
15943
  return true;
15907
- case "ObjectPattern":
15944
+ case "ObjectProperty":
15945
+ return parent.key !== id && isInDestructureAssignment(parent, parentStack);
15908
15946
  case "ArrayPattern":
15909
15947
  return isInDestructureAssignment(parent, parentStack);
15910
15948
  }
@@ -16073,7 +16111,7 @@ function isReferenced(node, parent, grandparent) {
16073
16111
  if (parent.key === node) {
16074
16112
  return !!parent.computed;
16075
16113
  }
16076
- return true;
16114
+ return !grandparent || grandparent.type !== "ObjectPattern";
16077
16115
  // no: class { NODE = value; }
16078
16116
  // yes: class { [NODE] = value; }
16079
16117
  // yes: class { key = NODE; }
@@ -16123,6 +16161,9 @@ function isReferenced(node, parent, grandparent) {
16123
16161
  // yes: export { NODE as foo };
16124
16162
  // no: export { NODE as foo } from "foo";
16125
16163
  case "ExportSpecifier":
16164
+ if (grandparent == null ? void 0 : grandparent.source) {
16165
+ return false;
16166
+ }
16126
16167
  return parent.local === node;
16127
16168
  // no: import NODE from "foo";
16128
16169
  // no: import * as NODE from "foo";
@@ -16203,7 +16244,7 @@ function isCoreComponent(tag) {
16203
16244
  return BASE_TRANSITION;
16204
16245
  }
16205
16246
  }
16206
- const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
16247
+ const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
16207
16248
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
16208
16249
  const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
16209
16250
  const isMemberExpressionNode = (exp, context) => {
@@ -16301,6 +16342,9 @@ function hasDynamicKeyVBind(node) {
16301
16342
  function isText$1(node) {
16302
16343
  return node.type === 5 || node.type === 2;
16303
16344
  }
16345
+ function isVPre(p) {
16346
+ return p.type === 7 && p.name === "pre";
16347
+ }
16304
16348
  function isVSlot(p) {
16305
16349
  return p.type === 7 && p.name === "slot";
16306
16350
  }
@@ -16599,7 +16643,7 @@ const tokenizer = new Tokenizer(stack, {
16599
16643
  ondirarg(start, end) {
16600
16644
  if (start === end) return;
16601
16645
  const arg = getSlice(start, end);
16602
- if (inVPre) {
16646
+ if (inVPre && !isVPre(currentProp)) {
16603
16647
  currentProp.name += arg;
16604
16648
  setLocEnd(currentProp.nameLoc, end);
16605
16649
  } else {
@@ -16614,7 +16658,7 @@ const tokenizer = new Tokenizer(stack, {
16614
16658
  },
16615
16659
  ondirmodifier(start, end) {
16616
16660
  const mod = getSlice(start, end);
16617
- if (inVPre) {
16661
+ if (inVPre && !isVPre(currentProp)) {
16618
16662
  currentProp.name += "." + mod;
16619
16663
  setLocEnd(currentProp.nameLoc, end);
16620
16664
  } else if (currentProp.name === "slot") {
@@ -17037,7 +17081,7 @@ function isUpperCase(c) {
17037
17081
  return c > 64 && c < 91;
17038
17082
  }
17039
17083
  const windowsNewlineRE = /\r\n/g;
17040
- function condenseWhitespace(nodes, tag) {
17084
+ function condenseWhitespace(nodes) {
17041
17085
  const shouldCondense = currentOptions.whitespace !== "preserve";
17042
17086
  let removedWhitespace = false;
17043
17087
  for (let i = 0; i < nodes.length; i++) {
@@ -17223,12 +17267,12 @@ function cacheStatic(root, context) {
17223
17267
  context,
17224
17268
  // Root node is unfortunately non-hoistable due to potential parent
17225
17269
  // fallthrough attributes.
17226
- isSingleElementRoot(root, root.children[0])
17270
+ !!getSingleElementRoot(root)
17227
17271
  );
17228
17272
  }
17229
- function isSingleElementRoot(root, child) {
17230
- const { children } = root;
17231
- return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
17273
+ function getSingleElementRoot(root) {
17274
+ const children = root.children.filter((x) => x.type !== 3);
17275
+ return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
17232
17276
  }
17233
17277
  function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
17234
17278
  const { children } = node;
@@ -17261,6 +17305,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
17261
17305
  } else if (child.type === 12) {
17262
17306
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
17263
17307
  if (constantType >= 2) {
17308
+ if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
17309
+ child.codegenNode.arguments.push(
17310
+ -1 + (` /* ${PatchFlagNames[-1]} */` )
17311
+ );
17312
+ }
17264
17313
  toCache.push(child);
17265
17314
  continue;
17266
17315
  }
@@ -17722,15 +17771,15 @@ function createRootCodegen(root, context) {
17722
17771
  const { helper } = context;
17723
17772
  const { children } = root;
17724
17773
  if (children.length === 1) {
17725
- const child = children[0];
17726
- if (isSingleElementRoot(root, child) && child.codegenNode) {
17727
- const codegenNode = child.codegenNode;
17774
+ const singleElementRootChild = getSingleElementRoot(root);
17775
+ if (singleElementRootChild && singleElementRootChild.codegenNode) {
17776
+ const codegenNode = singleElementRootChild.codegenNode;
17728
17777
  if (codegenNode.type === 13) {
17729
17778
  convertToBlock(codegenNode, context);
17730
17779
  }
17731
17780
  root.codegenNode = codegenNode;
17732
17781
  } else {
17733
- root.codegenNode = child;
17782
+ root.codegenNode = children[0];
17734
17783
  }
17735
17784
  } else if (children.length > 1) {
17736
17785
  let patchFlag = 64;
@@ -19101,7 +19150,7 @@ const transformBind = (dir, _node, context) => {
19101
19150
  arg.children.unshift(`(`);
19102
19151
  arg.children.push(`) || ""`);
19103
19152
  } else if (!arg.isStatic) {
19104
- arg.content = `${arg.content} || ""`;
19153
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
19105
19154
  }
19106
19155
  if (modifiers.some((mod) => mod.content === "camel")) {
19107
19156
  if (arg.type === 4) {
@@ -19514,7 +19563,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
19514
19563
  let prev;
19515
19564
  while (j--) {
19516
19565
  prev = children[j];
19517
- if (prev.type !== 3) {
19566
+ if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
19518
19567
  break;
19519
19568
  }
19520
19569
  }