@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.
@@ -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
  **/
@@ -126,7 +126,7 @@ const PatchFlagNames = {
126
126
  [512]: `NEED_PATCH`,
127
127
  [1024]: `DYNAMIC_SLOTS`,
128
128
  [2048]: `DEV_ROOT_FRAGMENT`,
129
- [-1]: `HOISTED`,
129
+ [-1]: `CACHED`,
130
130
  [-2]: `BAIL`
131
131
  };
132
132
 
@@ -384,6 +384,24 @@ const stringifySymbol = (v, i = "") => {
384
384
  );
385
385
  };
386
386
 
387
+ function normalizeCssVarValue(value) {
388
+ if (value == null) {
389
+ return "initial";
390
+ }
391
+ if (typeof value === "string") {
392
+ return value === "" ? " " : value;
393
+ }
394
+ if (typeof value !== "number" || !Number.isFinite(value)) {
395
+ {
396
+ console.warn(
397
+ "[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:",
398
+ value
399
+ );
400
+ }
401
+ }
402
+ return String(value);
403
+ }
404
+
387
405
  function warn$2(msg, ...args) {
388
406
  console.warn(`[Vue warn] ${msg}`, ...args);
389
407
  }
@@ -857,6 +875,7 @@ class Link {
857
875
  }
858
876
  }
