@vue/compiler-sfc 3.2.37 → 3.2.38

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.
@@ -151,17 +151,17 @@ function parseCssVars(sfc) {
151
151
  return vars;
152
152
  }
153
153
  function lexBinding(content, start) {
154
- let state = 0 /* inParens */;
154
+ let state = 0 /* LexerState.inParens */;
155
155
  let parenDepth = 0;
156
156
  for (let i = start; i < content.length; i++) {
157
157
  const char = content.charAt(i);
158
158
  switch (state) {
159
- case 0 /* inParens */:
159
+ case 0 /* LexerState.inParens */:
160
160
  if (char === `'`) {
161
- state = 1 /* inSingleQuoteString */;
161
+ state = 1 /* LexerState.inSingleQuoteString */;
162
162
  }
163
163
  else if (char === `"`) {
164
- state = 2 /* inDoubleQuoteString */;
164
+ state = 2 /* LexerState.inDoubleQuoteString */;
165
165
  }
166
166
  else if (char === `(`) {
167
167
  parenDepth++;
@@ -175,14 +175,14 @@ function lexBinding(content, start) {
175
175
  }
176
176
  }
177
177
  break;
178
- case 1 /* inSingleQuoteString */:
178
+ case 1 /* LexerState.inSingleQuoteString */:
179
179
  if (char === `'`) {
180
- state = 0 /* inParens */;
180
+ state = 0 /* LexerState.inParens */;
181
181
  }
182
182
  break;
183
- case 2 /* inDoubleQuoteString */:
183
+ case 2 /* LexerState.inDoubleQuoteString */:
184
184
  if (char === `"`) {
185
- state = 0 /* inParens */;
185
+ state = 0 /* LexerState.inParens */;
186
186
  }
187
187
  break;
188
188
  }
@@ -227,7 +227,7 @@ function genCssVarsCode(vars, bindings, id, isProd) {
227
227
  bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings
228
228
  });
229
229
  const transformed = CompilerDOM.processExpression(exp, context);
230
- const transformedString = transformed.type === 4 /* SIMPLE_EXPRESSION */
230
+ const transformedString = transformed.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */
231
231
  ? transformed.content
232
232
  : transformed.children
233
233
  .map(c => {
@@ -1094,7 +1094,7 @@ const createAssetUrlTransformWithOptions = (options) => {
1094
1094
  * ```
1095
1095
  */
1096
1096
  const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1097
- if (node.type === 1 /* ELEMENT */) {
1097
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
1098
1098
  if (!node.props.length) {
1099
1099
  return;
1100
1100
  }
@@ -1106,7 +1106,7 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1106
1106
  }
1107
1107
  const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
1108
1108
  node.props.forEach((attr, index) => {
1109
- if (attr.type !== 6 /* ATTRIBUTE */ ||
1109
+ if (attr.type !== 6 /* NodeTypes.ATTRIBUTE */ ||
1110
1110
  !assetAttrs.includes(attr.name) ||
1111
1111
  !attr.value ||
1112
1112
  isExternalUrl(attr.value.content) ||
@@ -1136,7 +1136,7 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1136
1136
  // absolute url (e.g. webpack file-loader)
1137
1137
  const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
1138
1138
  node.props[index] = {
1139
- type: 7 /* DIRECTIVE */,
1139
+ type: 7 /* NodeTypes.DIRECTIVE */,
1140
1140
  name: 'bind',
1141
1141
  arg: compilerCore.createSimpleExpression(attr.name, true, attr.loc),
1142
1142
  exp,
@@ -1157,30 +1157,30 @@ function getImportsExpressionExp(path, hash, loc, context) {
1157
1157
  }
1158
1158
  else {
1159
1159
  name = `_imports_${context.imports.length}`;
1160
- exp = compilerCore.createSimpleExpression(name, false, loc, 3 /* CAN_STRINGIFY */);
1160
+ exp = compilerCore.createSimpleExpression(name, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1161
1161
  context.imports.push({ exp, path });
1162
1162
  }
1163
1163
  if (!hash) {
1164
1164
  return exp;
1165
1165
  }
1166
1166
  const hashExp = `${name} + '${hash}'`;
1167
- const finalExp = compilerCore.createSimpleExpression(hashExp, false, loc, 3 /* CAN_STRINGIFY */);
1167
+ const finalExp = compilerCore.createSimpleExpression(hashExp, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1168
1168
  if (!context.hoistStatic) {
1169
1169
  return finalExp;
1170
1170
  }
1171
1171
  const existingHoistIndex = context.hoists.findIndex(h => {
1172
1172
  return (h &&
1173
- h.type === 4 /* SIMPLE_EXPRESSION */ &&
1173
+ h.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
1174
1174
  !h.isStatic &&
1175
1175
  h.content === hashExp);
1176
1176
  });
1177
1177
  if (existingHoistIndex > -1) {
1178
- return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* CAN_STRINGIFY */);
1178
+ return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1179
1179
  }
1180
1180
  return context.hoist(finalExp);
1181
1181
  }
1182
1182
  else {
1183
- return compilerCore.createSimpleExpression(`''`, false, loc, 3 /* CAN_STRINGIFY */);
1183
+ return compilerCore.createSimpleExpression(`''`, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1184
1184
  }
1185
1185
  }
1186
1186
 
@@ -1191,10 +1191,10 @@ const createSrcsetTransformWithOptions = (options) => {
1191
1191
  return (node, context) => transformSrcset(node, context, options);
1192
1192
  };
1193
1193
  const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1194
- if (node.type === 1 /* ELEMENT */) {
1194
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
1195
1195
  if (srcsetTags.includes(node.tag) && node.props.length) {
1196
1196
  node.props.forEach((attr, index) => {
1197
- if (attr.name === 'srcset' && attr.type === 6 /* ATTRIBUTE */) {
1197
+ if (attr.name === 'srcset' && attr.type === 6 /* NodeTypes.ATTRIBUTE */) {
1198
1198
  if (!attr.value)
1199
1199
  return;
1200
1200
  const value = attr.value.content;
@@ -1259,17 +1259,17 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1259
1259
  if (path) {
1260
1260
  const existingImportsIndex = context.imports.findIndex(i => i.path === path);
1261
1261
  if (existingImportsIndex > -1) {
1262
- exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1262
+ exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1263
1263
  }
1264
1264
  else {
1265
- exp = compilerCore.createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1265
+ exp = compilerCore.createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1266
1266
  context.imports.push({ exp, path });
1267
1267
  }
1268
1268
  compoundExpression.children.push(exp);
1269
1269
  }
1270
1270
  }
1271
1271
  else {
1272
- const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1272
+ const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1273
1273
  compoundExpression.children.push(exp);
1274
1274
  }
1275
1275
  const isNotLast = imageCandidates.length - 1 > index;
@@ -1286,10 +1286,10 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1286
1286
  let exp = compoundExpression;
1287
1287
  if (context.hoistStatic) {
1288
1288
  exp = context.hoist(compoundExpression);
1289
- exp.constType = 3 /* CAN_STRINGIFY */;
1289
+ exp.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1290
1290
  }
1291
1291
  node.props[index] = {
1292
- type: 7 /* DIRECTIVE */,
1292
+ type: 7 /* NodeTypes.DIRECTIVE */,
1293
1293
  name: 'bind',
1294
1294
  arg: compilerCore.createSimpleExpression('srcset', true, attr.loc),
1295
1295
  exp,
@@ -3352,7 +3352,13 @@ function rewriteDefault(input, as, parserPlugins) {
3352
3352
  }).program.body;
3353
3353
  ast.forEach(node => {
3354
3354
  if (node.type === 'ExportDefaultDeclaration') {
3355
- s.overwrite(node.start, node.declaration.start, `const ${as} = `);
3355
+ if (node.declaration.type === 'ClassDeclaration') {
3356
+ s.overwrite(node.start, node.declaration.id.start, `class `);
3357
+ s.append(`\nconst ${as} = ${node.declaration.id.name}`);
3358
+ }
3359
+ else {
3360
+ s.overwrite(node.start, node.declaration.start, `const ${as} = `);
3361
+ }
3356
3362
  }
3357
3363
  if (node.type === 'ExportNamedDeclaration') {
3358
3364
  for (const specifier of node.specifiers) {
@@ -3457,8 +3463,12 @@ function compileScript(sfc, options) {
3457
3463
  }
3458
3464
  if (options.babelParserPlugins)
3459
3465
  plugins.push(...options.babelParserPlugins);
3460
- if (isTS)
3461
- plugins.push('typescript', 'decorators-legacy');
3466
+ if (isTS) {
3467
+ plugins.push('typescript');
3468
+ if (!plugins.includes('decorators')) {
3469
+ plugins.push('decorators-legacy');
3470
+ }
3471
+ }
3462
3472
  if (!scriptSetup) {
3463
3473
  if (!script) {
3464
3474
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
@@ -4186,7 +4196,7 @@ function compileScript(sfc, options) {
4186
4196
  if (isTS) {
4187
4197
  // runtime enum
4188
4198
  if (node.type === 'TSEnumDeclaration') {
4189
- registerBinding(setupBindings, node.id, "setup-const" /* SETUP_CONST */);
4199
+ registerBinding(setupBindings, node.id, "setup-const" /* BindingTypes.SETUP_CONST */);
4190
4200
  }
4191
4201
  // move all Type declarations to outer scope
4192
4202
  if (node.type.startsWith('TS') ||
@@ -4248,22 +4258,22 @@ function compileScript(sfc, options) {
4248
4258
  }
4249
4259
  if (propsRuntimeDecl) {
4250
4260
  for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
4251
- bindingMetadata[key] = "props" /* PROPS */;
4261
+ bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
4252
4262
  }
4253
4263
  }
4254
4264
  for (const key in typeDeclaredProps) {
4255
- bindingMetadata[key] = "props" /* PROPS */;
4265
+ bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
4256
4266
  }
4257
4267
  // props aliases
4258
4268
  if (propsDestructureDecl) {
4259
4269
  if (propsDestructureRestId) {
4260
4270
  bindingMetadata[propsDestructureRestId] =
4261
- "setup-reactive-const" /* SETUP_REACTIVE_CONST */;
4271
+ "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */;
4262
4272
  }
4263
4273
  for (const key in propsDestructuredBindings) {
4264
4274
  const { local } = propsDestructuredBindings[key];
4265
4275
  if (local !== key) {
4266
- bindingMetadata[local] = "props-aliased" /* PROPS_ALIASED */;
4276
+ bindingMetadata[local] = "props-aliased" /* BindingTypes.PROPS_ALIASED */;
4267
4277
  (bindingMetadata.__propsAliases ||
4268
4278
  (bindingMetadata.__propsAliases = {}))[local] = key;
4269
4279
  }
@@ -4276,8 +4286,8 @@ function compileScript(sfc, options) {
4276
4286
  imported === '*' ||
4277
4287
  (imported === 'default' && source.endsWith('.vue')) ||
4278
4288
  source === 'vue'
4279
- ? "setup-const" /* SETUP_CONST */
4280
- : "setup-maybe-ref" /* SETUP_MAYBE_REF */;
4289
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4290
+ : "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
4281
4291
  }
4282
4292
  for (const key in scriptBindings) {
4283
4293
  bindingMetadata[key] = scriptBindings[key];
@@ -4288,7 +4298,7 @@ function compileScript(sfc, options) {
4288
4298
  // known ref bindings
4289
4299
  if (refBindings) {
4290
4300
  for (const key of refBindings) {
4291
- bindingMetadata[key] = "setup-ref" /* SETUP_REF */;
4301
+ bindingMetadata[key] = "setup-ref" /* BindingTypes.SETUP_REF */;
4292
4302
  }
4293
4303
  }
4294
4304
  // 8. inject `useCssVars` calls
@@ -4522,8 +4532,8 @@ function walkDeclaration(node, bindings, userImportAlias) {
4522
4532
  if (isCallOf(init, userReactiveBinding)) {
4523
4533
  // treat reactive() calls as let since it's meant to be mutable
4524
4534
  bindingType = isConst
4525
- ? "setup-reactive-const" /* SETUP_REACTIVE_CONST */
4526
- : "setup-let" /* SETUP_LET */;
4535
+ ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
4536
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4527
4537
  }
4528
4538
  else if (
4529
4539
  // if a declaration is a const literal, we can mark it so that
@@ -4531,19 +4541,19 @@ function walkDeclaration(node, bindings, userImportAlias) {
4531
4541
  isDefineCall ||
4532
4542
  (isConst && canNeverBeRef(init, userReactiveBinding))) {
4533
4543
  bindingType = isCallOf(init, DEFINE_PROPS)
4534
- ? "setup-reactive-const" /* SETUP_REACTIVE_CONST */
4535
- : "setup-const" /* SETUP_CONST */;
4544
+ ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
4545
+ : "setup-const" /* BindingTypes.SETUP_CONST */;
4536
4546
  }
4537
4547
  else if (isConst) {
4538
4548
  if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
4539
- bindingType = "setup-ref" /* SETUP_REF */;
4549
+ bindingType = "setup-ref" /* BindingTypes.SETUP_REF */;
4540
4550
  }
4541
4551
  else {
4542
- bindingType = "setup-maybe-ref" /* SETUP_MAYBE_REF */;
4552
+ bindingType = "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
4543
4553
  }
4544
4554
  }
4545
4555
  else {
4546
- bindingType = "setup-let" /* SETUP_LET */;
4556
+ bindingType = "setup-let" /* BindingTypes.SETUP_LET */;
4547
4557
  }
4548
4558
  registerBinding(bindings, id, bindingType);
4549
4559
  }
@@ -4566,7 +4576,7 @@ function walkDeclaration(node, bindings, userImportAlias) {
4566
4576
  node.type === 'ClassDeclaration') {
4567
4577
  // export function foo() {} / export class Foo {}
4568
4578
  // export declarations must be named.
4569
- bindings[node.id.name] = "setup-const" /* SETUP_CONST */;
4579
+ bindings[node.id.name] = "setup-const" /* BindingTypes.SETUP_CONST */;
4570
4580
  }
4571
4581
  }
4572
4582
  function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
@@ -4575,10 +4585,10 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
4575
4585
  if (p.key.type === 'Identifier' && p.key === p.value) {
4576
4586
  // shorthand: const { x } = ...
4577
4587
  const type = isDefineCall
4578
- ? "setup-const" /* SETUP_CONST */
4588
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4579
4589
  : isConst
4580
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4581
- : "setup-let" /* SETUP_LET */;
4590
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4591
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4582
4592
  registerBinding(bindings, p.key, type);
4583
4593
  }
4584
4594
  else {
@@ -4588,7 +4598,7 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
4588
4598
  else {
4589
4599
  // ...rest
4590
4600
  // argument can only be identifier when destructuring
4591
- const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
4601
+ const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
4592
4602
  registerBinding(bindings, p.argument, type);
4593
4603
  }
4594
4604
  }
@@ -4601,15 +4611,15 @@ function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
4601
4611
  function walkPattern(node, bindings, isConst, isDefineCall = false) {
4602
4612
  if (node.type === 'Identifier') {
4603
4613
  const type = isDefineCall
4604
- ? "setup-const" /* SETUP_CONST */
4614
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4605
4615
  : isConst
4606
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4607
- : "setup-let" /* SETUP_LET */;
4616
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4617
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4608
4618
  registerBinding(bindings, node, type);
4609
4619
  }
4610
4620
  else if (node.type === 'RestElement') {
4611
4621
  // argument can only be identifier when destructuring
4612
- const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
4622
+ const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
4613
4623
  registerBinding(bindings, node.argument, type);
4614
4624
  }
4615
4625
  else if (node.type === 'ObjectPattern') {
@@ -4621,10 +4631,10 @@ function walkPattern(node, bindings, isConst, isDefineCall = false) {
4621
4631
  else if (node.type === 'AssignmentPattern') {
4622
4632
  if (node.left.type === 'Identifier') {
4623
4633
  const type = isDefineCall
4624
- ? "setup-const" /* SETUP_CONST */
4634
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4625
4635
  : isConst
4626
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4627
- : "setup-let" /* SETUP_LET */;
4636
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4637
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4628
4638
  registerBinding(bindings, node.left, type);
4629
4639
  }
4630
4640
  else {
@@ -4844,7 +4854,7 @@ function analyzeBindingsFromOptions(node) {
4844
4854
  // props: ['foo']
4845
4855
  // props: { foo: ... }
4846
4856
  for (const key of getObjectOrArrayExpressionKeys(property.value)) {
4847
- bindings[key] = "props" /* PROPS */;
4857
+ bindings[key] = "props" /* BindingTypes.PROPS */;
4848
4858
  }
4849
4859
  }
4850
4860
  // inject
@@ -4852,7 +4862,7 @@ function analyzeBindingsFromOptions(node) {
4852
4862
  // inject: ['foo']
4853
4863
  // inject: { foo: {} }
4854
4864
  for (const key of getObjectOrArrayExpressionKeys(property.value)) {
4855
- bindings[key] = "options" /* OPTIONS */;
4865
+ bindings[key] = "options" /* BindingTypes.OPTIONS */;
4856
4866
  }
4857
4867
  }
4858
4868
  // computed & methods
@@ -4861,7 +4871,7 @@ function analyzeBindingsFromOptions(node) {
4861
4871
  // methods: { foo() {} }
4862
4872
  // computed: { foo() {} }
4863
4873
  for (const key of getObjectExpressionKeys(property.value)) {
4864
- bindings[key] = "options" /* OPTIONS */;
4874
+ bindings[key] = "options" /* BindingTypes.OPTIONS */;
4865
4875
  }
4866
4876
  }
4867
4877
  }
@@ -4881,8 +4891,8 @@ function analyzeBindingsFromOptions(node) {
4881
4891
  for (const key of getObjectExpressionKeys(bodyItem.argument)) {
4882
4892
  bindings[key] =
4883
4893
  property.key.name === 'setup'
4884
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4885
- : "data" /* DATA */;
4894
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4895
+ : "data" /* BindingTypes.DATA */;
4886
4896
  }
4887
4897
  }
4888
4898
  }
@@ -4934,14 +4944,14 @@ function resolveTemplateUsageCheckString(sfc) {
4934
4944
  CompilerDOM.transform(CompilerDOM.createRoot([ast]), {
4935
4945
  nodeTransforms: [
4936
4946
  node => {
4937
- if (node.type === 1 /* ELEMENT */) {
4947
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
4938
4948
  if (!CompilerDOM.parserOptions.isNativeTag(node.tag) &&
4939
4949
  !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) {
4940
4950
  code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`;
4941
4951
  }
4942
4952
  for (let i = 0; i < node.props.length; i++) {
4943
4953
  const prop = node.props[i];
4944
- if (prop.type === 7 /* DIRECTIVE */) {
4954
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */) {
4945
4955
  if (!isBuiltInDir(prop.name)) {
4946
4956
  code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
4947
4957
  }
@@ -4951,7 +4961,7 @@ function resolveTemplateUsageCheckString(sfc) {
4951
4961
  }
4952
4962
  }
4953
4963
  }
4954
- else if (node.type === 5 /* INTERPOLATION */) {
4964
+ else if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
4955
4965
  code += `,${processExp(node.content.content)}`;
4956
4966
  }
4957
4967
  }
@@ -4967,6 +4977,9 @@ function processExp(exp, dir) {
4967
4977
  if (dir === 'slot') {
4968
4978
  exp = `(${exp})=>{}`;
4969
4979
  }
4980
+ else if (dir === 'on') {
4981
+ exp = `()=>{${exp}}`;
4982
+ }
4970
4983
  else if (dir === 'for') {
4971
4984
  const inMatch = exp.match(forAliasRE);
4972
4985
  if (inMatch) {
@@ -5056,15 +5069,15 @@ function parse(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRo
5056
5069
  if ((!parent && tag !== 'template') ||
5057
5070
  // <template lang="xxx"> should also be treated as raw text
5058
5071
  (tag === 'template' &&
5059
- props.some(p => p.type === 6 /* ATTRIBUTE */ &&
5072
+ props.some(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
5060
5073
  p.name === 'lang' &&
5061
5074
  p.value &&
5062
5075
  p.value.content &&
5063
5076
  p.value.content !== 'html'))) {
5064
- return 2 /* RAWTEXT */;
5077
+ return 2 /* TextModes.RAWTEXT */;
5065
5078
  }
5066
5079
  else {
5067
- return 0 /* DATA */;
5080
+ return 0 /* TextModes.DATA */;
5068
5081
  }
5069
5082
  },
5070
5083
  onError: e => {
@@ -5072,7 +5085,7 @@ function parse(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRo
5072
5085
  }
5073
5086
  });
5074
5087
  ast.children.forEach(node => {
5075
- if (node.type !== 1 /* ELEMENT */) {
5088
+ if (node.type !== 1 /* NodeTypes.ELEMENT */) {
5076
5089
  return;
5077
5090
  }
5078
5091
  // we only want to keep the nodes that are not empty (when the tag is not a template)
@@ -5203,7 +5216,7 @@ function createBlock(node, source, pad) {
5203
5216
  block.content = padContent(source, block, pad) + block.content;
5204
5217
  }
5205
5218
  node.props.forEach(p => {
5206
- if (p.type === 6 /* ATTRIBUTE */) {
5219
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
5207
5220
  attrs[p.name] = p.value ? p.value.content || true : true;
5208
5221
  if (p.name === 'lang') {
5209
5222
  block.lang = p.value && p.value.content;
@@ -5271,7 +5284,7 @@ function padContent(content, block, pad) {
5271
5284
  }
5272
5285
  function hasSrc(node) {
5273
5286
  return node.props.some(p => {
5274
- if (p.type !== 6 /* ATTRIBUTE */) {
5287
+ if (p.type !== 6 /* NodeTypes.ATTRIBUTE */) {
5275
5288
  return false;
5276
5289
  }
5277
5290
  return p.name === 'src';
@@ -5284,7 +5297,7 @@ function hasSrc(node) {
5284
5297
  function isEmpty(node) {
5285
5298
  for (let i = 0; i < node.children.length; i++) {
5286
5299
  const child = node.children[i];
5287
- if (child.type !== 2 /* TEXT */ || child.content.trim() !== '') {
5300
+ if (child.type !== 2 /* NodeTypes.TEXT */ || child.content.trim() !== '') {
5288
5301
  return false;
5289
5302
  }
5290
5303
  }