@vue/compiler-sfc 3.2.36 → 3.2.39

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.
@@ -109,8 +109,6 @@ function sum (o) {
109
109
  var hashSum = sum;
110
110
 
111
111
  const CSS_VARS_HELPER = `useCssVars`;
112
- // match v-bind() with max 2-levels of nested parens.
113
- const cssVarRE = /v-bind\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
114
112
  function genCssVarsFromList(vars, id, isProd, isSSR = false) {
115
113
  return `{\n ${vars
116
114
  .map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
@@ -132,31 +130,89 @@ function normalizeExpression(exp) {
132
130
  }
133
131
  return exp;
134
132
  }
133
+ const vBindRE = /v-bind\s*\(/g;
135
134
  function parseCssVars(sfc) {
136
135
  const vars = [];
137
136
  sfc.styles.forEach(style => {
138
137
  let match;
139
138
  // ignore v-bind() in comments /* ... */
140
139
  const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
141
- while ((match = cssVarRE.exec(content))) {
142
- const variable = normalizeExpression(match[1]);
143
- if (!vars.includes(variable)) {
144
- vars.push(variable);
140
+ while ((match = vBindRE.exec(content))) {
141
+ const start = match.index + match[0].length;
142
+ const end = lexBinding(content, start);
143
+ if (end !== null) {
144
+ const variable = normalizeExpression(content.slice(start, end));
145
+ if (!vars.includes(variable)) {
146
+ vars.push(variable);
147
+ }
145
148
  }
146
149
  }
147
150
  });
148
151
  return vars;
149
152
  }
153
+ function lexBinding(content, start) {
154
+ let state = 0 /* LexerState.inParens */;
155
+ let parenDepth = 0;
156
+ for (let i = start; i < content.length; i++) {
157
+ const char = content.charAt(i);
158
+ switch (state) {
159
+ case 0 /* LexerState.inParens */:
160
+ if (char === `'`) {
161
+ state = 1 /* LexerState.inSingleQuoteString */;
162
+ }
163
+ else if (char === `"`) {
164
+ state = 2 /* LexerState.inDoubleQuoteString */;
165
+ }
166
+ else if (char === `(`) {
167
+ parenDepth++;
168
+ }
169
+ else if (char === `)`) {
170
+ if (parenDepth > 0) {
171
+ parenDepth--;
172
+ }
173
+ else {
174
+ return i;
175
+ }
176
+ }
177
+ break;
178
+ case 1 /* LexerState.inSingleQuoteString */:
179
+ if (char === `'`) {
180
+ state = 0 /* LexerState.inParens */;
181
+ }
182
+ break;
183
+ case 2 /* LexerState.inDoubleQuoteString */:
184
+ if (char === `"`) {
185
+ state = 0 /* LexerState.inParens */;
186
+ }
187
+ break;
188
+ }
189
+ }
190
+ return null;
191
+ }
150
192
  const cssVarsPlugin = opts => {
151
193
  const { id, isProd } = opts;
152
194
  return {
153
195
  postcssPlugin: 'vue-sfc-vars',
154
196
  Declaration(decl) {
155
197
  // rewrite CSS variables
156
- if (cssVarRE.test(decl.value)) {
157
- decl.value = decl.value.replace(cssVarRE, (_, $1) => {
158
- return `var(--${genVarName(id, normalizeExpression($1), isProd)})`;
159
- });
198
+ const value = decl.value;
199
+ if (vBindRE.test(value)) {
200
+ vBindRE.lastIndex = 0;
201
+ let transformed = '';
202
+ let lastIndex = 0;
203
+ let match;
204
+ while ((match = vBindRE.exec(value))) {
205
+ const start = match.index + match[0].length;
206
+ const end = lexBinding(value, start);
207
+ if (end !== null) {
208
+ const variable = normalizeExpression(value.slice(start, end));
209
+ transformed +=
210
+ value.slice(lastIndex, match.index) +
211
+ `var(--${genVarName(id, variable, isProd)})`;
212
+ lastIndex = end + 1;
213
+ }
214
+ }
215
+ decl.value = transformed + value.slice(lastIndex);
160
216
  }
161
217
  }
162
218
  };
@@ -171,7 +227,7 @@ function genCssVarsCode(vars, bindings, id, isProd) {
171
227
  bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings
172
228
  });
173
229
  const transformed = CompilerDOM.processExpression(exp, context);
174
- const transformedString = transformed.type === 4 /* SIMPLE_EXPRESSION */
230
+ const transformedString = transformed.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */
175
231
  ? transformed.content
176
232
  : transformed.children
177
233
  .map(c => {
@@ -1038,7 +1094,7 @@ const createAssetUrlTransformWithOptions = (options) => {
1038
1094
  * ```
1039
1095
  */
1040
1096
  const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1041
- if (node.type === 1 /* ELEMENT */) {
1097
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
1042
1098
  if (!node.props.length) {
1043
1099
  return;
1044
1100
  }
@@ -1050,7 +1106,7 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1050
1106
  }
1051
1107
  const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
1052
1108
  node.props.forEach((attr, index) => {
1053
- if (attr.type !== 6 /* ATTRIBUTE */ ||
1109
+ if (attr.type !== 6 /* NodeTypes.ATTRIBUTE */ ||
1054
1110
  !assetAttrs.includes(attr.name) ||
1055
1111
  !attr.value ||
1056
1112
  isExternalUrl(attr.value.content) ||
@@ -1080,7 +1136,7 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1080
1136
  // absolute url (e.g. webpack file-loader)
1081
1137
  const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
1082
1138
  node.props[index] = {
1083
- type: 7 /* DIRECTIVE */,
1139
+ type: 7 /* NodeTypes.DIRECTIVE */,
1084
1140
  name: 'bind',
1085
1141
  arg: compilerCore.createSimpleExpression(attr.name, true, attr.loc),
1086
1142
  exp,
@@ -1101,30 +1157,30 @@ function getImportsExpressionExp(path, hash, loc, context) {
1101
1157
  }
1102
1158
  else {
1103
1159
  name = `_imports_${context.imports.length}`;
1104
- exp = compilerCore.createSimpleExpression(name, false, loc, 3 /* CAN_STRINGIFY */);
1160
+ exp = compilerCore.createSimpleExpression(name, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1105
1161
  context.imports.push({ exp, path });
1106
1162
  }
1107
1163
  if (!hash) {
1108
1164
  return exp;
1109
1165
  }
1110
1166
  const hashExp = `${name} + '${hash}'`;
1111
- const finalExp = compilerCore.createSimpleExpression(hashExp, false, loc, 3 /* CAN_STRINGIFY */);
1167
+ const finalExp = compilerCore.createSimpleExpression(hashExp, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1112
1168
  if (!context.hoistStatic) {
1113
1169
  return finalExp;
1114
1170
  }
1115
1171
  const existingHoistIndex = context.hoists.findIndex(h => {
1116
1172
  return (h &&
1117
- h.type === 4 /* SIMPLE_EXPRESSION */ &&
1173
+ h.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
1118
1174
  !h.isStatic &&
1119
1175
  h.content === hashExp);
1120
1176
  });
1121
1177
  if (existingHoistIndex > -1) {
1122
- return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* CAN_STRINGIFY */);
1178
+ return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1123
1179
  }
1124
1180
  return context.hoist(finalExp);
1125
1181
  }
1126
1182
  else {
1127
- return compilerCore.createSimpleExpression(`''`, false, loc, 3 /* CAN_STRINGIFY */);
1183
+ return compilerCore.createSimpleExpression(`''`, false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1128
1184
  }
1129
1185
  }
1130
1186
 
@@ -1135,10 +1191,10 @@ const createSrcsetTransformWithOptions = (options) => {
1135
1191
  return (node, context) => transformSrcset(node, context, options);
1136
1192
  };
1137
1193
  const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1138
- if (node.type === 1 /* ELEMENT */) {
1194
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
1139
1195
  if (srcsetTags.includes(node.tag) && node.props.length) {
1140
1196
  node.props.forEach((attr, index) => {
1141
- if (attr.name === 'srcset' && attr.type === 6 /* ATTRIBUTE */) {
1197
+ if (attr.name === 'srcset' && attr.type === 6 /* NodeTypes.ATTRIBUTE */) {
1142
1198
  if (!attr.value)
1143
1199
  return;
1144
1200
  const value = attr.value.content;
@@ -1203,17 +1259,17 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1203
1259
  if (path) {
1204
1260
  const existingImportsIndex = context.imports.findIndex(i => i.path === path);
1205
1261
  if (existingImportsIndex > -1) {
1206
- exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1262
+ exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1207
1263
  }
1208
1264
  else {
1209
- 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 */);
1210
1266
  context.imports.push({ exp, path });
1211
1267
  }
1212
1268
  compoundExpression.children.push(exp);
1213
1269
  }
1214
1270
  }
1215
1271
  else {
1216
- const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1272
+ const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
1217
1273
  compoundExpression.children.push(exp);
1218
1274
  }
1219
1275
  const isNotLast = imageCandidates.length - 1 > index;
@@ -1230,10 +1286,10 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1230
1286
  let exp = compoundExpression;
1231
1287
  if (context.hoistStatic) {
1232
1288
  exp = context.hoist(compoundExpression);
1233
- exp.constType = 3 /* CAN_STRINGIFY */;
1289
+ exp.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
1234
1290
  }
1235
1291
  node.props[index] = {
1236
- type: 7 /* DIRECTIVE */,
1292
+ type: 7 /* NodeTypes.DIRECTIVE */,
1237
1293
  name: 'bind',
1238
1294
  arg: compilerCore.createSimpleExpression('srcset', true, attr.loc),
1239
1295
  exp,
@@ -3296,7 +3352,13 @@ function rewriteDefault(input, as, parserPlugins) {
3296
3352
  }).program.body;
3297
3353
  ast.forEach(node => {
3298
3354
  if (node.type === 'ExportDefaultDeclaration') {
3299
- 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
+ }
3300
3362
  }
3301
3363
  if (node.type === 'ExportNamedDeclaration') {
3302
3364
  for (const specifier of node.specifiers) {
@@ -3401,8 +3463,12 @@ function compileScript(sfc, options) {
3401
3463
  }
3402
3464
  if (options.babelParserPlugins)
3403
3465
  plugins.push(...options.babelParserPlugins);
3404
- if (isTS)
3405
- plugins.push('typescript', 'decorators-legacy');
3466
+ if (isTS) {
3467
+ plugins.push('typescript');
3468
+ if (!plugins.includes('decorators')) {
3469
+ plugins.push('decorators-legacy');
3470
+ }
3471
+ }
3406
3472
  if (!scriptSetup) {
3407
3473
  if (!script) {
3408
3474
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
@@ -4130,7 +4196,7 @@ function compileScript(sfc, options) {
4130
4196
  if (isTS) {
4131
4197
  // runtime enum
4132
4198
  if (node.type === 'TSEnumDeclaration') {
4133
- registerBinding(setupBindings, node.id, "setup-const" /* SETUP_CONST */);
4199
+ registerBinding(setupBindings, node.id, "setup-const" /* BindingTypes.SETUP_CONST */);
4134
4200
  }
4135
4201
  // move all Type declarations to outer scope
4136
4202
  if (node.type.startsWith('TS') ||
@@ -4192,22 +4258,22 @@ function compileScript(sfc, options) {
4192
4258
  }
4193
4259
  if (propsRuntimeDecl) {
4194
4260
  for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
4195
- bindingMetadata[key] = "props" /* PROPS */;
4261
+ bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
4196
4262
  }
4197
4263
  }
4198
4264
  for (const key in typeDeclaredProps) {
4199
- bindingMetadata[key] = "props" /* PROPS */;
4265
+ bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
4200
4266
  }
4201
4267
  // props aliases
4202
4268
  if (propsDestructureDecl) {
4203
4269
  if (propsDestructureRestId) {
4204
4270
  bindingMetadata[propsDestructureRestId] =
4205
- "setup-reactive-const" /* SETUP_REACTIVE_CONST */;
4271
+ "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */;
4206
4272
  }
4207
4273
  for (const key in propsDestructuredBindings) {
4208
4274
  const { local } = propsDestructuredBindings[key];
4209
4275
  if (local !== key) {
4210
- bindingMetadata[local] = "props-aliased" /* PROPS_ALIASED */;
4276
+ bindingMetadata[local] = "props-aliased" /* BindingTypes.PROPS_ALIASED */;
4211
4277
  (bindingMetadata.__propsAliases ||
4212
4278
  (bindingMetadata.__propsAliases = {}))[local] = key;
4213
4279
  }
@@ -4220,8 +4286,8 @@ function compileScript(sfc, options) {
4220
4286
  imported === '*' ||
4221
4287
  (imported === 'default' && source.endsWith('.vue')) ||
4222
4288
  source === 'vue'
4223
- ? "setup-const" /* SETUP_CONST */
4224
- : "setup-maybe-ref" /* SETUP_MAYBE_REF */;
4289
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4290
+ : "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
4225
4291
  }
4226
4292
  for (const key in scriptBindings) {
4227
4293
  bindingMetadata[key] = scriptBindings[key];
@@ -4232,7 +4298,7 @@ function compileScript(sfc, options) {
4232
4298
  // known ref bindings
4233
4299
  if (refBindings) {
4234
4300
  for (const key of refBindings) {
4235
- bindingMetadata[key] = "setup-ref" /* SETUP_REF */;
4301
+ bindingMetadata[key] = "setup-ref" /* BindingTypes.SETUP_REF */;
4236
4302
  }
4237
4303
  }
4238
4304
  // 8. inject `useCssVars` calls
@@ -4365,7 +4431,7 @@ function compileScript(sfc, options) {
4365
4431
  if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
4366
4432
  const match = filename.match(/([^/\\]+)\.\w+$/);
4367
4433
  if (match) {
4368
- runtimeOptions += `\n name: '${match[1]}',`;
4434
+ runtimeOptions += `\n __name: '${match[1]}',`;
4369
4435
  }
4370
4436
  }
4371
4437
  if (hasInlinedSsrRenderFn) {
@@ -4466,8 +4532,8 @@ function walkDeclaration(node, bindings, userImportAlias) {
4466
4532
  if (isCallOf(init, userReactiveBinding)) {
4467
4533
  // treat reactive() calls as let since it's meant to be mutable
4468
4534
  bindingType = isConst
4469
- ? "setup-reactive-const" /* SETUP_REACTIVE_CONST */
4470
- : "setup-let" /* SETUP_LET */;
4535
+ ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
4536
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4471
4537
  }
4472
4538
  else if (
4473
4539
  // if a declaration is a const literal, we can mark it so that
@@ -4475,19 +4541,19 @@ function walkDeclaration(node, bindings, userImportAlias) {
4475
4541
  isDefineCall ||
4476
4542
  (isConst && canNeverBeRef(init, userReactiveBinding))) {
4477
4543
  bindingType = isCallOf(init, DEFINE_PROPS)
4478
- ? "setup-reactive-const" /* SETUP_REACTIVE_CONST */
4479
- : "setup-const" /* SETUP_CONST */;
4544
+ ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
4545
+ : "setup-const" /* BindingTypes.SETUP_CONST */;
4480
4546
  }
4481
4547
  else if (isConst) {
4482
4548
  if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
4483
- bindingType = "setup-ref" /* SETUP_REF */;
4549
+ bindingType = "setup-ref" /* BindingTypes.SETUP_REF */;
4484
4550
  }
4485
4551
  else {
4486
- bindingType = "setup-maybe-ref" /* SETUP_MAYBE_REF */;
4552
+ bindingType = "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
4487
4553
  }
4488
4554
  }
4489
4555
  else {
4490
- bindingType = "setup-let" /* SETUP_LET */;
4556
+ bindingType = "setup-let" /* BindingTypes.SETUP_LET */;
4491
4557
  }
4492
4558
  registerBinding(bindings, id, bindingType);
4493
4559
  }
@@ -4510,7 +4576,7 @@ function walkDeclaration(node, bindings, userImportAlias) {
4510
4576
  node.type === 'ClassDeclaration') {
4511
4577
  // export function foo() {} / export class Foo {}
4512
4578
  // export declarations must be named.
4513
- bindings[node.id.name] = "setup-const" /* SETUP_CONST */;
4579
+ bindings[node.id.name] = "setup-const" /* BindingTypes.SETUP_CONST */;
4514
4580
  }
4515
4581
  }
4516
4582
  function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
@@ -4519,10 +4585,10 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
4519
4585
  if (p.key.type === 'Identifier' && p.key === p.value) {
4520
4586
  // shorthand: const { x } = ...
4521
4587
  const type = isDefineCall
4522
- ? "setup-const" /* SETUP_CONST */
4588
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4523
4589
  : isConst
4524
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4525
- : "setup-let" /* SETUP_LET */;
4590
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4591
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4526
4592
  registerBinding(bindings, p.key, type);
4527
4593
  }
4528
4594
  else {
@@ -4532,7 +4598,7 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
4532
4598
  else {
4533
4599
  // ...rest
4534
4600
  // argument can only be identifier when destructuring
4535
- 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 */;
4536
4602
  registerBinding(bindings, p.argument, type);
4537
4603
  }
4538
4604
  }
@@ -4545,15 +4611,15 @@ function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
4545
4611
  function walkPattern(node, bindings, isConst, isDefineCall = false) {
4546
4612
  if (node.type === 'Identifier') {
4547
4613
  const type = isDefineCall
4548
- ? "setup-const" /* SETUP_CONST */
4614
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4549
4615
  : isConst
4550
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4551
- : "setup-let" /* SETUP_LET */;
4616
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4617
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4552
4618
  registerBinding(bindings, node, type);
4553
4619
  }
4554
4620
  else if (node.type === 'RestElement') {
4555
4621
  // argument can only be identifier when destructuring
4556
- 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 */;
4557
4623
  registerBinding(bindings, node.argument, type);
4558
4624
  }
4559
4625
  else if (node.type === 'ObjectPattern') {
@@ -4565,10 +4631,10 @@ function walkPattern(node, bindings, isConst, isDefineCall = false) {
4565
4631
  else if (node.type === 'AssignmentPattern') {
4566
4632
  if (node.left.type === 'Identifier') {
4567
4633
  const type = isDefineCall
4568
- ? "setup-const" /* SETUP_CONST */
4634
+ ? "setup-const" /* BindingTypes.SETUP_CONST */
4569
4635
  : isConst
4570
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4571
- : "setup-let" /* SETUP_LET */;
4636
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4637
+ : "setup-let" /* BindingTypes.SETUP_LET */;
4572
4638
  registerBinding(bindings, node.left, type);
4573
4639
  }
4574
4640
  else {
@@ -4788,7 +4854,7 @@ function analyzeBindingsFromOptions(node) {
4788
4854
  // props: ['foo']
4789
4855
  // props: { foo: ... }
4790
4856
  for (const key of getObjectOrArrayExpressionKeys(property.value)) {
4791
- bindings[key] = "props" /* PROPS */;
4857
+ bindings[key] = "props" /* BindingTypes.PROPS */;
4792
4858
  }
4793
4859
  }
4794
4860
  // inject
@@ -4796,7 +4862,7 @@ function analyzeBindingsFromOptions(node) {
4796
4862
  // inject: ['foo']
4797
4863
  // inject: { foo: {} }
4798
4864
  for (const key of getObjectOrArrayExpressionKeys(property.value)) {
4799
- bindings[key] = "options" /* OPTIONS */;
4865
+ bindings[key] = "options" /* BindingTypes.OPTIONS */;
4800
4866
  }
4801
4867
  }
4802
4868
  // computed & methods
@@ -4805,7 +4871,7 @@ function analyzeBindingsFromOptions(node) {
4805
4871
  // methods: { foo() {} }
4806
4872
  // computed: { foo() {} }
4807
4873
  for (const key of getObjectExpressionKeys(property.value)) {
4808
- bindings[key] = "options" /* OPTIONS */;
4874
+ bindings[key] = "options" /* BindingTypes.OPTIONS */;
4809
4875
  }
4810
4876
  }
4811
4877
  }
@@ -4825,8 +4891,8 @@ function analyzeBindingsFromOptions(node) {
4825
4891
  for (const key of getObjectExpressionKeys(bodyItem.argument)) {
4826
4892
  bindings[key] =
4827
4893
  property.key.name === 'setup'
4828
- ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
4829
- : "data" /* DATA */;
4894
+ ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
4895
+ : "data" /* BindingTypes.DATA */;
4830
4896
  }
4831
4897
  }
4832
4898
  }
@@ -4878,14 +4944,14 @@ function resolveTemplateUsageCheckString(sfc) {
4878
4944
  CompilerDOM.transform(CompilerDOM.createRoot([ast]), {
4879
4945
  nodeTransforms: [
4880
4946
  node => {
4881
- if (node.type === 1 /* ELEMENT */) {
4947
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
4882
4948
  if (!CompilerDOM.parserOptions.isNativeTag(node.tag) &&
4883
4949
  !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) {
4884
4950
  code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`;
4885
4951
  }
4886
4952
  for (let i = 0; i < node.props.length; i++) {
4887
4953
  const prop = node.props[i];
4888
- if (prop.type === 7 /* DIRECTIVE */) {
4954
+ if (prop.type === 7 /* NodeTypes.DIRECTIVE */) {
4889
4955
  if (!isBuiltInDir(prop.name)) {
4890
4956
  code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
4891
4957
  }
@@ -4895,7 +4961,7 @@ function resolveTemplateUsageCheckString(sfc) {
4895
4961
  }
4896
4962
  }
4897
4963
  }
4898
- else if (node.type === 5 /* INTERPOLATION */) {
4964
+ else if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
4899
4965
  code += `,${processExp(node.content.content)}`;
4900
4966
  }
4901
4967
  }
@@ -4911,6 +4977,9 @@ function processExp(exp, dir) {
4911
4977
  if (dir === 'slot') {
4912
4978
  exp = `(${exp})=>{}`;
4913
4979
  }
4980
+ else if (dir === 'on') {
4981
+ exp = `()=>{${exp}}`;
4982
+ }
4914
4983
  else if (dir === 'for') {
4915
4984
  const inMatch = exp.match(forAliasRE);
4916
4985
  if (inMatch) {
@@ -5000,15 +5069,15 @@ function parse(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRo
5000
5069
  if ((!parent && tag !== 'template') ||
5001
5070
  // <template lang="xxx"> should also be treated as raw text
5002
5071
  (tag === 'template' &&
5003
- props.some(p => p.type === 6 /* ATTRIBUTE */ &&
5072
+ props.some(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
5004
5073
  p.name === 'lang' &&
5005
5074
  p.value &&
5006
5075
  p.value.content &&
5007
5076
  p.value.content !== 'html'))) {
5008
- return 2 /* RAWTEXT */;
5077
+ return 2 /* TextModes.RAWTEXT */;
5009
5078
  }
5010
5079
  else {
5011
- return 0 /* DATA */;
5080
+ return 0 /* TextModes.DATA */;
5012
5081
  }
5013
5082
  },
5014
5083
  onError: e => {
@@ -5016,7 +5085,7 @@ function parse(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRo
5016
5085
  }
5017
5086
  });
5018
5087
  ast.children.forEach(node => {
5019
- if (node.type !== 1 /* ELEMENT */) {
5088
+ if (node.type !== 1 /* NodeTypes.ELEMENT */) {
5020
5089
  return;
5021
5090
  }
5022
5091
  // we only want to keep the nodes that are not empty (when the tag is not a template)
@@ -5147,7 +5216,7 @@ function createBlock(node, source, pad) {
5147
5216
  block.content = padContent(source, block, pad) + block.content;
5148
5217
  }
5149
5218
  node.props.forEach(p => {
5150
- if (p.type === 6 /* ATTRIBUTE */) {
5219
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
5151
5220
  attrs[p.name] = p.value ? p.value.content || true : true;
5152
5221
  if (p.name === 'lang') {
5153
5222
  block.lang = p.value && p.value.content;
@@ -5215,7 +5284,7 @@ function padContent(content, block, pad) {
5215
5284
  }
5216
5285
  function hasSrc(node) {
5217
5286
  return node.props.some(p => {
5218
- if (p.type !== 6 /* ATTRIBUTE */) {
5287
+ if (p.type !== 6 /* NodeTypes.ATTRIBUTE */) {
5219
5288
  return false;
5220
5289
  }
5221
5290
  return p.name === 'src';
@@ -5228,7 +5297,7 @@ function hasSrc(node) {
5228
5297
  function isEmpty(node) {
5229
5298
  for (let i = 0; i < node.children.length; i++) {
5230
5299
  const child = node.children[i];
5231
- if (child.type !== 2 /* TEXT */ || child.content.trim() !== '') {
5300
+ if (child.type !== 2 /* NodeTypes.TEXT */ || child.content.trim() !== '') {
5232
5301
  return false;
5233
5302
  }
5234
5303
  }