@vue/compiler-core 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/compiler-core v3.5.21
2
+ * @vue/compiler-core v3.5.23
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1574,16 +1574,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
1574
1574
  (id) => markScopeIdentifier(node, id, knownIds)
1575
1575
  );
1576
1576
  }
1577
+ } else if (node.type === "SwitchStatement") {
1578
+ if (node.scopeIds) {
1579
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1580
+ } else {
1581
+ walkSwitchStatement(
1582
+ node,
1583
+ false,
1584
+ (id) => markScopeIdentifier(node, id, knownIds)
1585
+ );
1586
+ }
1577
1587
  } else if (node.type === "CatchClause" && node.param) {
1578
- for (const id of extractIdentifiers(node.param)) {
1579
- markScopeIdentifier(node, id, knownIds);
1588
+ if (node.scopeIds) {
1589
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1590
+ } else {
1591
+ for (const id of extractIdentifiers(node.param)) {
1592
+ markScopeIdentifier(node, id, knownIds);
1593
+ }
1580
1594
  }
1581
1595
  } else if (isForStatement(node)) {
1582
- walkForStatement(
1583
- node,
1584
- false,
1585
- (id) => markScopeIdentifier(node, id, knownIds)
1586
- );
1596
+ if (node.scopeIds) {
1597
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1598
+ } else {
1599
+ walkForStatement(
1600
+ node,
1601
+ false,
1602
+ (id) => markScopeIdentifier(node, id, knownIds)
1603
+ );
1604
+ }
1587
1605
  }
1588
1606
  },
1589
1607
  leave(node, parent) {
@@ -1654,7 +1672,8 @@ function walkFunctionParams(node, onIdent) {
1654
1672
  }
1655
1673
  }
1656
1674
  function walkBlockDeclarations(block, onIdent) {
1657
- for (const stmt of block.body) {
1675
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1676
+ for (const stmt of body) {
1658
1677
  if (stmt.type === "VariableDeclaration") {
1659
1678
  if (stmt.declare) continue;
1660
1679
  for (const decl of stmt.declarations) {
@@ -1667,6 +1686,8 @@ function walkBlockDeclarations(block, onIdent) {
1667
1686
  onIdent(stmt.id);
1668
1687
  } else if (isForStatement(stmt)) {
1669
1688
  walkForStatement(stmt, true, onIdent);
1689
+ } else if (stmt.type === "SwitchStatement") {
1690
+ walkSwitchStatement(stmt, true, onIdent);
1670
1691
  }
1671
1692
  }
1672
1693
  }
@@ -1683,6 +1704,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1683
1704
  }
1684
1705
  }
1685
1706
  }
1707
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1708
+ for (const cs of stmt.cases) {
1709
+ for (const stmt2 of cs.consequent) {
1710
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1711
+ for (const decl of stmt2.declarations) {
1712
+ for (const id of extractIdentifiers(decl.id)) {
1713
+ onIdent(id);
1714
+ }
1715
+ }
1716
+ }
1717
+ }
1718
+ walkBlockDeclarations(cs, onIdent);
1719
+ }
1720
+ }
1686
1721
  function extractIdentifiers(param, nodes = []) {
1687
1722
  switch (param.type) {
1688
1723
  case "Identifier":
@@ -4560,14 +4595,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4560
4595
  knownIds
4561
4596
  );
4562
4597
  const children = [];
4598
+ const isTSNode = TS_NODE_TYPES.includes(ast.type);
4563
4599
  ids.sort((a, b) => a.start - b.start);
4564
4600
  ids.forEach((id, i) => {
4565
4601
  const start = id.start - 1;
4566
4602
  const end = id.end - 1;
4567
4603
  const last = ids[i - 1];
4568
- const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4569
- if (leadingText.length || id.prefix) {
4570
- children.push(leadingText + (id.prefix || ``));
4604
+ if (!(isTSNode && i === 0)) {
4605
+ const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4606
+ if (leadingText.length || id.prefix) {
4607
+ children.push(leadingText + (id.prefix || ``));
4608
+ }
4571
4609
  }
4572
4610
  const source = rawExp.slice(start, end);
4573
4611
  children.push(
@@ -4582,7 +4620,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4582
4620
  id.isConstant ? 3 : 0
4583
4621
  )
4584
4622
  );
4585
- if (i === ids.length - 1 && end < rawExp.length) {
4623
+ if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
4586
4624
  children.push(rawExp.slice(end));
4587
4625
  }
4588
4626
  });
@@ -4838,90 +4876,6 @@ function getParentCondition(node) {
4838
4876
  }
4839
4877
  }
