@vue/compat 3.5.21 → 3.5.23

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.21
2
+ * @vue/compat v3.5.23
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1219,7 +1219,7 @@ function iterator(self, method, wrapValue) {
1219
1219
  iter._next = iter.next;
1220
1220
  iter.next = () => {
1221
1221
  const result = iter._next();
1222
- if (result.value) {
1222
+ if (!result.done) {
1223
1223
  result.value = wrapValue(result.value);
1224
1224
  }
1225
1225
  return result;
@@ -1346,7 +1346,8 @@ class BaseReactiveHandler {
1346
1346
  return res;
1347
1347
  }
1348
1348
  if (isRef(res)) {
1349
- return targetIsArray && isIntegerKey(key) ? res : res.value;
1349
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
1350
+ return isReadonly2 && isObject(value) ? readonly(value) : value;
1350
1351
  }
1351
1352
  if (isObject(res)) {
1352
1353
  return isReadonly2 ? readonly(res) : reactive(res);
@@ -2707,14 +2708,11 @@ function checkRecursiveUpdates(seen, fn) {
2707
2708
  let isHmrUpdating = false;
2708
2709
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
2709
2710
  if (!!(process.env.NODE_ENV !== "production")) {
2710
- const g = getGlobalThis();
2711
- if (!g.__VUE_HMR_RUNTIME__) {
2712
- g.__VUE_HMR_RUNTIME__ = {
2713
- createRecord: tryWrap(createRecord),
2714
- rerender: tryWrap(rerender),
2715
- reload: tryWrap(reload)
2716
- };
2717
- }
2711
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
2712
+ createRecord: tryWrap(createRecord),
2713
+ rerender: tryWrap(rerender),
2714
+ reload: tryWrap(reload)
2715
+ };
2718
2716
  }
2719
2717
  const map = /* @__PURE__ */ new Map();
2720
2718
  function registerHMR(instance) {
@@ -3612,9 +3610,6 @@ const TeleportImpl = {
3612
3610
  insert(mainAnchor, container, anchor);
3613
3611
  const mount = (container2, anchor2) => {
3614
3612
  if (shapeFlag & 16) {
3615
- if (parentComponent && parentComponent.isCE) {
3616
- parentComponent.ce._teleportTarget = container2;
3617
- }
3618
3613
  mountChildren(
3619
3614
  children,
3620
3615
  container2,
@@ -3636,6 +3631,9 @@ const TeleportImpl = {
3636
3631
  } else if (namespace !== "mathml" && isTargetMathML(target)) {
3637
3632
  namespace = "mathml";
3638
3633
  }
3634
+ if (parentComponent && parentComponent.isCE) {
3635
+ (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
3636
+ }
3639
3637
  if (!disabled) {
3640
3638
  mount(target, targetAnchor);
3641
3639
  updateCssVars(n2, false);
@@ -4746,14 +4744,16 @@ Server rendered element contains more child nodes than client vdom.`
4746
4744
  if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
4747
4745
  clientText = clientText.slice(1);
4748
4746
  }
4749
- if (el.textContent !== clientText) {
4747
+ const { textContent } = el;
4748
+ if (textContent !== clientText && // innerHTML normalize \r\n or \r into a single \n in the DOM
4749
+ textContent !== clientText.replace(/\r\n|\r/g, "\n")) {
4750
4750
  if (!isMismatchAllowed(el, 0 /* TEXT */)) {
4751
4751
  (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
4752
4752
  `Hydration text content mismatch on`,
4753
4753
  el,
4754
4754
  `
4755
- - rendered on server: ${el.textContent}
4756
- - expected on client: ${vnode.children}`
4755
+ - rendered on server: ${textContent}
4756
+ - expected on client: ${clientText}`
4757
4757
  );
4758
4758
  logMismatchError();
4759
4759
  }
@@ -5359,7 +5359,10 @@ function defineAsyncComponent(source) {
5359
5359
  error: error.value
5360
5360
  });
5361
5361
  } else if (loadingComponent && !delayed.value) {
5362
- return createVNode(loadingComponent);
5362
+ return createInnerComp(
5363
+ loadingComponent,
5364
+ instance
5365
+ );
5363
5366
  }
5364
5367
  };
5365
5368
  }
@@ -6107,12 +6110,13 @@ function createSlots(slots, dynamicSlots) {
6107
6110
 
6108
6111
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6109
6112
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6113
+ const hasProps = Object.keys(props).length > 0;
6110
6114
  if (name !== "default") props.name = name;
6111
6115
  return openBlock(), createBlock(
6112
6116
  Fragment,
6113
6117
  null,
6114
6118
  [createVNode("slot", props, fallback && fallback())],
6115
- 64
6119
+ hasProps ? -2 : 64
6116
6120
  );
6117
6121
  }
6118
6122
  let slot = slots[name];
@@ -6457,7 +6461,7 @@ const PublicInstanceProxyHandlers = {
6457
6461
  } else if (hasSetupBinding(setupState, key)) {
6458
6462
  accessCache[key] = 1 /* SETUP */;
6459
6463
  return setupState[key];
6460
- } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
6464
+ } else if (__VUE_OPTIONS_API__ && data !== EMPTY_OBJ && hasOwn(data, key)) {
6461
6465
  accessCache[key] = 2 /* DATA */;
6462
6466
  return data[key];
6463
6467
  } else if (
@@ -6529,7 +6533,7 @@ const PublicInstanceProxyHandlers = {
6529
6533
  } else if (!!(process.env.NODE_ENV !== "production") && setupState.__isScriptSetup && hasOwn(setupState, key)) {
6530
6534
  warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
6531
6535
  return false;
6532
- } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
6536
+ } else if (__VUE_OPTIONS_API__ && data !== EMPTY_OBJ && hasOwn(data, key)) {
6533
6537
  data[key] = value;
6534
6538
  return true;
6535
6539
  } else if (hasOwn(instance.props, key)) {
@@ -6558,7 +6562,7 @@ const PublicInstanceProxyHandlers = {
6558
6562
  _: { data, setupState, accessCache, ctx, appContext, propsOptions, type }
6559
6563
  }, key) {
6560
6564
  let normalizedProps, cssModules;
6561
- return !!(accessCache[key] || data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
6565
+ return !!(accessCache[key] || __VUE_OPTIONS_API__ && data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
6562
6566
  },
6563
6567
  defineProperty(target, key, descriptor) {
6564
6568
  if (descriptor.get != null) {
@@ -7305,7 +7309,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7305
7309
  return vm;
7306
7310
  }
7307
7311
  }
7308
- Vue.version = `2.6.14-compat:${"3.5.21"}`;
7312
+ Vue.version = `2.6.14-compat:${"3.5.23"}`;
7309
7313
  Vue.config = singletonApp.config;
7310
7314
  Vue.use = (plugin, ...options) => {
7311
7315
  if (plugin && isFunction(plugin.install)) {
@@ -8780,15 +8784,25 @@ function baseCreateRenderer(options, createHydrationFns) {
8780
8784
  optimized
8781
8785
  );
8782
8786
  } else {
8783
- patchElement(
8784
- n1,
8785
- n2,
8786
- parentComponent,
8787
- parentSuspense,
8788
- namespace,
8789
- slotScopeIds,
8790
- optimized
8791
- );
8787
+ const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
8788
+ try {
8789
+ if (customElement) {
8790
+ customElement._beginPatch();
8791
+ }
8792
+ patchElement(
8793
+ n1,
8794
+ n2,
8795
+ parentComponent,
8796
+ parentSuspense,
8797
+ namespace,
8798
+ slotScopeIds,
8799
+ optimized
8800
+ );
8801
+ } finally {
8802
+ if (customElement) {
8803
+ customElement._endPatch();
8804
+ }
8805
+ }
8792
8806
  }
8793
8807
  };
8794
8808
  const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
@@ -11104,7 +11118,8 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
11104
11118
  pendingId,
11105
11119
  effects,
11106
11120
  parentComponent: parentComponent2,
11107
- container: container2
11121
+ container: container2,
11122
+ isInFallback
11108
11123
  } = suspense;
11109
11124
  let delayEnter = false;
11110
11125
  if (suspense.isHydrating) {
@@ -11121,6 +11136,9 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
11121
11136
  0
11122
11137
  );
11123
11138
  queuePostFlushCb(effects);
11139
+ if (isInFallback && vnode2.ssFallback) {
11140
+ vnode2.ssFallback.el = null;
11141
+ }
11124
11142
  }
11125
11143
  };
11126
11144
  }
@@ -11129,6 +11147,9 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
11129
11147
  anchor = next(activeBranch);
11130
11148
  }
11131
11149
  unmount(activeBranch, parentComponent2, suspense, true);
11150
+ if (!delayEnter && isInFallback && vnode2.ssFallback) {
11151
+ vnode2.ssFallback.el = null;
11152
+ }
11132
11153
  }
