Skip to content

Commit 06de266

Browse files
javoskiyyx990803
authored andcommitted
reusing onRE (vuejs#5130)
* remove unnecessary code * improve compiler codegen * change false to 0 * reusing onRE
1 parent c619b8d commit 06de266

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/compiler/error-detector.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { dirRE } from './parser/index'
3+
import { dirRE, onRE } from './parser/index'
44

55
// operators like typeof, instanceof and in are allowed
66
const prohibitedKeywordRE = new RegExp('\\b' + (
@@ -11,7 +11,6 @@ const prohibitedKeywordRE = new RegExp('\\b' + (
1111
const unaryOperatorsRE = new RegExp('\\b' + (
1212
'delete,typeof,void'
1313
).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)')
14-
const eventAttrRE = /^@|^v-on:/
1514
// check valid identifier for v-for
1615
const identRE = /[A-Za-z_$][\w$]*/
1716
// strip strings in expressions
@@ -34,7 +33,7 @@ function checkNode (node: ASTNode, errors: Array<string>) {
3433
if (value) {
3534
if (name === 'v-for') {
3635
checkFor(node, `v-for="${value}"`, errors)
37-
} else if (eventAttrRE.test(name)) {
36+
} else if (onRE.test(name)) {
3837
checkEvent(value, `${name}="${value}"`, errors)
3938
} else {
4039
checkExpression(value, `${name}="${value}"`, errors)

src/compiler/parser/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import {
1818
} from '../helpers'
1919

2020
export const dirRE = /^v-|^@|^:/
21+
export const onRE = /^@|^v-on:/
2122
export const forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/
2223
export const forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/
2324
const bindRE = /^:|^v-bind:/
24-
const onRE = /^@|^v-on:/
2525
const argRE = /:(.*)$/
2626
const modifierRE = /\.[^.]+/g
2727

0 commit comments

Comments
 (0)