@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
+ if (!!(process.env.NODE_ENV !== "production")) {
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
  if (!!(process.env.NODE_ENV !== "production")) {
881
904
  this.subsHead = void 0;
882
905
  }
@@ -5007,10 +5030,8 @@ function resolveCssVars(instance, vnode, expectedMap) {
5007
5030
  if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
5008
5031
  const cssVars = instance.getCssVars();
5009
5032
  for (const key in cssVars) {
5010
- expectedMap.set(
5011
- `--${getEscapedCssVarName(key)}`,
5012
- String(cssVars[key])
5013
- );
5033
+ const value = normalizeCssVarValue(cssVars[key]);
5034
+ expectedMap.set(`--${getEscapedCssVarName(key)}`, value);
5014
5035
  }
5015
5036
  }
5016
5037
  if (vnode === root && instance.parent) {
@@ -5041,7 +5062,7 @@ function isMismatchAllowed(el, allowedType) {
5041
5062
  if (allowedType === 0 /* TEXT */ && list.includes("children")) {
5042
5063
  return true;
5043
5064
  }
5044
- return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
5065
+ return list.includes(MismatchTypeString[allowedType]);
5045
5066
  }
5046
5067
  }
5047
5068
 
@@ -5199,16 +5220,19 @@ function defineAsyncComponent(source) {
5199
5220
  __asyncLoader: load,
5200
5221
  __asyncHydrate(el, instance, hydrate) {
5201
5222
  let patched = false;
5202
- const doHydrate = hydrateStrategy ? () => {
5203
- const performHydrate = () => {
5204
- if (!!(process.env.NODE_ENV !== "production") && patched) {
5223
+ (instance.bu || (instance.bu = [])).push(() => patched = true);
5224
+ const performHydrate = () => {
5225
+ if (patched) {
5226
+ if (!!(process.env.NODE_ENV !== "production")) {
5205
5227
  warn$1(
5206
- `Skipping lazy hydration for component '${getComponentName(resolvedComp)}': it was updated before lazy hydration performed.`
5228
+ `Skipping lazy hydration for component '${getComponentName(resolvedComp) || resolvedComp.__file}': it was updated before lazy hydration performed.`
5207
5229
  );
5208
- return;
5209
5230
  }
5210
- hydrate();
5211
- };
5231
+ return;
5232
+ }
5233
+ hydrate();
5234
+ };
5235
+ const doHydrate = hydrateStrategy ? () => {
5212
5236
  const teardown = hydrateStrategy(
5213
5237
  performHydrate,
5214
5238
  (cb) => forEachElement(el, cb)
@@ -5216,8 +5240,7 @@ function defineAsyncComponent(source) {
5216
5240
  if (teardown) {
5217
5241
  (instance.bum || (instance.bum = [])).push(teardown);
5218
5242
  }
5219
- (instance.u || (instance.u = [])).push(() => patched = true);
5220
- } : hydrate;
5243
+ } : performHydrate;
5221
5244
  if (resolvedComp) {
5222
5245
  doHydrate();
5223
5246
  } else {
@@ -6639,15 +6662,15 @@ function withDefaults(props, defaults) {
6639
6662
  return null;
6640
6663
  }
6641
6664
  function useSlots() {
6642
- return getContext().slots;
6665
+ return getContext("useSlots").slots;
6643
6666
  }
6644
6667
  function useAttrs() {
6645
- return getContext().attrs;
6668
+ return getContext("useAttrs").attrs;
6646
6669
  }
6647
- function getContext() {
6670
+ function getContext(calledFunctionName) {
6648
6671
  const i = getCurrentInstance();
6649
6672
  if (!!(process.env.NODE_ENV !== "production") && !i) {
6650
- warn$1(`useContext() called without active instance.`);
6673
+ warn$1(`${calledFunctionName}() called without active instance.`);
6651
6674
  }
6652
6675
  return i.setupContext || (i.setupContext = createSetupContext(i));
6653
6676
  }
@@ -6908,7 +6931,8 @@ function applyOptions(instance) {
6908
6931
  expose.forEach((key) => {
6909
6932
  Object.defineProperty(exposed, key, {
6910
6933
  get: () => publicThis[key],
6911
- set: (val) => publicThis[key] = val
6934
+ set: (val) => publicThis[key] = val,
6935
+ enumerable: true
6912
6936
  });
6913
6937
  });
6914
6938
  } else if (!instance.exposed) {
@@ -7233,7 +7257,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7233
7257
  return vm;
7234
7258
  }
7235
7259
  }
7236
- Vue.version = `2.6.14-compat:${"3.5.16"}`;
7260
+ Vue.version = `2.6.14-compat:${"3.5.18"}`;
7237
7261
  Vue.config = singletonApp.config;
7238
7262
  Vue.use = (plugin, ...options) => {
7239
7263
  if (plugin && isFunction(plugin.install)) {
@@ -7827,7 +7851,7 @@ function provide(key, value) {
7827
7851
  }
7828
7852
  }
7829
7853
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
7830
- const instance = currentInstance || currentRenderingInstance;
7854
+ const instance = getCurrentInstance();
7831
7855
  if (instance || currentApp) {
7832
7856
  let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
7833
7857
  if (provides && key in provides) {
@@ -7842,7 +7866,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
7842
7866
  }
7843
7867
  }
7844
7868
  function hasInjectionContext() {
7845
- return !!(currentInstance || currentRenderingInstance || currentApp);
7869
+ return !!(getCurrentInstance() || currentApp);
7846
7870
  }
7847
7871
 
7848
7872
  function createPropsDefaultThis(instance, rawProps, propKey) {
@@ -8328,7 +8352,7 @@ function isBoolean(...args) {
8328
8352
  return args.some((elem) => elem.toLowerCase() === "boolean");
8329
8353
  }
8330
8354
 
8331
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
8355
+ const isInternalKey = (key) => key === "_" || key === "__" || key === "_ctx" || key === "$stable";
8332
8356
  const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
8333
8357
  const normalizeSlot = (key, rawSlot, ctx) => {
8334
8358
  if (rawSlot._n) {
@@ -8382,6 +8406,8 @@ const assignSlots = (slots, children, optimized) => {
8382
8406
  const initSlots = (instance, children, optimized) => {
8383
8407
  const slots = instance.slots = createInternalObject();
8384
8408
  if (instance.vnode.shapeFlag & 32) {
8409
+ const cacheIndexes = children.__;
8410
+ if (cacheIndexes) def(slots, "__", cacheIndexes, true);
8385
8411
  const type = children._;
8386
8412
  if (type) {
8387
8413
  assignSlots(slots, children, optimized);
@@ -8620,6 +8646,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8620
8646
  }
8621
8647
  if (ref != null && parentComponent) {
8622
8648
  setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
8649
+ } else if (ref == null && n1 && n1.ref != null) {
8650
+ setRef(n1.ref, null, parentSuspense, n1, true);
8623
8651
  }
8624
8652
  };
8625
8653
  const processText = (n1, n2, container, anchor) => {
@@ -9105,6 +9133,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9105
9133
  if (!initialVNode.el) {
9106
9134
  const placeholder = instance.subTree = createVNode(Comment);
9107
9135
  processCommentNode(null, placeholder, container, anchor);
9136
+ initialVNode.placeholder = placeholder.el;
9108
9137
  }
9109
9138
  } else {
9110
9139
  setupRenderEffect(
@@ -9194,7 +9223,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9194
9223
  hydrateSubTree();
9195
9224
  }
9196
9225
  } else {
9197
- if (root.ce) {
9226
+ if (root.ce && // @ts-expect-error _def is private
9227
+ root.ce._def.shadowRoot !== false) {
9198
9228
  root.ce._injectChildStyle(type);
9199
9229
  }
9200
9230
  if (!!(process.env.NODE_ENV !== "production")) {
@@ -9629,7 +9659,11 @@ function baseCreateRenderer(options, createHydrationFns) {
9629
9659
  for (i = toBePatched - 1; i >= 0; i--) {
9630
9660
  const nextIndex = s2 + i;
9631
9661
  const nextChild = c2[nextIndex];
9632
- const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
9662
+ const anchorVNode = c2[nextIndex + 1];
9663
+ const anchor = nextIndex + 1 < l2 ? (
9664
+ // #13559, fallback to el placeholder for unresolved async component
9665
+ anchorVNode.el || anchorVNode.placeholder
9666
+ ) : parentAnchor;
9633
9667
  if (newIndexToOldIndexMap[i] === 0) {
9634
9668
  patch(
9635
9669
  null,
@@ -10290,8 +10324,9 @@ function emit(instance, event, ...rawArgs) {
10290
10324
  }
10291
10325
  }
10292
10326
  let args = rawArgs;
10293
- const isModelListener = event.startsWith("update:");
10294
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
10327
+ const isCompatModelListener = compatModelEventPrefix + event in props;
10328
+ const isModelListener = isCompatModelListener || event.startsWith("update:");
10329
+ const modifiers = isCompatModelListener ? props.modelModifiers : isModelListener && getModelModifiers(props, event.slice(7));
10295
10330
  if (modifiers) {
10296
10331
  if (modifiers.trim) {
10297
10332
  args = rawArgs.map((a) => isString(a) ? a.trim() : a);
@@ -11623,6 +11658,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
11623
11658
  suspense: vnode.suspense,
11624
11659
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
11625
11660
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
11661
+ placeholder: vnode.placeholder,
11626
11662
  el: vnode.el,
11627
11663
  anchor: vnode.anchor,
11628
11664
  ctx: vnode.ctx,
@@ -12443,7 +12479,7 @@ function isMemoSame(cached, memo) {
12443
12479
  return true;
12444
12480
  }
12445
12481
 
12446
- const version = "3.5.16";
12482
+ const version = "3.5.18";
12447
12483
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12448
12484
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12449
12485
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13000,8 +13036,9 @@ function setVarsOnNode(el, vars) {
13000
13036
  const style = el.style;
13001
13037
  let cssText = "";
13002
13038
  for (const key in vars) {
13003
- style.setProperty(`--${key}`, vars[key]);
13004
- cssText += `--${key}: ${vars[key]};`;
13039
+ const value = normalizeCssVarValue(vars[key]);
13040
+ style.setProperty(`--${key}`, value);
13041
+ cssText += `--${key}: ${value};`;
13005
13042
  }
13006
13043
  style[CSS_VAR_TEXT] = cssText;
13007
13044
  }
@@ -13534,9 +13571,10 @@ class VueElement extends BaseClass {
13534
13571
  };
13535
13572
  const asyncDef = this._def.__asyncLoader;
13536
13573
  if (asyncDef) {
13537
- this._pendingResolve = asyncDef().then(
13538
- (def) => resolve(this._def = def, true)
13539
- );
13574
+ this._pendingResolve = asyncDef().then((def) => {
13575
+ def.configureApp = this._def.configureApp;
13576
+ resolve(this._def = def, true);
13577
+ });
13540
13578
  } else {
13541
13579
  resolve(this._def);
13542
13580
  }
@@ -15553,7 +15591,7 @@ class Tokenizer {
15553
15591
  this.buffer = input;
15554
15592
  while (this.index < this.buffer.length) {
15555
15593
  const c = this.buffer.charCodeAt(this.index);
15556
- if (c === 10) {
15594
+ if (c === 10 && this.state !== 33) {
15557
15595
  this.newlines.push(this.index);
15558
15596
  }
15559
15597
  switch (this.state) {
@@ -15897,7 +15935,7 @@ function isCoreComponent(tag) {
15897
15935
  return BASE_TRANSITION;
15898
15936
  }
15899
15937
  }
15900
- const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
15938
+ const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
15901
15939
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
15902
15940
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
15903
15941
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
@@ -16009,6 +16047,9 @@ function hasDynamicKeyVBind(node) {
16009
16047
  function isText$1(node) {
16010
16048
  return node.type === 5 || node.type === 2;
16011
16049
  }
16050
+ function isVPre(p) {
16051
+ return p.type === 7 && p.name === "pre";
16052
+ }
16012
16053
  function isVSlot(p) {
16013
16054
  return p.type === 7 && p.name === "slot";
16014
16055
  }
@@ -16267,7 +16308,7 @@ const tokenizer = new Tokenizer(stack, {
16267
16308
  ondirarg(start, end) {
16268
16309
  if (start === end) return;
16269
16310
  const arg = getSlice(start, end);
16270
- if (inVPre) {
16311
+ if (inVPre && !isVPre(currentProp)) {
16271
16312
  currentProp.name += arg;
16272
16313
  setLocEnd(currentProp.nameLoc, end);
16273
16314
  } else {
@@ -16282,7 +16323,7 @@ const tokenizer = new Tokenizer(stack, {
16282
16323
  },
16283
16324
  ondirmodifier(start, end) {
16284
16325
  const mod = getSlice(start, end);
16285
- if (inVPre) {
16326
+ if (inVPre && !isVPre(currentProp)) {
16286
16327
  currentProp.name += "." + mod;
16287
16328
  setLocEnd(currentProp.nameLoc, end);
16288
16329
  } else if (currentProp.name === "slot") {
@@ -16708,7 +16749,7 @@ function isUpperCase(c) {
16708
16749
  return c > 64 && c < 91;
16709
16750
  }
16710
16751
  const windowsNewlineRE = /\r\n/g;
16711
- function condenseWhitespace(nodes, tag) {
16752
+ function condenseWhitespace(nodes) {
16712
16753
  const shouldCondense = currentOptions.whitespace !== "preserve";
16713
16754
  let removedWhitespace = false;
16714
16755
  for (let i = 0; i < nodes.length; i++) {
@@ -16872,12 +16913,12 @@ function cacheStatic(root, context) {
16872
16913
  context,
16873
16914
  // Root node is unfortunately non-hoistable due to potential parent
16874
16915
  // fallthrough attributes.
16875
- isSingleElementRoot(root, root.children[0])
16916
+ !!getSingleElementRoot(root)
16876
16917
  );
16877
16918
  }
16878
- function isSingleElementRoot(root, child) {
16879
- const { children } = root;
16880
- return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
16919
+ function getSingleElementRoot(root) {
16920
+ const children = root.children.filter((x) => x.type !== 3);
16921
+ return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
16881
16922
  }
16882
16923
  function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
16883
16924
  const { children } = node;
@@ -16910,6 +16951,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
16910
16951
  } else if (child.type === 12) {
16911
16952
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
16912
16953
  if (constantType >= 2) {
16954
+ if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
16955
+ child.codegenNode.arguments.push(
16956
+ -1 + (!!(process.env.NODE_ENV !== "production") ? ` /* ${PatchFlagNames[-1]} */` : ``)
16957
+ );
16958
+ }
16913
16959
  toCache.push(child);
16914
16960
  continue;
16915
16961
  }
@@ -17344,15 +17390,15 @@ function createRootCodegen(root, context) {
17344
17390
  const { helper } = context;
17345
17391
  const { children } = root;
17346
17392
  if (children.length === 1) {
17347
- const child = children[0];
17348
- if (isSingleElementRoot(root, child) && child.codegenNode) {
17349
- const codegenNode = child.codegenNode;
17393
+ const singleElementRootChild = getSingleElementRoot(root);
17394
+ if (singleElementRootChild && singleElementRootChild.codegenNode) {
17395
+ const codegenNode = singleElementRootChild.codegenNode;
17350
17396
  if (codegenNode.type === 13) {
17351
17397
  convertToBlock(codegenNode, context);
17352
17398
  }
17353
17399
  root.codegenNode = codegenNode;
17354
17400
  } else {
17355
- root.codegenNode = child;
17401
+ root.codegenNode = children[0];
17356
17402
  }
17357
17403
  } else if (children.length > 1) {
17358
17404
  let patchFlag = 64;
@@ -18362,7 +18408,7 @@ const transformBind = (dir, _node, context) => {
18362
18408
  arg.children.unshift(`(`);
18363
18409
  arg.children.push(`) || ""`);
18364
18410
  } else if (!arg.isStatic) {
18365
- arg.content = `${arg.content} || ""`;
18411
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
18366
18412
  }
18367
18413
  if (modifiers.some((mod) => mod.content === "camel")) {
18368
18414
  if (arg.type === 4) {
@@ -18709,7 +18755,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
18709
18755
  let prev;
18710
18756
  while (j--) {
18711
18757
  prev = children[j];
18712
- if (prev.type !== 3) {
18758
+ if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
18713
18759
  break;
18714
18760
  }
18715
18761
  }