@vue/compat 3.5.20 → 3.5.22

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.20
2
+ * @vue/compat v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -10,7 +10,6 @@ var estreeWalker = require('estree-walker');
10
10
  var decode_js = require('entities/lib/decode.js');
11
11
  var sourceMapJs = require('source-map-js');
12
12
 
13
- /*! #__NO_SIDE_EFFECTS__ */
14
13
  // @__NO_SIDE_EFFECTS__
15
14
  function makeMap(str) {
16
15
  const map = /* @__PURE__ */ Object.create(null);
@@ -68,10 +67,10 @@ const cacheStringFunction = (fn) => {
68
67
  return hit || (cache[str] = fn(str));
69
68
  });
70
69
  };
71
- const camelizeRE = /-(\w)/g;
70
+ const camelizeRE = /-\w/g;
72
71
  const camelize = cacheStringFunction(
73
72
  (str) => {
74
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
73
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
75
74
  }
76
75
  );
77
76
  const hyphenateRE = /\B([A-Z])/g;
@@ -1114,7 +1113,7 @@ function iterator(self, method, wrapValue) {
1114
1113
  iter._next = iter.next;
1115
1114
  iter.next = () => {
1116
1115
  const result = iter._next();
1117
- if (result.value) {
1116
+ if (!result.done) {
1118
1117
  result.value = wrapValue(result.value);
1119
1118
  }
1120
1119
  return result;
@@ -1241,7 +1240,8 @@ class BaseReactiveHandler {
1241
1240
  return res;
1242
1241
  }
1243
1242
  if (isRef(res)) {
1244
- return targetIsArray && isIntegerKey(key) ? res : res.value;
1243
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
1244
+ return isReadonly2 && isObject(value) ? readonly(value) : value;
1245
1245
  }
1246
1246
  if (isObject(res)) {
1247
1247
  return isReadonly2 ? readonly(res) : reactive(res);
@@ -2031,11 +2031,11 @@ function traverse(value, depth = Infinity, seen) {
2031
2031
  if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
2032
2032
  return value;
2033
2033
  }
2034
- seen = seen || /* @__PURE__ */ new Set();
2035
- if (seen.has(value)) {
2034
+ seen = seen || /* @__PURE__ */ new Map();
2035
+ if ((seen.get(value) || 0) >= depth) {
2036
2036
  return value;
2037
2037
  }
2038
- seen.add(value);
2038
+ seen.set(value, depth);
2039
2039
  depth--;
2040
2040
  if (isRef(value)) {
2041
2041
  traverse(value.value, depth, seen);
@@ -2722,9 +2722,6 @@ const TeleportImpl = {
2722
2722
  insert(mainAnchor, container, anchor);
2723
2723
  const mount = (container2, anchor2) => {
2724
2724
  if (shapeFlag & 16) {
2725
- if (parentComponent && parentComponent.isCE) {
2726
- parentComponent.ce._teleportTarget = container2;
2727
- }
2728
2725
  mountChildren(
2729
2726
  children,
2730
2727
  container2,
@@ -2746,6 +2743,9 @@ const TeleportImpl = {
2746
2743
  } else if (namespace !== "mathml" && isTargetMathML(target)) {
2747
2744
  namespace = "mathml";
2748
2745
  }
2746
+ if (parentComponent && parentComponent.isCE) {
2747
+ (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
2748
+ }
2749
2749
  if (!disabled) {
2750
2750
  mount(target, targetAnchor);
2751
2751
  updateCssVars(n2, false);
@@ -2922,26 +2922,34 @@ function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }
2922
2922
  function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
2923
2923
  o: { nextSibling, parentNode, querySelector, insert, createText }
2924
2924
  }, hydrateChildren) {
2925
+ function hydrateDisabledTeleport(node2, vnode2, targetStart, targetAnchor) {
2926
+ vnode2.anchor = hydrateChildren(
2927
+ nextSibling(node2),
2928
+ vnode2,
2929
+ parentNode(node2),
2930
+ parentComponent,
2931
+ parentSuspense,
2932
+ slotScopeIds,
2933
+ optimized
2934
+ );
2935
+ vnode2.targetStart = targetStart;
2936
+ vnode2.targetAnchor = targetAnchor;
2937
+ }
2925
2938
  const target = vnode.target = resolveTarget(
2926
2939
  vnode.props,
2927
2940
  querySelector
2928
2941
  );
2942
+ const disabled = isTeleportDisabled(vnode.props);
2929
2943
  if (target) {
2930
- const disabled = isTeleportDisabled(vnode.props);
2931
2944
  const targetNode = target._lpa || target.firstChild;
2932
2945
  if (vnode.shapeFlag & 16) {
2933
2946
  if (disabled) {
2934
- vnode.anchor = hydrateChildren(
2935
- nextSibling(node),
2947
+ hydrateDisabledTeleport(
2948
+ node,
2936
2949
  vnode,
2937
- parentNode(node),
2938
- parentComponent,
2939
- parentSuspense,
2940
- slotScopeIds,
2941
- optimized
2950
+ targetNode,
2951
+ targetNode && nextSibling(targetNode)
2942
2952
  );
2943
- vnode.targetStart = targetNode;
2944
- vnode.targetAnchor = targetNode && nextSibling(targetNode);
2945
2953
  } else {
2946
2954
  vnode.anchor = nextSibling(node);
2947
2955
  let targetAnchor = targetNode;
@@ -2972,6 +2980,10 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
2972
2980
  }
2973
2981
  }
2974
2982
  updateCssVars(vnode, disabled);
2983
+ } else if (disabled) {
2984
+ if (vnode.shapeFlag & 16) {
2985
+ hydrateDisabledTeleport(node, vnode, node, nextSibling(node));
2986
+ }
2975
2987
  }
2976
2988
  return vnode.anchor && nextSibling(vnode.anchor);
2977
2989
  }
@@ -3080,7 +3092,7 @@ const BaseTransitionImpl = {
3080
3092
  setTransitionHooks(innerChild, enterHooks);
3081
3093
  }
3082
3094
  let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
3083
- if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
3095
+ if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(oldInnerChild, innerChild) && recursiveGetSubtree(instance).type !== Comment) {
3084
3096
  let leavingHooks = resolveTransitionHooks(
3085
3097
  oldInnerChild,
3086
3098
  rawProps,
@@ -3356,7 +3368,6 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3356
3368
  return ret;
3357
3369
  }
3358
3370
 
3359
- /*! #__NO_SIDE_EFFECTS__ */
3360
3371
  // @__NO_SIDE_EFFECTS__
3361
3372
  function defineComponent(options, extraOptions) {
3362
3373
  return isFunction(options) ? (
@@ -3394,6 +3405,7 @@ function useTemplateRef(key) {
3394
3405
  return ret;
3395
3406
  }
3396
3407
 
3408
+ const pendingSetRefMap = /* @__PURE__ */ new WeakMap();
3397
3409
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3398
3410
  if (isArray(rawRef)) {
3399
3411
  rawRef.forEach(
@@ -3424,6 +3436,7 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3424
3436
  return hasOwn(rawSetupState, key);
3425
3437
  };
3426
3438
  if (oldRef != null && oldRef !== ref) {
3439
+ invalidatePendingSetRef(oldRawRef);
3427
3440
  if (isString(oldRef)) {
3428
3441
  refs[oldRef] = null;
3429
3442
  if (canSetSetupRef(oldRef)) {
@@ -3479,14 +3492,27 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3479
3492
  } else ;
3480
3493
  };
3481
3494
  if (value) {
3482
- doSet.id = -1;
3483
- queuePostRenderEffect(doSet, parentSuspense);
3495
+ const job = () => {
3496
+ doSet();
3497
+ pendingSetRefMap.delete(rawRef);
3498
+ };
3499
+ job.id = -1;
3500
+ pendingSetRefMap.set(rawRef, job);
3501
+ queuePostRenderEffect(job, parentSuspense);
3484
3502
  } else {
3503
+ invalidatePendingSetRef(rawRef);
3485
3504
  doSet();
3486
3505
  }
3487
3506
  }
3488
3507
  }
3489
3508
  }
3509
+ function invalidatePendingSetRef(rawRef) {
3510
+ const pendingSetRef = pendingSetRefMap.get(rawRef);
3511
+ if (pendingSetRef) {
3512
+ pendingSetRef.flags |= 8;
3513
+ pendingSetRefMap.delete(rawRef);
3514
+ }
3515
+ }
3490
3516
 
3491
3517
  let hasLoggedMismatchError = false;
3492
3518
  const logMismatchError = () => {
@@ -4048,7 +4074,6 @@ function forEachElement(node, cb) {
4048
4074
  }
4049
4075
 
4050
4076
  const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
4051
- /*! #__NO_SIDE_EFFECTS__ */
4052
4077
  // @__NO_SIDE_EFFECTS__
4053
4078
  function defineAsyncComponent(source) {
4054
4079
  if (isFunction(source)) {
@@ -4904,12 +4929,13 @@ function createSlots(slots, dynamicSlots) {
4904
4929
 
4905
4930
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
4906
4931
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
4932
+ const hasProps = Object.keys(props).length > 0;
4907
4933
  if (name !== "default") props.name = name;
4908
4934
  return openBlock(), createBlock(
4909
4935
  Fragment,
4910
4936
  null,
4911
4937
  [createVNode("slot", props, fallback && fallback())],
4912
- 64
4938
+ hasProps ? -2 : 64
4913
4939
  );
4914
4940
  }
4915
4941
  let slot = slots[name];
@@ -5841,7 +5867,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5841
5867
  return vm;
5842
5868
  }
5843
5869
  }
5844
- Vue.version = `2.6.14-compat:${"3.5.20"}`;
5870
+ Vue.version = `2.6.14-compat:${"3.5.22"}`;
5845
5871
  Vue.config = singletonApp.config;
5846
5872
  Vue.use = (plugin, ...options) => {
5847
5873
  if (plugin && isFunction(plugin.install)) {
@@ -8388,8 +8414,9 @@ function emit(instance, event, ...rawArgs) {
8388
8414
  return emit$1(instance, event, args);
8389
8415
  }
8390
8416
  }
8417
+ const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
8391
8418
  function normalizeEmitsOptions(comp, appContext, asMixin = false) {
8392
- const cache = appContext.emitsCache;
8419
+ const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
8393
8420
  const cached = cache.get(comp);
8394
8421
  if (cached !== void 0) {
8395
8422
  return cached;
@@ -8775,7 +8802,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
8775
8802
  const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
8776
8803
  if (pendingBranch) {
8777
8804
  suspense.pendingBranch = newBranch;
8778
- if (isSameVNodeType(newBranch, pendingBranch)) {
8805
+ if (isSameVNodeType(pendingBranch, newBranch)) {
8779
8806
  patch(
8780
8807
  pendingBranch,
8781
8808
  newBranch,
@@ -8846,7 +8873,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
8846
8873
  );
8847
8874
  setActiveBranch(suspense, newFallback);
8848
8875
  }
8849
- } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
8876
+ } else if (activeBranch && isSameVNodeType(activeBranch, newBranch)) {
8850
8877
  patch(
8851
8878
  activeBranch,
8852
8879
  newBranch,
@@ -8877,7 +8904,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
8877
8904
  }
8878
8905
  }
8879
8906
  } else {
8880
- if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
8907
+ if (activeBranch && isSameVNodeType(activeBranch, newBranch)) {
8881
8908
  patch(
8882
8909
  activeBranch,
8883
8910
  newBranch,
@@ -9940,23 +9967,28 @@ const computed = (getterOrOptions, debugOptions) => {
9940
9967
  };
9941
9968
 
9942
9969
  function h(type, propsOrChildren, children) {
9943
- const l = arguments.length;
9944
- if (l === 2) {
9945
- if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
9946
- if (isVNode(propsOrChildren)) {
9947
- return createVNode(type, null, [propsOrChildren]);
9970
+ try {
9971
+ setBlockTracking(-1);
9972
+ const l = arguments.length;
9973
+ if (l === 2) {
9974
+ if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
9975
+ if (isVNode(propsOrChildren)) {
9976
+ return createVNode(type, null, [propsOrChildren]);
9977
+ }
9978
+ return createVNode(type, propsOrChildren);
9979
+ } else {
9980
+ return createVNode(type, null, propsOrChildren);
9948
9981
  }
9949
- return createVNode(type, propsOrChildren);
9950
9982
  } else {
9951
- return createVNode(type, null, propsOrChildren);
9952
- }
9953
- } else {
9954
- if (l > 3) {
9955
- children = Array.prototype.slice.call(arguments, 2);
9956
- } else if (l === 3 && isVNode(children)) {
9957
- children = [children];
9983
+ if (l > 3) {
9984
+ children = Array.prototype.slice.call(arguments, 2);
9985
+ } else if (l === 3 && isVNode(children)) {
9986
+ children = [children];
9987
+ }
9988
+ return createVNode(type, propsOrChildren, children);
9958
9989
  }
9959
- return createVNode(type, propsOrChildren, children);
9990
+ } finally {
9991
+ setBlockTracking(1);
9960
9992
  }
9961
9993
  }
9962
9994
 
@@ -9992,7 +10024,7 @@ function isMemoSame(cached, memo) {
9992
10024
  return true;
9993
10025
  }
9994
10026
 
9995
- const version = "3.5.20";
10027
+ const version = "3.5.22";
9996
10028
  const warn$1 = NOOP;
9997
10029
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9998
10030
  const devtools = void 0;
@@ -10261,11 +10293,11 @@ function resolveTransitionProps(rawProps) {
10261
10293
  addTransitionClass(el, legacyLeaveFromClass);
10262
10294
  }
10263
10295
  if (!el._enterCancelled) {
10264
- forceReflow();
10296
+ forceReflow(el);
10265
10297
  addTransitionClass(el, leaveActiveClass);
10266
10298
  } else {
10267
10299
  addTransitionClass(el, leaveActiveClass);
10268
- forceReflow();
10300
+ forceReflow(el);
10269
10301
  }
10270
10302
  nextFrame(() => {
10271
10303
  if (!el._isLeaving) {
@@ -10391,7 +10423,7 @@ function getTransitionInfo(el, expectedType) {
10391
10423
  type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
10392
10424
  propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
10393
10425
  }
10394
- const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
10426
+ const hasTransform = type === TRANSITION$1 && /\b(?:transform|all)(?:,|$)/.test(
10395
10427
  getStyleProperties(`${TRANSITION$1}Property`).toString()
10396
10428
  );
10397
10429
  return {
@@ -10411,8 +10443,9 @@ function toMs(s) {
10411
10443
  if (s === "auto") return 0;
10412
10444
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
10413
10445
  }
10414
- function forceReflow() {
10415
- return document.body.offsetHeight;
10446
+ function forceReflow(el) {
10447
+ const targetDocument = el ? el.ownerDocument : document;
10448
+ return targetDocument.body.offsetHeight;
10416
10449
  }
10417
10450
 
10418
10451
  function patchClass(el, value, isSVG) {
@@ -10484,7 +10517,7 @@ function useCssVars(getter) {
10484
10517
  return;
10485
10518
  }
10486
10519
 
10487
- const displayRE = /(^|;)\s*display\s*:/;
10520
+ const displayRE = /(?:^|;)\s*display\s*:/;
10488
10521
  function patchStyle(el, prev, next) {
10489
10522
  const style = el.style;
10490
10523
  const isCssString = isString(next);
@@ -10822,11 +10855,10 @@ function shouldSetAsProp(el, key, value, isSVG) {
10822
10855
  }
10823
10856
 
10824
10857
  const REMOVAL = {};
10825
- /*! #__NO_SIDE_EFFECTS__ */
10826
10858
  // @__NO_SIDE_EFFECTS__
10827
10859
  function defineCustomElement(options, extraOptions, _createApp) {
10828
- const Comp = defineComponent(options, extraOptions);
10829
- if (isPlainObject(Comp)) extend$1(Comp, extraOptions);
10860
+ let Comp = defineComponent(options, extraOptions);
10861
+ if (isPlainObject(Comp)) Comp = extend$1({}, Comp, extraOptions);
10830
10862
  class VueCustomElement extends VueElement {
10831
10863
  constructor(initialProps) {
10832
10864
  super(Comp, initialProps, _createApp);
@@ -10835,7 +10867,6 @@ function defineCustomElement(options, extraOptions, _createApp) {
10835
10867
  VueCustomElement.def = Comp;
10836
10868
  return VueCustomElement;
10837
10869
  }
10838
-
10839
10870
  const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
10840
10871
  return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
10841
10872
  });
@@ -10869,7 +10900,11 @@ class VueElement extends BaseClass {
10869
10900
  this._root = this.shadowRoot;
10870
10901
  } else {
10871
10902
  if (_def.shadowRoot !== false) {
10872
- this.attachShadow({ mode: "open" });
10903
+ this.attachShadow(
10904
+ extend$1({}, _def.shadowRootOptions, {
10905
+ mode: "open"
10906
+ })
10907
+ );
10873
10908
  this._root = this.shadowRoot;
10874
10909
  } else {
10875
10910
  this._root = this;
@@ -10929,9 +10964,18 @@ class VueElement extends BaseClass {
10929
10964
  this._app && this._app.unmount();
10930
10965
  if (this._instance) this._instance.ce = void 0;
10931
10966
  this._app = this._instance = null;
10967
+ if (this._teleportTargets) {
10968
+ this._teleportTargets.clear();
10969
+ this._teleportTargets = void 0;
10970
+ }
10932
10971
  }
10933
10972
  });
10934
10973
  }
10974
+ _processMutations(mutations) {
10975
+ for (const m of mutations) {
10976
+ this._setAttr(m.attributeName);
10977
+ }
10978
+ }
10935
10979
  /**
10936
10980
  * resolve inner component definition (handle possible async component)
10937
10981
  */
@@ -10942,11 +10986,7 @@ class VueElement extends BaseClass {
10942
10986
  for (let i = 0; i < this.attributes.length; i++) {
10943
10987
  this._setAttr(this.attributes[i].name);
10944
10988
  }
10945
- this._ob = new MutationObserver((mutations) => {
10946
- for (const m of mutations) {
10947
- this._setAttr(m.attributeName);
10948
- }
10949
- });
10989
+ this._ob = new MutationObserver(this._processMutations.bind(this));
10950
10990
  this._ob.observe(this, { attributes: true });
10951
10991
  const resolve = (def, isAsync = false) => {
10952
10992
  this._resolved = true;
@@ -11053,7 +11093,10 @@ class VueElement extends BaseClass {
11053
11093
  }
11054
11094
  if (shouldReflect) {
11055
11095
  const ob = this._ob;
11056
- ob && ob.disconnect();
11096
+ if (ob) {
11097
+ this._processMutations(ob.takeRecords());
11098
+ ob.disconnect();
11099
+ }
11057
11100
  if (val === true) {
11058
11101
  this.setAttribute(hyphenate(key), "");
11059
11102
  } else if (typeof val === "string" || typeof val === "number") {
@@ -11132,7 +11175,7 @@ class VueElement extends BaseClass {
11132
11175
  * Only called when shadowRoot is false
11133
11176
  */
11134
11177
  _renderSlots() {
11135
- const outlets = (this._teleportTarget || this).querySelectorAll("slot");
11178
+ const outlets = this._getSlots();
11136
11179
  const scopeId = this._instance.type.__scopeId;
11137
11180
  for (let i = 0; i < outlets.length; i++) {
11138
11181
  const o = outlets[i];
@@ -11158,6 +11201,19 @@ class VueElement extends BaseClass {
11158
11201
  parent.removeChild(o);
11159
11202
  }
11160
11203
  }
11204
+ /**
11205
+ * @internal
11206
+ */
11207
+ _getSlots() {
11208
+ const roots = [this];
11209
+ if (this._teleportTargets) {
11210
+ roots.push(...this._teleportTargets);
11211
+ }
11212
+ return roots.reduce((res, i) => {
11213
+ res.push(...Array.from(i.querySelectorAll("slot")));
11214
+ return res;
11215
+ }, []);
11216
+ }
11161
11217
  /**
11162
11218
  * @internal
11163
11219
  */
@@ -11239,7 +11295,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
11239
11295
  prevChildren.forEach(callPendingCbs);
11240
11296
  prevChildren.forEach(recordPosition);
11241
11297
  const movedChildren = prevChildren.filter(applyTranslation);
11242
- forceReflow();
11298
+ forceReflow(instance.vnode.el);
11243
11299
  movedChildren.forEach((c) => {
11244
11300
  const el = c.el;
11245
11301
  const style = el.style;
@@ -11249,7 +11305,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
11249
11305
  if (e && e.target !== el) {
11250
11306
  return;
11251
11307
  }
11252
- if (!e || /transform$/.test(e.propertyName)) {
11308
+ if (!e || e.propertyName.endsWith("transform")) {
11253
11309
  el.removeEventListener("transitionend", cb);
11254
11310
  el[moveCbKey] = null;
11255
11311
  removeTransitionClass(el, moveClass);
@@ -13229,16 +13285,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
13229
13285
  (id) => markScopeIdentifier(node, id, knownIds)
13230
13286
  );
13231
13287
  }
13288
+ } else if (node.type === "SwitchStatement") {
13289
+ if (node.scopeIds) {
13290
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
13291
+ } else {
13292
+ walkSwitchStatement(
13293
+ node,
13294
+ false,
13295
+ (id) => markScopeIdentifier(node, id, knownIds)
13296
+ );
13297
+ }
13232
13298
  } else if (node.type === "CatchClause" && node.param) {
13233
- for (const id of extractIdentifiers(node.param)) {
13234
- markScopeIdentifier(node, id, knownIds);
13299
+ if (node.scopeIds) {
13300
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
13301
+ } else {
13302
+ for (const id of extractIdentifiers(node.param)) {
13303
+ markScopeIdentifier(node, id, knownIds);
13304
+ }
13235
13305
  }
13236
13306
  } else if (isForStatement(node)) {
13237
- walkForStatement(
13238
- node,
13239
- false,
13240
- (id) => markScopeIdentifier(node, id, knownIds)
13241
- );
13307
+ if (node.scopeIds) {
13308
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
13309
+ } else {
13310
+ walkForStatement(
13311
+ node,
13312
+ false,
13313
+ (id) => markScopeIdentifier(node, id, knownIds)
13314
+ );
13315
+ }
13242
13316
  }
13243
13317
  },
13244
13318
  leave(node, parent) {
@@ -13309,7 +13383,8 @@ function walkFunctionParams(node, onIdent) {
13309
13383
  }
13310
13384
  }
13311
13385
  function walkBlockDeclarations(block, onIdent) {
13312
- for (const stmt of block.body) {
13386
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
13387
+ for (const stmt of body) {
13313
13388
  if (stmt.type === "VariableDeclaration") {
13314
13389
  if (stmt.declare) continue;
13315
13390
  for (const decl of stmt.declarations) {
@@ -13322,6 +13397,8 @@ function walkBlockDeclarations(block, onIdent) {
13322
13397
  onIdent(stmt.id);
13323
13398
  } else if (isForStatement(stmt)) {
13324
13399
  walkForStatement(stmt, true, onIdent);
13400
+ } else if (stmt.type === "SwitchStatement") {
13401
+ walkSwitchStatement(stmt, true, onIdent);
13325
13402
  }
13326
13403
  }
13327
13404
  }
@@ -13338,6 +13415,20 @@ function walkForStatement(stmt, isVar, onIdent) {
13338
13415
  }
13339
13416
  }
13340
13417
  }
13418
+ function walkSwitchStatement(stmt, isVar, onIdent) {
13419
+ for (const cs of stmt.cases) {
13420
+ for (const stmt2 of cs.consequent) {
13421
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
13422
+ for (const decl of stmt2.declarations) {
13423
+ for (const id of extractIdentifiers(decl.id)) {
13424
+ onIdent(id);
13425
+ }
13426
+ }
13427
+ }
13428
+ }
13429
+ walkBlockDeclarations(cs, onIdent);
13430
+ }
13431
+ }
13341
13432
  function extractIdentifiers(param, nodes = []) {
13342
13433
  switch (param.type) {
13343
13434
  case "Identifier":
@@ -13573,6 +13664,7 @@ function isCoreComponent(tag) {
13573
13664
  }
13574
13665
  const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
13575
13666
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13667
+ const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13576
13668
  const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
13577
13669
  const isMemberExpressionNode = (exp, context) => {
13578
13670
  try {
@@ -16131,7 +16223,7 @@ function isConst(type) {
16131
16223
  }
16132
16224
 
16133
16225
  const transformIf = createStructuralDirectiveTransform(
16134
- /^(if|else|else-if)$/,
16226
+ /^(?:if|else|else-if)$/,
16135
16227
  (node, dir, context) => {
16136
16228
  return processIf(node, dir, context, (ifNode, branch, isRoot) => {
16137
16229
  const siblings = context.parent.children;
@@ -16340,90 +16432,6 @@ function getParentCondition(node) {
16340
16432
  }
16341
16433
  }
16342
16434
 
16343
- const transformBind = (dir, _node, context) => {
16344
- const { modifiers, loc } = dir;
16345
- const arg = dir.arg;
16346
- let { exp } = dir;
16347
- if (exp && exp.type === 4 && !exp.content.trim()) {
16348
- {
16349
- context.onError(
16350
- createCompilerError(34, loc)
16351
- );
16352
- return {
16353
- props: [
16354
- createObjectProperty(arg, createSimpleExpression("", true, loc))
16355
- ]
16356
- };
16357
- }
16358
- }
16359
- if (!exp) {
16360
- if (arg.type !== 4 || !arg.isStatic) {
16361
- context.onError(
16362
- createCompilerError(
16363
- 52,
16364
- arg.loc
16365
- )
16366
- );
16367
- return {
16368
- props: [
16369
- createObjectProperty(arg, createSimpleExpression("", true, loc))
16370
- ]
16371
- };
16372
- }
16373
- transformBindShorthand(dir, context);
16374
- exp = dir.exp;
16375
- }
16376
- if (arg.type !== 4) {
16377
- arg.children.unshift(`(`);
16378
- arg.children.push(`) || ""`);
16379
- } else if (!arg.isStatic) {
16380
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
16381
- }
16382
- if (modifiers.some((mod) => mod.content === "camel")) {
16383
- if (arg.type === 4) {
16384
- if (arg.isStatic) {
16385
- arg.content = camelize(arg.content);
16386
- } else {
16387
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
16388
- }
16389
- } else {
16390
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
16391
- arg.children.push(`)`);
16392
- }
16393
- }
16394
- if (!context.inSSR) {
16395
- if (modifiers.some((mod) => mod.content === "prop")) {
16396
- injectPrefix(arg, ".");
16397
- }
16398
- if (modifiers.some((mod) => mod.content === "attr")) {
16399
- injectPrefix(arg, "^");
16400
- }
16401
- }
16402
- return {
16403
- props: [createObjectProperty(arg, exp)]
16404
- };
16405
- };
16406
- const transformBindShorthand = (dir, context) => {
16407
- const arg = dir.arg;
16408
- const propName = camelize(arg.content);
16409
- dir.exp = createSimpleExpression(propName, false, arg.loc);
16410
- {
16411
- dir.exp = processExpression(dir.exp, context);
16412
- }
16413
- };
16414
- const injectPrefix = (arg, prefix) => {
16415
- if (arg.type === 4) {
16416
- if (arg.isStatic) {
16417
- arg.content = prefix + arg.content;
16418
- } else {
16419
- arg.content = `\`${prefix}\${${arg.content}}\``;
16420
- }
16421
- } else {
16422
- arg.children.unshift(`'${prefix}' + (`);
16423
- arg.children.push(`)`);
16424
- }
16425
- };
16426
-
16427
16435
  const transformFor = createStructuralDirectiveTransform(
16428
16436
  "for",
16429
16437
  (node, dir, context) => {
@@ -16436,9 +16444,6 @@ const transformFor = createStructuralDirectiveTransform(
16436
16444
  const memo = findDir(node, "memo");
16437
16445
  const keyProp = findProp(node, `key`, false, true);
16438
16446
  const isDirKey = keyProp && keyProp.type === 7;
16439
- if (isDirKey && !keyProp.exp) {
16440
- transformBindShorthand(keyProp, context);
16441
- }
16442
16447
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
16443
16448
  if (memo && keyExp && isDirKey) {
16444
16449
  {
@@ -16719,7 +16724,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16719
16724
  const dynamicSlots = [];
16720
16725
  let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
16721
16726
  if (!context.ssr && context.prefixIdentifiers) {
16722
- hasDynamicSlots = hasScopeRef(node, context.identifiers);
16727
+ hasDynamicSlots = node.props.some(
16728
+ (prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
16729
+ ) || children.some((child) => hasScopeRef(child, context.identifiers));
16723
16730
  }
16724
16731
  const onComponentSlot = findDir(node, "slot", true);
16725
16732
  if (onComponentSlot) {
@@ -16782,7 +16789,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16782
16789
  );
16783
16790
  } else if (vElse = findDir(
16784
16791
  slotElement,
16785
- /^else(-if)?$/,
16792
+ /^else(?:-if)?$/,
16786
16793
  true
16787
16794
  /* allowEmpty */
16788
16795
  )) {
@@ -16794,7 +16801,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16794
16801
  break;
16795
16802
  }
16796
16803
  }
16797
- if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
16804
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
16798
16805
  let conditional = dynamicSlots[dynamicSlots.length - 1];
16799
16806
  while (conditional.alternate.type === 19) {
16800
16807
  conditional = conditional.alternate;
@@ -17719,6 +17726,65 @@ const transformOn$1 = (dir, node, context, augmentor) => {
17719
17726
  return ret;
17720
17727
  };
17721
17728
 
17729
+ const transformBind = (dir, _node, context) => {
17730
+ const { modifiers, loc } = dir;
17731
+ const arg = dir.arg;
17732
+ let { exp } = dir;
17733
+ if (exp && exp.type === 4 && !exp.content.trim()) {
17734
+ {
17735
+ context.onError(
17736
+ createCompilerError(34, loc)
17737
+ );
17738
+ return {
17739
+ props: [
17740
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
17741
+ ]
17742
+ };
17743
+ }
17744
+ }
17745
+ if (arg.type !== 4) {
17746
+ arg.children.unshift(`(`);
17747
+ arg.children.push(`) || ""`);
17748
+ } else if (!arg.isStatic) {
17749
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
17750
+ }
17751
+ if (modifiers.some((mod) => mod.content === "camel")) {
17752
+ if (arg.type === 4) {
17753
+ if (arg.isStatic) {
17754
+ arg.content = camelize(arg.content);
17755
+ } else {
17756
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
17757
+ }
17758
+ } else {
17759
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
17760
+ arg.children.push(`)`);
17761
+ }
17762
+ }
17763
+ if (!context.inSSR) {
17764
+ if (modifiers.some((mod) => mod.content === "prop")) {
17765
+ injectPrefix(arg, ".");
17766
+ }
17767
+ if (modifiers.some((mod) => mod.content === "attr")) {
17768
+ injectPrefix(arg, "^");
17769
+ }
17770
+ }
17771
+ return {
17772
+ props: [createObjectProperty(arg, exp)]
17773
+ };
17774
+ };
17775
+ const injectPrefix = (arg, prefix) => {
17776
+ if (arg.type === 4) {
17777
+ if (arg.isStatic) {
17778
+ arg.content = prefix + arg.content;
17779
+ } else {
17780
+ arg.content = `\`${prefix}\${${arg.content}}\``;
17781
+ }
17782
+ } else {
17783
+ arg.children.unshift(`'${prefix}' + (`);
17784
+ arg.children.push(`)`);
17785
+ }
17786
+ };
17787
+
17722
17788
  const transformText = (node, context) => {
17723
17789
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
17724
17790
  return () => {
@@ -18069,9 +18135,35 @@ const transformMemo = (node, context) => {
18069
18135
  }
18070
18136
  };
18071
18137
 
18138
+ const transformVBindShorthand = (node, context) => {
18139
+ if (node.type === 1) {
18140
+ for (const prop of node.props) {
18141
+ if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
18142
+ const arg = prop.arg;
18143
+ if (arg.type !== 4 || !arg.isStatic) {
18144
+ context.onError(
18145
+ createCompilerError(
18146
+ 52,
18147
+ arg.loc
18148
+ )
18149
+ );
18150
+ prop.exp = createSimpleExpression("", true, arg.loc);
18151
+ } else {
18152
+ const propName = camelize(arg.content);
18153
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
18154
+ propName[0] === "-") {
18155
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
18156
+ }
18157
+ }
18158
+ }
18159
+ }
18160
+ }
18161
+ };
18162
+
18072
18163
  function getBaseTransformPreset(prefixIdentifiers) {
18073
18164
  return [
18074
18165
  [
18166
+ transformVBindShorthand,
18075
18167
  transformOnce,
18076
18168
  transformIf,
18077
18169
  transformMemo,
@@ -18556,7 +18648,7 @@ const getCachedNode = (node) => {
18556
18648
  return node.codegenNode;
18557
18649
  }
18558
18650
  };
18559
- const dataAriaRE = /^(data|aria)-/;
18651
+ const dataAriaRE = /^(?:data|aria)-/;
18560
18652
  const isStringifiableAttr = (name, ns) => {
18561
18653
  return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : ns === 2 ? isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
18562
18654
  };
@@ -18567,6 +18659,9 @@ function analyzeNode(node) {
18567
18659
  if (node.type === 1 && isNonStringifiable(node.tag)) {
18568
18660
  return false;
18569
18661
  }
18662
+ if (node.type === 1 && findDir(node, "once", true)) {
18663
+ return false;
18664
+ }
18570
18665
  if (node.type === 12) {
18571
18666
  return [1, 0];
18572
18667
  }