4840
4878
 
4841
- const transformBind = (dir, _node, context) => {
4842
- const { modifiers, loc } = dir;
4843
- const arg = dir.arg;
4844
- let { exp } = dir;
4845
- if (exp && exp.type === 4 && !exp.content.trim()) {
4846
- {
4847
- context.onError(
4848
- createCompilerError(34, loc)
4849
- );
4850
- return {
4851
- props: [
4852
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4853
- ]
4854
- };
4855
- }
4856
- }
4857
- if (!exp) {
4858
- if (arg.type !== 4 || !arg.isStatic) {
4859
- context.onError(
4860
- createCompilerError(
4861
- 52,
4862
- arg.loc
4863
- )
4864
- );
4865
- return {
4866
- props: [
4867
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4868
- ]
4869
- };
4870
- }
4871
- transformBindShorthand(dir, context);
4872
- exp = dir.exp;
4873
- }
4874
- if (arg.type !== 4) {
4875
- arg.children.unshift(`(`);
4876
- arg.children.push(`) || ""`);
4877
- } else if (!arg.isStatic) {
4878
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
4879
- }
4880
- if (modifiers.some((mod) => mod.content === "camel")) {
4881
- if (arg.type === 4) {
4882
- if (arg.isStatic) {
4883
- arg.content = shared.camelize(arg.content);
4884
- } else {
4885
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4886
- }
4887
- } else {
4888
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4889
- arg.children.push(`)`);
4890
- }
4891
- }
4892
- if (!context.inSSR) {
4893
- if (modifiers.some((mod) => mod.content === "prop")) {
4894
- injectPrefix(arg, ".");
4895
- }
4896
- if (modifiers.some((mod) => mod.content === "attr")) {
4897
- injectPrefix(arg, "^");
4898
- }
4899
- }
4900
- return {
4901
- props: [createObjectProperty(arg, exp)]
4902
- };
4903
- };
4904
- const transformBindShorthand = (dir, context) => {
4905
- const arg = dir.arg;
4906
- const propName = shared.camelize(arg.content);
4907
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4908
- {
4909
- dir.exp = processExpression(dir.exp, context);
4910
- }
4911
- };
4912
- const injectPrefix = (arg, prefix) => {
4913
- if (arg.type === 4) {
4914
- if (arg.isStatic) {
4915
- arg.content = prefix + arg.content;
4916
- } else {
4917
- arg.content = `\`${prefix}\${${arg.content}}\``;
4918
- }
4919
- } else {
4920
- arg.children.unshift(`'${prefix}' + (`);
4921
- arg.children.push(`)`);
4922
- }
4923
- };
4924
-
4925
4879
  const transformFor = createStructuralDirectiveTransform(
4926
4880
  "for",
4927
4881
  (node, dir, context) => {
@@ -4934,9 +4888,6 @@ const transformFor = createStructuralDirectiveTransform(
4934
4888
  const memo = findDir(node, "memo");
4935
4889
  const keyProp = findProp(node, `key`, false, true);
4936
4890
  const isDirKey = keyProp && keyProp.type === 7;
4937
- if (isDirKey && !keyProp.exp) {
4938
- transformBindShorthand(keyProp, context);
4939
- }
4940
4891
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4941
4892
  if (memo && keyExp && isDirKey) {
4942
4893
  {
@@ -6252,6 +6203,65 @@ const transformOn = (dir, node, context, augmentor) => {
6252
6203
  return ret;
6253
6204
  };
6254
6205
 
6206
+ const transformBind = (dir, _node, context) => {
6207
+ const { modifiers, loc } = dir;
6208
+ const arg = dir.arg;
6209
+ let { exp } = dir;
6210
+ if (exp && exp.type === 4 && !exp.content.trim()) {
6211
+ {
6212
+ context.onError(
6213
+ createCompilerError(34, loc)
6214
+ );
6215
+ return {
6216
+ props: [
6217
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
6218
+ ]
6219
+ };
6220
+ }
6221
+ }
6222
+ if (arg.type !== 4) {
6223
+ arg.children.unshift(`(`);
6224
+ arg.children.push(`) || ""`);
6225
+ } else if (!arg.isStatic) {
6226
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
6227
+ }
6228
+ if (modifiers.some((mod) => mod.content === "camel")) {
6229
+ if (arg.type === 4) {
6230
+ if (arg.isStatic) {
6231
+ arg.content = shared.camelize(arg.content);
6232
+ } else {
6233
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
6234
+ }
6235
+ } else {
6236
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
6237
+ arg.children.push(`)`);
6238
+ }
6239
+ }
6240
+ if (!context.inSSR) {
6241
+ if (modifiers.some((mod) => mod.content === "prop")) {
6242
+ injectPrefix(arg, ".");
6243
+ }
6244
+ if (modifiers.some((mod) => mod.content === "attr")) {
6245
+ injectPrefix(arg, "^");
6246
+ }
6247
+ }
6248
+ return {
6249
+ props: [createObjectProperty(arg, exp)]
6250
+ };
6251
+ };
6252
+ const injectPrefix = (arg, prefix) => {
6253
+ if (arg.type === 4) {
6254
+ if (arg.isStatic) {
6255
+ arg.content = prefix + arg.content;
6256
+ } else {
6257
+ arg.content = `\`${prefix}\${${arg.content}}\``;
6258
+ }
6259
+ } else {
6260
+ arg.children.unshift(`'${prefix}' + (`);
6261
+ arg.children.push(`)`);
6262
+ }
6263
+ };
6264
+
6255
6265
  const transformText = (node, context) => {
6256
6266
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
6257
6267
  return () => {
@@ -6607,9 +6617,36 @@ const transformMemo = (node, context) => {
6607
6617
  }
6608
6618
  };
6609
6619
 
6620
+ const transformVBindShorthand = (node, context) => {
6621
+ if (node.type === 1) {
6622
+ for (const prop of node.props) {
6623
+ if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
6624
+ false) && prop.arg) {
6625
+ const arg = prop.arg;
6626
+ if (arg.type !== 4 || !arg.isStatic) {
6627
+ context.onError(
6628
+ createCompilerError(
6629
+ 52,
6630
+ arg.loc
6631
+ )
6632
+ );
6633
+ prop.exp = createSimpleExpression("", true, arg.loc);
6634
+ } else {
6635
+ const propName = shared.camelize(arg.content);
6636
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
6637
+ propName[0] === "-") {
6638
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
6639
+ }
6640
+ }
6641
+ }
6642
+ }
6643
+ }
6644
+ };
6645
+
6610
6646
  function getBaseTransformPreset(prefixIdentifiers) {
6611
6647
  return [
6612
6648
  [
6649
+ transformVBindShorthand,
6613
6650
  transformOnce,
6614
6651
  transformIf,
6615
6652
  transformMemo,
@@ -6821,8 +6858,10 @@ exports.transformElement = transformElement;
6821
6858
  exports.transformExpression = transformExpression;
6822
6859
  exports.transformModel = transformModel;
6823
6860
  exports.transformOn = transformOn;
6861
+ exports.transformVBindShorthand = transformVBindShorthand;
6824
6862
  exports.traverseNode = traverseNode;
6825
6863
  exports.unwrapTSNode = unwrapTSNode;
6864
+ exports.validFirstIdentCharRE = validFirstIdentCharRE;
6826
6865
  exports.walkBlockDeclarations = walkBlockDeclarations;
6827
6866
  exports.walkFunctionParams = walkFunctionParams;
6828
6867
  exports.walkIdentifiers = walkIdentifiers;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.21
2
+ * @vue/compiler-core v3.5.23
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1570,16 +1570,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
1570
1570
  (id) => markScopeIdentifier(node, id, knownIds)
1571
1571
  );
1572
1572
  }
1573
+ } else if (node.type === "SwitchStatement") {
1574
+ if (node.scopeIds) {
1575
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1576
+ } else {
1577
+ walkSwitchStatement(
1578
+ node,
1579
+ false,
1580
+ (id) => markScopeIdentifier(node, id, knownIds)
1581
+ );
1582
+ }
1573
1583
  } else if (node.type === "CatchClause" && node.param) {
1574
- for (const id of extractIdentifiers(node.param)) {
1575
- markScopeIdentifier(node, id, knownIds);
1584
+ if (node.scopeIds) {
1585
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1586
+ } else {
1587
+ for (const id of extractIdentifiers(node.param)) {
1588
+ markScopeIdentifier(node, id, knownIds);
1589
+ }
1576
1590
  }
1577
1591
  } else if (isForStatement(node)) {
1578
- walkForStatement(
1579
- node,
1580
- false,
1581
- (id) => markScopeIdentifier(node, id, knownIds)
1582
- );
1592
+ if (node.scopeIds) {
1593
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
1594
+ } else {
1595
+ walkForStatement(
1596
+ node,
1597
+ false,
1598
+ (id) => markScopeIdentifier(node, id, knownIds)
1599
+ );
1600
+ }
1583
1601
  }
1584
1602
  },
1585
1603
  leave(node, parent) {
@@ -1650,7 +1668,8 @@ function walkFunctionParams(node, onIdent) {
1650
1668
  }
1651
1669
  }
1652
1670
  function walkBlockDeclarations(block, onIdent) {
1653
- for (const stmt of block.body) {
1671
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1672
+ for (const stmt of body) {
1654
1673
  if (stmt.type === "VariableDeclaration") {
1655
1674
  if (stmt.declare) continue;
1656
1675
  for (const decl of stmt.declarations) {
@@ -1663,6 +1682,8 @@ function walkBlockDeclarations(block, onIdent) {
1663
1682
  onIdent(stmt.id);
1664
1683
  } else if (isForStatement(stmt)) {
1665
1684
  walkForStatement(stmt, true, onIdent);
1685
+ } else if (stmt.type === "SwitchStatement") {
1686
+ walkSwitchStatement(stmt, true, onIdent);
1666
1687
  }
1667
1688
  }
1668
1689
  }
@@ -1679,6 +1700,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1679
1700
  }
1680
1701
  }
1681
1702
  }
1703
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1704
+ for (const cs of stmt.cases) {
1705
+ for (const stmt2 of cs.consequent) {
1706
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1707
+ for (const decl of stmt2.declarations) {
1708
+ for (const id of extractIdentifiers(decl.id)) {
1709
+ onIdent(id);
1710
+ }
1711
+ }
1712
+ }
1713
+ }
1714
+ walkBlockDeclarations(cs, onIdent);
1715
+ }
1716
+ }
1682
1717
  function extractIdentifiers(param, nodes = []) {
1683
1718
  switch (param.type) {
1684
1719
  case "Identifier":
@@ -4484,14 +4519,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4484
4519
  knownIds
4485
4520
  );
4486
4521
  const children = [];
4522
+ const isTSNode = TS_NODE_TYPES.includes(ast.type);
4487
4523
  ids.sort((a, b) => a.start - b.start);
4488
4524
  ids.forEach((id, i) => {
4489
4525
  const start = id.start - 1;
4490
4526
  const end = id.end - 1;
4491
4527
  const last = ids[i - 1];
4492
- const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4493
- if (leadingText.length || id.prefix) {
4494
- children.push(leadingText + (id.prefix || ``));
4528
+ if (!(isTSNode && i === 0)) {
4529
+ const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4530
+ if (leadingText.length || id.prefix) {
4531
+ children.push(leadingText + (id.prefix || ``));
4532
+ }
4495
4533
  }
4496
4534
  const source = rawExp.slice(start, end);
4497
4535
  children.push(
@@ -4506,7 +4544,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4506
4544
  id.isConstant ? 3 : 0
4507
4545
  )
4508
4546
  );
4509
- if (i === ids.length - 1 && end < rawExp.length) {
4547
+ if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
4510
4548
  children.push(rawExp.slice(end));
4511
4549
  }
4512
4550
  });
@@ -4753,90 +4791,6 @@ function getParentCondition(node) {
4753
4791
  }
4754
4792
  }
4755
4793
 
4756
- const transformBind = (dir, _node, context) => {
4757
- const { modifiers, loc } = dir;
4758
- const arg = dir.arg;
4759
- let { exp } = dir;
4760
- if (exp && exp.type === 4 && !exp.content.trim()) {
4761
- {
4762
- context.onError(
4763
- createCompilerError(34, loc)
4764
- );
4765
- return {
4766
- props: [
4767
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4768
- ]
4769
- };
4770
- }
4771
- }
4772
- if (!exp) {
4773
- if (arg.type !== 4 || !arg.isStatic) {
4774
- context.onError(
4775
- createCompilerError(
4776
- 52,
4777
- arg.loc
4778
- )
4779
- );
4780
- return {
4781
- props: [
4782
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4783
- ]
4784
- };
4785
- }
4786
- transformBindShorthand(dir, context);
4787
- exp = dir.exp;
4788
- }
4789
- if (arg.type !== 4) {
4790
- arg.children.unshift(`(`);
4791
- arg.children.push(`) || ""`);
4792
- } else if (!arg.isStatic) {
4793
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
4794
- }
4795
- if (modifiers.some((mod) => mod.content === "camel")) {
4796
- if (arg.type === 4) {
4797
- if (arg.isStatic) {
4798
- arg.content = shared.camelize(arg.content);
4799
- } else {
4800
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4801
- }
4802
- } else {
4803
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4804
- arg.children.push(`)`);
4805
- }
4806
- }
4807
- if (!context.inSSR) {
4808
- if (modifiers.some((mod) => mod.content === "prop")) {
4809
- injectPrefix(arg, ".");
4810
- }
4811
- if (modifiers.some((mod) => mod.content === "attr")) {
4812
- injectPrefix(arg, "^");
4813
- }
4814
- }
4815
- return {
4816
- props: [createObjectProperty(arg, exp)]
4817
- };
4818
- };
4819
- const transformBindShorthand = (dir, context) => {
4820
- const arg = dir.arg;
4821
- const propName = shared.camelize(arg.content);
4822
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4823
- {
4824
- dir.exp = processExpression(dir.exp, context);
4825
- }
4826
- };
4827
- const injectPrefix = (arg, prefix) => {
4828
- if (arg.type === 4) {
4829
- if (arg.isStatic) {
4830
- arg.content = prefix + arg.content;
4831
- } else {
4832
- arg.content = `\`${prefix}\${${arg.content}}\``;
4833
- }
4834
- } else {
4835
- arg.children.unshift(`'${prefix}' + (`);
4836
- arg.children.push(`)`);
4837
- }
4838
- };
4839
-
4840
4794
  const transformFor = createStructuralDirectiveTransform(
4841
4795
  "for",
4842
4796
  (node, dir, context) => {
@@ -4849,9 +4803,6 @@ const transformFor = createStructuralDirectiveTransform(
4849
4803
  const memo = findDir(node, "memo");
4850
4804
  const keyProp = findProp(node, `key`, false, true);
4851
4805
  const isDirKey = keyProp && keyProp.type === 7;
4852
- if (isDirKey && !keyProp.exp) {
4853
- transformBindShorthand(keyProp, context);
4854
- }
4855
4806
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4856
4807
  if (memo && keyExp && isDirKey) {
4857
4808
  {
@@ -6134,6 +6085,65 @@ const transformOn = (dir, node, context, augmentor) => {
6134
6085
  return ret;
6135
6086
  };
6136
6087
 
6088
+ const transformBind = (dir, _node, context) => {
6089
+ const { modifiers, loc } = dir;
6090
+ const arg = dir.arg;
6091
+ let { exp } = dir;
6092
+ if (exp && exp.type === 4 && !exp.content.trim()) {
6093
+ {
6094
+ context.onError(
6095
+ createCompilerError(34, loc)
6096
+ );
6097
+ return {
6098
+ props: [
6099
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
6100
+ ]
6101
+ };
6102
+ }
6103
+ }
6104
+ if (arg.type !== 4) {
6105
+ arg.children.unshift(`(`);
6106
+ arg.children.push(`) || ""`);
6107
+ } else if (!arg.isStatic) {
6108
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
6109
+ }
6110
+ if (modifiers.some((mod) => mod.content === "camel")) {
6111
+ if (arg.type === 4) {
6112
+ if (arg.isStatic) {
6113
+ arg.content = shared.camelize(arg.content);
6114
+ } else {
6115
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
6116
+ }
6117
+ } else {
6118
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
6119
+ arg.children.push(`)`);
6120
+ }
6121
+ }
6122
+ if (!context.inSSR) {
6123
+ if (modifiers.some((mod) => mod.content === "prop")) {
6124
+ injectPrefix(arg, ".");
6125
+ }
6126
+ if (modifiers.some((mod) => mod.content === "attr")) {
6127
+ injectPrefix(arg, "^");
6128
+ }
6129
+ }
6130
+ return {
6131
+ props: [createObjectProperty(arg, exp)]
6132
+ };
6133
+ };
6134
+ const injectPrefix = (arg, prefix) => {
6135
+ if (arg.type === 4) {
6136
+ if (arg.isStatic) {
6137
+ arg.content = prefix + arg.content;
6138
+ } else {
6139
+ arg.content = `\`${prefix}\${${arg.content}}\``;
6140
+ }
6141
+ } else {
6142
+ arg.children.unshift(`'${prefix}' + (`);
6143
+ arg.children.push(`)`);
6144
+ }
6145
+ };
6146
+
6137
6147
  const transformText = (node, context) => {
6138
6148
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
6139
6149
  return () => {
@@ -6484,9 +6494,36 @@ const transformMemo = (node, context) => {
6484
6494
  }
6485
6495
  };
6486
6496
 
6497
+ const transformVBindShorthand = (node, context) => {
6498
+ if (node.type === 1) {
6499
+ for (const prop of node.props) {
6500
+ if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
6501
+ false) && prop.arg) {
6502
+ const arg = prop.arg;
6503
+ if (arg.type !== 4 || !arg.isStatic) {
6504
+ context.onError(
6505
+ createCompilerError(
6506
+ 52,
6507
+ arg.loc
6508
+ )
6509
+ );
6510
+ prop.exp = createSimpleExpression("", true, arg.loc);
6511
+ } else {
6512
+ const propName = shared.camelize(arg.content);
6513
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
6514
+ propName[0] === "-") {
6515
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
6516
+ }
6517
+ }
6518
+ }
6519
+ }
6520
+ }
6521
+ };
6522
+
6487
6523
  function getBaseTransformPreset(prefixIdentifiers) {
6488
6524
  return [
6489
6525
  [
6526
+ transformVBindShorthand,
6490
6527
  transformOnce,
6491
6528
  transformIf,
6492
6529
  transformMemo,
@@ -6698,8 +6735,10 @@ exports.transformElement = transformElement;
6698
6735
  exports.transformExpression = transformExpression;
6699
6736
  exports.transformModel = transformModel;
6700
6737
  exports.transformOn = transformOn;
6738
+ exports.transformVBindShorthand = transformVBindShorthand;
6701
6739
  exports.traverseNode = traverseNode;
6702
6740
  exports.unwrapTSNode = unwrapTSNode;
6741
+ exports.validFirstIdentCharRE = validFirstIdentCharRE;
6703
6742
  exports.walkBlockDeclarations = walkBlockDeclarations;
6704
6743
  exports.walkFunctionParams = walkFunctionParams;
6705
6744
  exports.walkIdentifiers = walkIdentifiers;
@@ -1,6 +1,6 @@
1
1
  import { PatchFlags } from '@vue/shared';
2
2
  export { generateCodeFrame } from '@vue/shared';
3
- import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty } from '@babel/types';
3
+ import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, SwitchCase, Program, ObjectProperty } from '@babel/types';
4
4
  import { ParserPlugin } from '@babel/parser';
5
5
 
6
6
  export declare const FRAGMENT: unique symbol;
@@ -1011,6 +1011,7 @@ export declare function baseCompile(source: string | RootNode, options?: Compile
1011
1011
  export declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
1012
1012
  export declare function isCoreComponent(tag: string): symbol | void;
1013
1013
  export declare const isSimpleIdentifier: (name: string) => boolean;
1014
+ export declare const validFirstIdentCharRE: RegExp;
1014
1015
  /**
1015
1016
  * Simple lexer to check if an expression is a member expression. This is
1016
1017
  * lax and only checks validity at the root level (i.e. does not validate exps
@@ -1049,7 +1050,7 @@ export declare function isReferencedIdentifier(id: Identifier, parent: Node$1 |
1049
1050
  export declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
1050
1051
  export declare function isInNewExpression(parentStack: Node$1[]): boolean;
1051
1052
  export declare function walkFunctionParams(node: Function, onIdent: (id: Identifier) => void): void;
1052
- export declare function walkBlockDeclarations(block: BlockStatement$1 | Program, onIdent: (node: Identifier) => void): void;
1053
+ export declare function walkBlockDeclarations(block: BlockStatement$1 | SwitchCase | Program, onIdent: (node: Identifier) => void): void;
1053
1054
  export declare function extractIdentifiers(param: Node$1, nodes?: Identifier[]): Identifier[];
1054
1055
  export declare const isFunctionType: (node: Node$1) => node is Function;
1055
1056
  export declare const isStaticProperty: (node: Node$1) => node is ObjectProperty;
@@ -1082,6 +1083,8 @@ export declare function buildSlots(node: ElementNode, context: TransformContext,
1082
1083
  hasDynamicSlots: boolean;
1083
1084
  };
1084
1085
 
1086
+ export declare const transformVBindShorthand: NodeTransform;
1087
+
1085
1088
  interface SlotOutletProcessResult {
1086
1089
  slotName: string | ExpressionNode;
1087
1090
  slotProps: PropsExpression | undefined;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.21
2
+ * @vue/compiler-core v3.5.23
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1514,7 +1514,8 @@ function walkFunctionParams(node, onIdent) {
1514
1514
  }
1515
1515
  }
1516
1516
  function walkBlockDeclarations(block, onIdent) {
1517
- for (const stmt of block.body) {
1517
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1518
+ for (const stmt of body) {
1518
1519
  if (stmt.type === "VariableDeclaration") {
1519
1520
  if (stmt.declare) continue;
1520
1521
  for (const decl of stmt.declarations) {
@@ -1527,6 +1528,8 @@ function walkBlockDeclarations(block, onIdent) {
1527
1528
  onIdent(stmt.id);
1528
1529
  } else if (isForStatement(stmt)) {
1529
1530
  walkForStatement(stmt, true, onIdent);
1531
+ } else if (stmt.type === "SwitchStatement") {
1532
+ walkSwitchStatement(stmt, true, onIdent);
1530
1533
  }
1531
1534
  }
1532
1535
  }
@@ -1543,6 +1546,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1543
1546
  }
1544
1547
  }
1545
1548
  }
1549
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1550
+ for (const cs of stmt.cases) {
1551
+ for (const stmt2 of cs.consequent) {
1552
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1553
+ for (const decl of stmt2.declarations) {
1554
+ for (const id of extractIdentifiers(decl.id)) {
1555
+ onIdent(id);
1556
+ }
1557
+ }
1558
+ }
1559
+ }
1560
+ walkBlockDeclarations(cs, onIdent);
1561
+ }
1562
+ }
1546
1563
  function extractIdentifiers(param, nodes = []) {
1547
1564
  switch (param.type) {
1548
1565
  case "Identifier":
@@ -4126,80 +4143,6 @@ function getParentCondition(node) {
4126
4143
  }
4127
4144
  }
4128
4145
 
4129
- const transformBind = (dir, _node, context) => {
4130
- const { modifiers, loc } = dir;
4131
- const arg = dir.arg;
4132
- let { exp } = dir;
4133
- if (exp && exp.type === 4 && !exp.content.trim()) {
4134
- {
4135
- exp = void 0;
4136
- }
4137
- }
4138
- if (!exp) {
4139
- if (arg.type !== 4 || !arg.isStatic) {
4140
- context.onError(
4141
- createCompilerError(
4142
- 52,
4143
- arg.loc
4144
- )
4145
- );
4146
- return {
4147
- props: [
4148
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4149
- ]
4150
- };
4151
- }
4152
- transformBindShorthand(dir);
4153
- exp = dir.exp;
4154
- }
4155
- if (arg.type !== 4) {
4156
- arg.children.unshift(`(`);
4157
- arg.children.push(`) || ""`);
4158
- } else if (!arg.isStatic) {
4159
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
4160
- }
4161
- if (modifiers.some((mod) => mod.content === "camel")) {
4162
- if (arg.type === 4) {
4163
- if (arg.isStatic) {
4164
- arg.content = camelize(arg.content);
4165
- } else {
4166
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4167
- }
4168
- } else {
4169
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4170
- arg.children.push(`)`);
4171
- }
4172
- }
4173
- if (!context.inSSR) {
4174
- if (modifiers.some((mod) => mod.content === "prop")) {
4175
- injectPrefix(arg, ".");
4176
- }
4177
- if (modifiers.some((mod) => mod.content === "attr")) {
4178
- injectPrefix(arg, "^");
4179
- }
4180
- }
4181
- return {
4182
- props: [createObjectProperty(arg, exp)]
4183
- };
4184
- };
4185
- const transformBindShorthand = (dir, context) => {
4186
- const arg = dir.arg;
4187
- const propName = camelize(arg.content);
4188
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4189
- };
4190
- const injectPrefix = (arg, prefix) => {
4191
- if (arg.type === 4) {
4192
- if (arg.isStatic) {
4193
- arg.content = prefix + arg.content;
4194
- } else {
4195
- arg.content = `\`${prefix}\${${arg.content}}\``;
4196
- }
4197
- } else {
4198
- arg.children.unshift(`'${prefix}' + (`);
4199
- arg.children.push(`)`);
4200
- }
4201
- };
4202
-
4203
4146
  const transformFor = createStructuralDirectiveTransform(
4204
4147
  "for",
4205
4148
  (node, dir, context) => {
@@ -4211,10 +4154,7 @@ const transformFor = createStructuralDirectiveTransform(
4211
4154
  const isTemplate = isTemplateNode(node);
4212
4155
  const memo = findDir(node, "memo");
4213
4156
  const keyProp = findProp(node, `key`, false, true);
4214
- const isDirKey = keyProp && keyProp.type === 7;
4215
- if (isDirKey && !keyProp.exp) {
4216
- transformBindShorthand(keyProp);
4217
- }
4157
+ keyProp && keyProp.type === 7;
4218
4158
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4219
4159
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4220
4160
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -5386,6 +5326,58 @@ const transformOn = (dir, node, context, augmentor) => {
5386
5326
  return ret;
5387
5327
  };
5388
5328
 
5329
+ const transformBind = (dir, _node, context) => {
5330
+ const { modifiers, loc } = dir;
5331
+ const arg = dir.arg;
5332
+ let { exp } = dir;
5333
+ if (exp && exp.type === 4 && !exp.content.trim()) {
5334
+ {
5335
+ exp = void 0;
5336
+ }
5337
+ }
5338
+ if (arg.type !== 4) {
5339
+ arg.children.unshift(`(`);
5340
+ arg.children.push(`) || ""`);
5341
+ } else if (!arg.isStatic) {
5342
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
5343
+ }
5344
+ if (modifiers.some((mod) => mod.content === "camel")) {
5345
+ if (arg.type === 4) {
5346
+ if (arg.isStatic) {
5347
+ arg.content = camelize(arg.content);
5348
+ } else {
5349
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
5350
+ }
5351
+ } else {
5352
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
5353
+ arg.children.push(`)`);
5354
+ }
5355
+ }
5356
+ if (!context.inSSR) {
5357
+ if (modifiers.some((mod) => mod.content === "prop")) {
5358
+ injectPrefix(arg, ".");
5359
+ }
5360
+ if (modifiers.some((mod) => mod.content === "attr")) {
5361
+ injectPrefix(arg, "^");
5362
+ }
5363
+ }
5364
+ return {
5365
+ props: [createObjectProperty(arg, exp)]
5366
+ };
5367
+ };
5368
+ const injectPrefix = (arg, prefix) => {
5369
+ if (arg.type === 4) {
5370
+ if (arg.isStatic) {
5371
+ arg.content = prefix + arg.content;
5372
+ } else {
5373
+ arg.content = `\`${prefix}\${${arg.content}}\``;
5374
+ }
5375
+ } else {
5376
+ arg.children.unshift(`'${prefix}' + (`);
5377
+ arg.children.push(`)`);
5378
+ }
5379
+ };
5380
+
5389
5381
  const transformText = (node, context) => {
5390
5382
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
5391
5383
  return () => {
@@ -5716,9 +5708,36 @@ const transformMemo = (node, context) => {
5716
5708
  }
5717
5709
  };
5718
5710
 
5711
+ const transformVBindShorthand = (node, context) => {
5712
+ if (node.type === 1) {
5713
+ for (const prop of node.props) {
5714
+ if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
5715
+ prop.exp.type === 4 && !prop.exp.content.trim()) && prop.arg) {
5716
+ const arg = prop.arg;
5717
+ if (arg.type !== 4 || !arg.isStatic) {
5718
+ context.onError(
5719
+ createCompilerError(
5720
+ 52,
5721
+ arg.loc
5722
+ )
5723
+ );
5724
+ prop.exp = createSimpleExpression("", true, arg.loc);
5725
+ } else {
5726
+ const propName = camelize(arg.content);
5727
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
5728
+ propName[0] === "-") {
5729
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
5730
+ }
5731
+ }
5732
+ }
5733
+ }
5734
+ }
5735
+ };
5736
+
5719
5737
  function getBaseTransformPreset(prefixIdentifiers) {
5720
5738
  return [
5721
5739
  [
5740
+ transformVBindShorthand,
5722
5741
  transformOnce,
5723
5742
  transformIf,
5724
5743
  transformMemo,
@@ -5793,4 +5812,4 @@ const BindingTypes = {
5793
5812
 
5794
5813
  const noopDirectiveTransform = () => ({ props: [] });
5795
5814
 
5796
- export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
5815
+ export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.5.21",
3
+ "version": "3.5.23",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -46,13 +46,13 @@
46
46
  },
47
47
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
48
48
  "dependencies": {
49
- "@babel/parser": "^7.28.3",
49
+ "@babel/parser": "^7.28.5",
50
50
  "entities": "^4.5.0",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.1",
53
- "@vue/shared": "3.5.21"
53
+ "@vue/shared": "3.5.23"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/types": "^7.28.2"
56
+ "@babel/types": "^7.28.5"
57
57
  }
58
58
  }