859
877
  class Dep {
878
+ // TODO isolatedDeclarations "__v_skip"
860
879
  constructor(computed) {
861
880
  this.computed = computed;
862
881
  this.version = 0;
@@ -877,6 +896,10 @@ class Dep {
877
896
  * Subscriber counter
878
897
  */
879
898
  this.sc = 0;
899
+ /**
900
+ * @internal
901
+ */
902
+ this.__v_skip = true;
880
903
  {
881
904
  this.subsHead = void 0;
882
905
  }
@@ -4977,10 +5000,8 @@ function resolveCssVars(instance, vnode, expectedMap) {
4977
5000
  if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
4978
5001
  const cssVars = instance.getCssVars();
4979
5002
  for (const key in cssVars) {
4980
- expectedMap.set(
4981
- `--${getEscapedCssVarName(key)}`,
4982
- String(cssVars[key])
4983
- );
5003
+ const value = normalizeCssVarValue(cssVars[key]);
5004
+ expectedMap.set(`--${getEscapedCssVarName(key)}`, value);
4984
5005
  }
4985
5006
  }
4986
5007
  if (vnode === root && instance.parent) {
@@ -5011,7 +5032,7 @@ function isMismatchAllowed(el, allowedType) {
5011
5032
  if (allowedType === 0 /* TEXT */ && list.includes("children")) {
5012
5033
  return true;
5013
5034
  }
5014
- return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
5035
+ return list.includes(MismatchTypeString[allowedType]);
5015
5036
  }
5016
5037
  }
5017
5038
 
@@ -5169,16 +5190,19 @@ function defineAsyncComponent(source) {
5169
5190
  __asyncLoader: load,
5170
5191
  __asyncHydrate(el, instance, hydrate) {
5171
5192
  let patched = false;
5172
- const doHydrate = hydrateStrategy ? () => {
5173
- const performHydrate = () => {
5174
- if (patched) {
5193
+ (instance.bu || (instance.bu = [])).push(() => patched = true);
5194
+ const performHydrate = () => {
5195
+ if (patched) {
5196
+ {
5175
5197
  warn$1(
5176
- `Skipping lazy hydration for component '${getComponentName(resolvedComp)}': it was updated before lazy hydration performed.`
5198
+ `Skipping lazy hydration for component '${getComponentName(resolvedComp) || resolvedComp.__file}': it was updated before lazy hydration performed.`
5177
5199
  );
5178
- return;
5179
5200
  }
5180
- hydrate();
5181
- };
5201
+ return;
5202
+ }
5203
+ hydrate();
5204
+ };
5205
+ const doHydrate = hydrateStrategy ? () => {
5182
5206
  const teardown = hydrateStrategy(
5183
5207
  performHydrate,
5184
5208
  (cb) => forEachElement(el, cb)
@@ -5186,8 +5210,7 @@ function defineAsyncComponent(source) {
5186
5210
  if (teardown) {
5187
5211
  (instance.bum || (instance.bum = [])).push(teardown);
5188
5212
  }
5189
- (instance.u || (instance.u = [])).push(() => patched = true);
5190
- } : hydrate;
5213
+ } : performHydrate;
5191
5214
  if (resolvedComp) {
5192
5215
  doHydrate();
5193
5216
  } else {
@@ -6609,15 +6632,15 @@ function withDefaults(props, defaults) {
6609
6632
  return null;
6610
6633
  }
6611
6634
  function useSlots() {
6612
- return getContext().slots;
6635
+ return getContext("useSlots").slots;
6613
6636
  }
6614
6637
  function useAttrs() {
6615
- return getContext().attrs;
6638
+ return getContext("useAttrs").attrs;
6616
6639
  }
6617
- function getContext() {
6640
+ function getContext(calledFunctionName) {
6618
6641
  const i = getCurrentInstance();
6619
6642
  if (!i) {
6620
- warn$1(`useContext() called without active instance.`);
6643
+ warn$1(`${calledFunctionName}() called without active instance.`);
6621
6644
  }
6622
6645
  return i.setupContext || (i.setupContext = createSetupContext(i));
6623
6646
  }
@@ -6876,7 +6899,8 @@ function applyOptions(instance) {
6876
6899
  expose.forEach((key) => {
6877
6900
  Object.defineProperty(exposed, key, {
6878
6901
  get: () => publicThis[key],
6879
- set: (val) => publicThis[key] = val
6902
+ set: (val) => publicThis[key] = val,
6903
+ enumerable: true
6880
6904
  });
6881
6905
  });
6882
6906
  } else if (!instance.exposed) {
@@ -7201,7 +7225,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7201
7225
  return vm;
7202
7226
  }
7203
7227
  }
7204
- Vue.version = `2.6.14-compat:${"3.5.16"}`;
7228
+ Vue.version = `2.6.14-compat:${"3.5.18"}`;
7205
7229
  Vue.config = singletonApp.config;
7206
7230
  Vue.use = (plugin, ...options) => {
7207
7231
  if (plugin && isFunction(plugin.install)) {
@@ -7793,7 +7817,7 @@ function provide(key, value) {
7793
7817
  }
7794
7818
  }
7795
7819
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
7796
- const instance = currentInstance || currentRenderingInstance;
7820
+ const instance = getCurrentInstance();
7797
7821
  if (instance || currentApp) {
7798
7822
  let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
7799
7823
  if (provides && key in provides) {
@@ -7808,7 +7832,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
7808
7832
  }
7809
7833
  }
7810
7834
  function hasInjectionContext() {
7811
- return !!(currentInstance || currentRenderingInstance || currentApp);
7835
+ return !!(getCurrentInstance() || currentApp);
7812
7836
  }
7813
7837
 
7814
7838
  function createPropsDefaultThis(instance, rawProps, propKey) {
@@ -8294,7 +8318,7 @@ function isBoolean(...args) {
8294
8318
  return args.some((elem) => elem.toLowerCase() === "boolean");
8295
8319
  }
8296
8320
 
8297
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
8321
+ const isInternalKey = (key) => key === "_" || key === "__" || key === "_ctx" || key === "$stable";
8298
8322
  const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
8299
8323
  const normalizeSlot = (key, rawSlot, ctx) => {
8300
8324
  if (rawSlot._n) {
@@ -8348,6 +8372,8 @@ const assignSlots = (slots, children, optimized) => {
8348
8372
  const initSlots = (instance, children, optimized) => {
8349
8373
  const slots = instance.slots = createInternalObject();
8350
8374
  if (instance.vnode.shapeFlag & 32) {
8375
+ const cacheIndexes = children.__;
8376
+ if (cacheIndexes) def(slots, "__", cacheIndexes, true);
8351
8377
  const type = children._;
8352
8378
  if (type) {
8353
8379
  assignSlots(slots, children, optimized);
@@ -8559,6 +8585,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8559
8585
  }
8560
8586
  if (ref != null && parentComponent) {
8561
8587
  setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
8588
+ } else if (ref == null && n1 && n1.ref != null) {
8589
+ setRef(n1.ref, null, parentSuspense, n1, true);
8562
8590
  }
8563
8591
  };
8564
8592
  const processText = (n1, n2, container, anchor) => {
@@ -9033,6 +9061,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9033
9061
  if (!initialVNode.el) {
9034
9062
  const placeholder = instance.subTree = createVNode(Comment);
9035
9063
  processCommentNode(null, placeholder, container, anchor);
9064
+ initialVNode.placeholder = placeholder.el;
9036
9065
  }
9037
9066
  } else {
9038
9067
  setupRenderEffect(
@@ -9122,7 +9151,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9122
9151
  hydrateSubTree();
9123
9152
  }
9124
9153
  } else {
9125
- if (root.ce) {
9154
+ if (root.ce && // @ts-expect-error _def is private
9155
+ root.ce._def.shadowRoot !== false) {
9126
9156
  root.ce._injectChildStyle(type);
9127
9157
  }
9128
9158
  {
@@ -9557,7 +9587,11 @@ function baseCreateRenderer(options, createHydrationFns) {
9557
9587
  for (i = toBePatched - 1; i >= 0; i--) {
9558
9588
  const nextIndex = s2 + i;
9559
9589
  const nextChild = c2[nextIndex];
9560
- const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
9590
+ const anchorVNode = c2[nextIndex + 1];
9591
+ const anchor = nextIndex + 1 < l2 ? (
9592
+ // #13559, fallback to el placeholder for unresolved async component
9593
+ anchorVNode.el || anchorVNode.placeholder
9594
+ ) : parentAnchor;
9561
9595
  if (newIndexToOldIndexMap[i] === 0) {
9562
9596
  patch(
9563
9597
  null,
@@ -10218,8 +10252,9 @@ function emit(instance, event, ...rawArgs) {
10218
10252
  }
10219
10253
  }
10220
10254
  let args = rawArgs;
10221
- const isModelListener = event.startsWith("update:");
10222
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
10255
+ const isCompatModelListener = compatModelEventPrefix + event in props;
10256
+ const isModelListener = isCompatModelListener || event.startsWith("update:");
10257
+ const modifiers = isCompatModelListener ? props.modelModifiers : isModelListener && getModelModifiers(props, event.slice(7));
10223
10258
  if (modifiers) {
10224
10259
  if (modifiers.trim) {
10225
10260
  args = rawArgs.map((a) => isString(a) ? a.trim() : a);
@@ -11551,6 +11586,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
11551
11586
  suspense: vnode.suspense,
11552
11587
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
11553
11588
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
11589
+ placeholder: vnode.placeholder,
11554
11590
  el: vnode.el,
11555
11591
  anchor: vnode.anchor,
11556
11592
  ctx: vnode.ctx,
@@ -12357,7 +12393,7 @@ function isMemoSame(cached, memo) {
12357
12393
  return true;
12358
12394
  }
12359
12395
 
12360
- const version = "3.5.16";
12396
+ const version = "3.5.18";
12361
12397
  const warn = warn$1 ;
12362
12398
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12363
12399
  const devtools = devtools$1 ;
@@ -12914,8 +12950,9 @@ function setVarsOnNode(el, vars) {
12914
12950
  const style = el.style;
12915
12951
  let cssText = "";
12916
12952
  for (const key in vars) {
12917
- style.setProperty(`--${key}`, vars[key]);
12918
- cssText += `--${key}: ${vars[key]};`;
12953
+ const value = normalizeCssVarValue(vars[key]);
12954
+ style.setProperty(`--${key}`, value);
12955
+ cssText += `--${key}: ${value};`;
12919
12956
  }
12920
12957
  style[CSS_VAR_TEXT] = cssText;
12921
12958
  }
@@ -13448,9 +13485,10 @@ class VueElement extends BaseClass {
13448
13485
  };
13449
13486
  const asyncDef = this._def.__asyncLoader;
13450
13487
  if (asyncDef) {
13451
- this._pendingResolve = asyncDef().then(
13452
- (def) => resolve(this._def = def, true)
13453
- );
13488
+ this._pendingResolve = asyncDef().then((def) => {
13489
+ def.configureApp = this._def.configureApp;
13490
+ resolve(this._def = def, true);
13491
+ });
13454
13492
  } else {
13455
13493
  resolve(this._def);
13456
13494
  }
@@ -15473,7 +15511,7 @@ class Tokenizer {
15473
15511
  this.buffer = input;
15474
15512
  while (this.index < this.buffer.length) {
15475
15513
  const c = this.buffer.charCodeAt(this.index);
15476
- if (c === 10) {
15514
+ if (c === 10 && this.state !== 33) {
15477
15515
  this.newlines.push(this.index);
15478
15516
  }
15479
15517
  switch (this.state) {
@@ -15817,7 +15855,7 @@ function isCoreComponent(tag) {
15817
15855
  return BASE_TRANSITION;
15818
15856
  }
15819
15857
  }
15820
- const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
15858
+ const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
15821
15859
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
15822
15860
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
15823
15861
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
@@ -15929,6 +15967,9 @@ function hasDynamicKeyVBind(node) {
15929
15967
  function isText$1(node) {
15930
15968
  return node.type === 5 || node.type === 2;
15931
15969
  }
15970
+ function isVPre(p) {
15971
+ return p.type === 7 && p.name === "pre";
15972
+ }
15932
15973
  function isVSlot(p) {
15933
15974
  return p.type === 7 && p.name === "slot";
15934
15975
  }
@@ -16187,7 +16228,7 @@ const tokenizer = new Tokenizer(stack, {
16187
16228
  ondirarg(start, end) {
16188
16229
  if (start === end) return;
16189
16230
  const arg = getSlice(start, end);
16190
- if (inVPre) {
16231
+ if (inVPre && !isVPre(currentProp)) {
16191
16232
  currentProp.name += arg;
16192
16233
  setLocEnd(currentProp.nameLoc, end);
16193
16234
  } else {
@@ -16202,7 +16243,7 @@ const tokenizer = new Tokenizer(stack, {
16202
16243
  },
16203
16244
  ondirmodifier(start, end) {
16204
16245
  const mod = getSlice(start, end);
16205
- if (inVPre) {
16246
+ if (inVPre && !isVPre(currentProp)) {
16206
16247
  currentProp.name += "." + mod;
16207
16248
  setLocEnd(currentProp.nameLoc, end);
16208
16249
  } else if (currentProp.name === "slot") {
@@ -16628,7 +16669,7 @@ function isUpperCase(c) {
16628
16669
  return c > 64 && c < 91;
16629
16670
  }
16630
16671
  const windowsNewlineRE = /\r\n/g;
16631
- function condenseWhitespace(nodes, tag) {
16672
+ function condenseWhitespace(nodes) {
16632
16673
  const shouldCondense = currentOptions.whitespace !== "preserve";
16633
16674
  let removedWhitespace = false;
16634
16675
  for (let i = 0; i < nodes.length; i++) {
@@ -16792,12 +16833,12 @@ function cacheStatic(root, context) {
16792
16833
  context,
16793
16834
  // Root node is unfortunately non-hoistable due to potential parent
16794
16835
  // fallthrough attributes.
16795
- isSingleElementRoot(root, root.children[0])
16836
+ !!getSingleElementRoot(root)
16796
16837
  );
16797
16838
  }
16798
- function isSingleElementRoot(root, child) {
16799
- const { children } = root;
16800
- return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
16839
+ function getSingleElementRoot(root) {
16840
+ const children = root.children.filter((x) => x.type !== 3);
16841
+ return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
16801
16842
  }
16802
16843
  function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
16803
16844
  const { children } = node;
@@ -16830,6 +16871,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
16830
16871
  } else if (child.type === 12) {
16831
16872
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
16832
16873
  if (constantType >= 2) {
16874
+ if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
16875
+ child.codegenNode.arguments.push(
16876
+ -1 + (` /* ${PatchFlagNames[-1]} */` )
16877
+ );
16878
+ }
16833
16879
  toCache.push(child);
16834
16880
  continue;
16835
16881
  }
@@ -17263,15 +17309,15 @@ function createRootCodegen(root, context) {
17263
17309
  const { helper } = context;
17264
17310
  const { children } = root;
17265
17311
  if (children.length === 1) {
17266
- const child = children[0];
17267
- if (isSingleElementRoot(root, child) && child.codegenNode) {
17268
- const codegenNode = child.codegenNode;
17312
+ const singleElementRootChild = getSingleElementRoot(root);
17313
+ if (singleElementRootChild && singleElementRootChild.codegenNode) {
17314
+ const codegenNode = singleElementRootChild.codegenNode;
17269
17315
  if (codegenNode.type === 13) {
17270
17316
  convertToBlock(codegenNode, context);
17271
17317
  }
17272
17318
  root.codegenNode = codegenNode;
17273
17319
  } else {
17274
- root.codegenNode = child;
17320
+ root.codegenNode = children[0];
17275
17321
  }
17276
17322
  } else if (children.length > 1) {
17277
17323
  let patchFlag = 64;
@@ -18279,7 +18325,7 @@ const transformBind = (dir, _node, context) => {
18279
18325
  arg.children.unshift(`(`);
18280
18326
  arg.children.push(`) || ""`);
18281
18327
  } else if (!arg.isStatic) {
18282
- arg.content = `${arg.content} || ""`;
18328
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
18283
18329
  }
18284
18330
  if (modifiers.some((mod) => mod.content === "camel")) {
18285
18331
  if (arg.type === 4) {
@@ -18626,7 +18672,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
18626
18672
  let prev;
18627
18673
  while (j--) {
18628
18674
  prev = children[j];
18629
- if (prev.type !== 3) {
18675
+ if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
18630
18676
  break;
18631
18677
  }
18632
18678
  }