11133
11154
  if (!delayEnter) {
11134
11155
  move(pendingBranch, container2, anchor, 0);
@@ -11247,6 +11268,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
11247
11268
  optimized2
11248
11269
  );
11249
11270
  if (placeholder) {
11271
+ vnode2.placeholder = null;
11250
11272
  remove(placeholder);
11251
11273
  }
11252
11274
  updateHOCHostEl(instance, vnode2.el);
@@ -12284,31 +12306,28 @@ const computed = (getterOrOptions, debugOptions) => {
12284
12306
  };
12285
12307
 
12286
12308
  function h(type, propsOrChildren, children) {
12287
- const doCreateVNode = (type2, props, children2) => {
12309
+ try {
12288
12310
  setBlockTracking(-1);
12289
- try {
12290
- return createVNode(type2, props, children2);
12291
- } finally {
12292
- setBlockTracking(1);
12293
- }
12294
- };
12295
- const l = arguments.length;
12296
- if (l === 2) {
12297
- if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
12298
- if (isVNode(propsOrChildren)) {
12299
- return doCreateVNode(type, null, [propsOrChildren]);
12311
+ const l = arguments.length;
12312
+ if (l === 2) {
12313
+ if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
12314
+ if (isVNode(propsOrChildren)) {
12315
+ return createVNode(type, null, [propsOrChildren]);
12316
+ }
12317
+ return createVNode(type, propsOrChildren);
12318
+ } else {
12319
+ return createVNode(type, null, propsOrChildren);
12300
12320
  }
12301
- return doCreateVNode(type, propsOrChildren);
12302
12321
  } else {
12303
- return doCreateVNode(type, null, propsOrChildren);
12304
- }
12305
- } else {
12306
- if (l > 3) {
12307
- children = Array.prototype.slice.call(arguments, 2);
12308
- } else if (l === 3 && isVNode(children)) {
12309
- children = [children];
12322
+ if (l > 3) {
12323
+ children = Array.prototype.slice.call(arguments, 2);
12324
+ } else if (l === 3 && isVNode(children)) {
12325
+ children = [children];
12326
+ }
12327
+ return createVNode(type, propsOrChildren, children);
12310
12328
  }
12311
- return doCreateVNode(type, propsOrChildren, children);
12329
+ } finally {
12330
+ setBlockTracking(1);
12312
12331
  }
12313
12332
  }
12314
12333
 
@@ -12518,7 +12537,7 @@ function isMemoSame(cached, memo) {
12518
12537
  return true;
12519
12538
  }
12520
12539
 
12521
- const version = "3.5.21";
12540
+ const version = "3.5.23";
12522
12541
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12523
12542
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12524
12543
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -12788,11 +12807,11 @@ function resolveTransitionProps(rawProps) {
12788
12807
  addTransitionClass(el, legacyLeaveFromClass);
12789
12808
  }
12790
12809
  if (!el._enterCancelled) {
12791
- forceReflow();
12810
+ forceReflow(el);
12792
12811
  addTransitionClass(el, leaveActiveClass);
12793
12812
  } else {
12794
12813
  addTransitionClass(el, leaveActiveClass);
12795
- forceReflow();
12814
+ forceReflow(el);
12796
12815
  }
12797
12816
  nextFrame(() => {
12798
12817
  if (!el._isLeaving) {
@@ -12941,8 +12960,9 @@ function toMs(s) {
12941
12960
  if (s === "auto") return 0;
12942
12961
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
12943
12962
  }
12944
- function forceReflow() {
12945
- return document.body.offsetHeight;
12963
+ function forceReflow(el) {
12964
+ const targetDocument = el ? el.ownerDocument : document;
12965
+ return targetDocument.body.offsetHeight;
12946
12966
  }
12947
12967
 
12948
12968
  function patchClass(el, value, isSVG) {
@@ -13427,6 +13447,9 @@ function shouldSetAsProp(el, key, value, isSVG) {
13427
13447
  if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
13428
13448
  return false;
13429
13449
  }
13450
+ if (key === "sandbox" && el.tagName === "IFRAME") {
13451
+ return false;
13452
+ }
13430
13453
  if (key === "form") {
13431
13454
  return false;
13432
13455
  }
@@ -13487,6 +13510,8 @@ class VueElement extends BaseClass {
13487
13510
  this._nonce = this._def.nonce;
13488
13511
  this._connected = false;
13489
13512
  this._resolved = false;
13513
+ this._patching = false;
13514
+ this._dirty = false;
13490
13515
  this._numberProps = null;
13491
13516
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13492
13517
  this._ob = null;
@@ -13499,7 +13524,11 @@ class VueElement extends BaseClass {
13499
13524
  );
13500
13525
  }
13501
13526
  if (_def.shadowRoot !== false) {
13502
- this.attachShadow({ mode: "open" });
13527
+ this.attachShadow(
13528
+ extend({}, _def.shadowRootOptions, {
13529
+ mode: "open"
13530
+ })
13531
+ );
13503
13532
  this._root = this.shadowRoot;
13504
13533
  } else {
13505
13534
  this._root = this;
@@ -13559,9 +13588,18 @@ class VueElement extends BaseClass {
13559
13588
  this._app && this._app.unmount();
13560
13589
  if (this._instance) this._instance.ce = void 0;
13561
13590
  this._app = this._instance = null;
13591
+ if (this._teleportTargets) {
13592
+ this._teleportTargets.clear();
13593
+ this._teleportTargets = void 0;
13594
+ }
13562
13595
  }
13563
13596
  });
13564
13597
  }
13598
+ _processMutations(mutations) {
13599
+ for (const m of mutations) {
13600
+ this._setAttr(m.attributeName);
13601
+ }
13602
+ }
13565
13603
  /**
13566
13604
  * resolve inner component definition (handle possible async component)
13567
13605
  */
@@ -13572,11 +13610,7 @@ class VueElement extends BaseClass {
13572
13610
  for (let i = 0; i < this.attributes.length; i++) {
13573
13611
  this._setAttr(this.attributes[i].name);
13574
13612
  }
13575
- this._ob = new MutationObserver((mutations) => {
13576
- for (const m of mutations) {
13577
- this._setAttr(m.attributeName);
13578
- }
13579
- });
13613
+ this._ob = new MutationObserver(this._processMutations.bind(this));
13580
13614
  this._ob.observe(this, { attributes: true });
13581
13615
  const resolve = (def, isAsync = false) => {
13582
13616
  this._resolved = true;
@@ -13653,7 +13687,7 @@ class VueElement extends BaseClass {
13653
13687
  return this._getProp(key);
13654
13688
  },
13655
13689
  set(val) {
13656
- this._setProp(key, val, true, true);
13690
+ this._setProp(key, val, true, !this._patching);
13657
13691
  }
13658
13692
  });
13659
13693
  }
@@ -13679,6 +13713,7 @@ class VueElement extends BaseClass {
13679
13713
  */
13680
13714
  _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
13681
13715
  if (val !== this._props[key]) {
13716
+ this._dirty = true;
13682
13717
  if (val === REMOVAL) {
13683
13718
  delete this._props[key];
13684
13719
  } else {
@@ -13692,7 +13727,10 @@ class VueElement extends BaseClass {
13692
13727
  }
13693
13728
  if (shouldReflect) {
13694
13729
  const ob = this._ob;
13695
- ob && ob.disconnect();
13730
+ if (ob) {
13731
+ this._processMutations(ob.takeRecords());
13732
+ ob.disconnect();
13733
+ }
13696
13734
  if (val === true) {
13697
13735
  this.setAttribute(hyphenate(key), "");
13698
13736
  } else if (typeof val === "string" || typeof val === "number") {
@@ -13796,7 +13834,7 @@ class VueElement extends BaseClass {
13796
13834
  * Only called when shadowRoot is false
13797
13835
  */
13798
13836
  _renderSlots() {
13799
- const outlets = (this._teleportTarget || this).querySelectorAll("slot");
13837
+ const outlets = this._getSlots();
13800
13838
  const scopeId = this._instance.type.__scopeId;
13801
13839
  for (let i = 0; i < outlets.length; i++) {
13802
13840
  const o = outlets[i];
@@ -13822,12 +13860,45 @@ class VueElement extends BaseClass {
13822
13860
  parent.removeChild(o);
13823
13861
  }
13824
13862
  }
13863
+ /**
13864
+ * @internal
13865
+ */
13866
+ _getSlots() {
13867
+ const roots = [this];
13868
+ if (this._teleportTargets) {
13869
+ roots.push(...this._teleportTargets);
13870
+ }
13871
+ const slots = /* @__PURE__ */ new Set();
13872
+ for (const root of roots) {
13873
+ const found = root.querySelectorAll("slot");
13874
+ for (let i = 0; i < found.length; i++) {
13875
+ slots.add(found[i]);
13876
+ }
13877
+ }
13878
+ return Array.from(slots);
13879
+ }
13825
13880
  /**
13826
13881
  * @internal
13827
13882
  */
13828
13883
  _injectChildStyle(comp) {
13829
13884
  this._applyStyles(comp.styles, comp);
13830
13885
  }
13886
+ /**
13887
+ * @internal
13888
+ */
13889
+ _beginPatch() {
13890
+ this._patching = true;
13891
+ this._dirty = false;
13892
+ }
13893
+ /**
13894
+ * @internal
13895
+ */
13896
+ _endPatch() {
13897
+ this._patching = false;
13898
+ if (this._dirty && this._instance) {
13899
+ this._update();
13900
+ }
13901
+ }
13831
13902
  /**
13832
13903
  * @internal
13833
13904
  */
@@ -13926,7 +13997,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
13926
13997
  prevChildren.forEach(callPendingCbs);
13927
13998
  prevChildren.forEach(recordPosition);
13928
13999
  const movedChildren = prevChildren.filter(applyTranslation);
13929
- forceReflow();
14000
+ forceReflow(instance.vnode.el);
13930
14001
  movedChildren.forEach((c) => {
13931
14002
  const el = c.el;
13932
14003
  const style = el.style;
@@ -13971,10 +14042,10 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
13971
14042
  instance
13972
14043
  )
13973
14044
  );
13974
- positionMap.set(
13975
- child,
13976
- child.el.getBoundingClientRect()
13977
- );
14045
+ positionMap.set(child, {
14046
+ left: child.el.offsetLeft,
14047
+ top: child.el.offsetTop
14048
+ });
13978
14049
  }
13979
14050
  }
13980
14051
  }
@@ -14005,7 +14076,10 @@ function callPendingCbs(c) {
14005
14076
  }
14006
14077
  }
14007
14078
  function recordPosition(c) {
14008
- newPositionMap.set(c, c.el.getBoundingClientRect());
14079
+ newPositionMap.set(c, {
14080
+ left: c.el.offsetLeft,
14081
+ top: c.el.offsetTop
14082
+ });
14009
14083
  }
14010
14084
  function applyTranslation(c) {
14011
14085
  const oldPos = positionMap.get(c);
@@ -14051,24 +14125,22 @@ function onCompositionEnd(e) {
14051
14125
  }
14052
14126
  }
14053
14127
  const assignKey = Symbol("_assign");
14128
+ function castValue(value, trim, number) {
14129
+ if (trim) value = value.trim();
14130
+ if (number) value = looseToNumber(value);
14131
+ return value;
14132
+ }
14054
14133
  const vModelText = {
14055
14134
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
14056
14135
  el[assignKey] = getModelAssigner(vnode);
14057
14136
  const castToNumber = number || vnode.props && vnode.props.type === "number";
14058
14137
  addEventListener(el, lazy ? "change" : "input", (e) => {
14059
14138
  if (e.target.composing) return;
14060
- let domValue = el.value;
14061
- if (trim) {
14062
- domValue = domValue.trim();
14063
- }
14064
- if (castToNumber) {
14065
- domValue = looseToNumber(domValue);
14066
- }
14067
- el[assignKey](domValue);
14139
+ el[assignKey](castValue(el.value, trim, castToNumber));
14068
14140
  });
14069
- if (trim) {
14141
+ if (trim || castToNumber) {
14070
14142
  addEventListener(el, "change", () => {
14071
- el.value = el.value.trim();
14143
+ el.value = castValue(el.value, trim, castToNumber);
14072
14144
  });
14073
14145
  }
14074
14146
  if (!lazy) {
@@ -18400,80 +18472,6 @@ function getParentCondition(node) {
18400
18472
  }
18401
18473
  }
18402
18474
 
18403
- const transformBind = (dir, _node, context) => {
18404
- const { modifiers, loc } = dir;
18405
- const arg = dir.arg;
18406
- let { exp } = dir;
18407
- if (exp && exp.type === 4 && !exp.content.trim()) {
18408
- {
18409
- exp = void 0;
18410
- }
18411
- }
18412
- if (!exp) {
18413
- if (arg.type !== 4 || !arg.isStatic) {
18414
- context.onError(
18415
- createCompilerError(
18416
- 52,
18417
- arg.loc
18418
- )
18419
- );
18420
- return {
18421
- props: [
18422
- createObjectProperty(arg, createSimpleExpression("", true, loc))
18423
- ]
18424
- };
18425
- }
18426
- transformBindShorthand(dir);
18427
- exp = dir.exp;
18428
- }
18429
- if (arg.type !== 4) {
18430
- arg.children.unshift(`(`);
18431
- arg.children.push(`) || ""`);
18432
- } else if (!arg.isStatic) {
18433
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
18434
- }
18435
- if (modifiers.some((mod) => mod.content === "camel")) {
18436
- if (arg.type === 4) {
18437
- if (arg.isStatic) {
18438
- arg.content = camelize(arg.content);
18439
- } else {
18440
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
18441
- }
18442
- } else {
18443
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
18444
- arg.children.push(`)`);
18445
- }
18446
- }
18447
- if (!context.inSSR) {
18448
- if (modifiers.some((mod) => mod.content === "prop")) {
18449
- injectPrefix(arg, ".");
18450
- }
18451
- if (modifiers.some((mod) => mod.content === "attr")) {
18452
- injectPrefix(arg, "^");
18453
- }
18454
- }
18455
- return {
18456
- props: [createObjectProperty(arg, exp)]
18457
- };
18458
- };
18459
- const transformBindShorthand = (dir, context) => {
18460
- const arg = dir.arg;
18461
- const propName = camelize(arg.content);
18462
- dir.exp = createSimpleExpression(propName, false, arg.loc);
18463
- };
18464
- const injectPrefix = (arg, prefix) => {
18465
- if (arg.type === 4) {
18466
- if (arg.isStatic) {
18467
- arg.content = prefix + arg.content;
18468
- } else {
18469
- arg.content = `\`${prefix}\${${arg.content}}\``;
18470
- }
18471
- } else {
18472
- arg.children.unshift(`'${prefix}' + (`);
18473
- arg.children.push(`)`);
18474
- }
18475
- };
18476
-
18477
18475
  const transformFor = createStructuralDirectiveTransform(
18478
18476
  "for",
18479
18477
  (node, dir, context) => {
@@ -18485,10 +18483,7 @@ const transformFor = createStructuralDirectiveTransform(
18485
18483
  const isTemplate = isTemplateNode(node);
18486
18484
  const memo = findDir(node, "memo");
18487
18485
  const keyProp = findProp(node, `key`, false, true);
18488
- const isDirKey = keyProp && keyProp.type === 7;
18489
- if (isDirKey && !keyProp.exp) {
18490
- transformBindShorthand(keyProp);
18491
- }
18486
+ keyProp && keyProp.type === 7;
18492
18487
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
18493
18488
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
18494
18489
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -19641,6 +19636,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
19641
19636
  return ret;
19642
19637
  };
19643
19638
 
19639
+ const transformBind = (dir, _node, context) => {
19640
+ const { modifiers, loc } = dir;
19641
+ const arg = dir.arg;
19642
+ let { exp } = dir;
19643
+ if (exp && exp.type === 4 && !exp.content.trim()) {
19644
+ {
19645
+ exp = void 0;
19646
+ }
19647
+ }
19648
+ if (arg.type !== 4) {
19649
+ arg.children.unshift(`(`);
19650
+ arg.children.push(`) || ""`);
19651
+ } else if (!arg.isStatic) {
19652
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
19653
+ }
19654
+ if (modifiers.some((mod) => mod.content === "camel")) {
19655
+ if (arg.type === 4) {
19656
+ if (arg.isStatic) {
19657
+ arg.content = camelize(arg.content);
19658
+ } else {
19659
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
19660
+ }
19661
+ } else {
19662
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
19663
+ arg.children.push(`)`);
19664
+ }
19665
+ }
19666
+ if (!context.inSSR) {
19667
+ if (modifiers.some((mod) => mod.content === "prop")) {
19668
+ injectPrefix(arg, ".");
19669
+ }
19670
+ if (modifiers.some((mod) => mod.content === "attr")) {
19671
+ injectPrefix(arg, "^");
19672
+ }
19673
+ }
19674
+ return {
19675
+ props: [createObjectProperty(arg, exp)]
19676
+ };
19677
+ };
19678
+ const injectPrefix = (arg, prefix) => {
19679
+ if (arg.type === 4) {
19680
+ if (arg.isStatic) {
19681
+ arg.content = prefix + arg.content;
19682
+ } else {
19683
+ arg.content = `\`${prefix}\${${arg.content}}\``;
19684
+ }
19685
+ } else {
19686
+ arg.children.unshift(`'${prefix}' + (`);
19687
+ arg.children.push(`)`);
19688
+ }
19689
+ };
19690
+
19644
19691
  const transformText = (node, context) => {
19645
19692
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
19646
19693
  return () => {
@@ -19971,9 +20018,36 @@ const transformMemo = (node, context) => {
19971
20018
  }
19972
20019
  };
19973
20020
 
20021
+ const transformVBindShorthand = (node, context) => {
20022
+ if (node.type === 1) {
20023
+ for (const prop of node.props) {
20024
+ if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
20025
+ prop.exp.type === 4 && !prop.exp.content.trim()) && prop.arg) {
20026
+ const arg = prop.arg;
20027
+ if (arg.type !== 4 || !arg.isStatic) {
20028
+ context.onError(
20029
+ createCompilerError(
20030
+ 52,
20031
+ arg.loc
20032
+ )
20033
+ );
20034
+ prop.exp = createSimpleExpression("", true, arg.loc);
20035
+ } else {
20036
+ const propName = camelize(arg.content);
20037
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
20038
+ propName[0] === "-") {
20039
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
20040
+ }
20041
+ }
20042
+ }
20043
+ }
20044
+ }
20045
+ };
20046
+
19974
20047
  function getBaseTransformPreset(prefixIdentifiers) {
19975
20048
  return [
19976
20049
  [
20050
+ transformVBindShorthand,
19977
20051
  transformOnce,
19978
20052
  transformIf,
19979
20053
  transformMemo,