Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

指令解析优化 #2196

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
// special binding prefixes
const bindRE = /^v-bind:|^:/
const onRE = /^v-on:|^@/
const argRE = /:(.*)$/
const dirAttrRE = /^v-([^:]+)(?:$|:(.*)$)/
const modifierRE = /\.[^\.]+/g
const transitionRE = /^(v-bind:|:)?transition$/

Expand Down Expand Up @@ -643,7 +643,7 @@ function makeTerminalNodeLinkFn (el, dirName, value, options, def) {
function compileDirectives (attrs, options) {
var i = attrs.length
var dirs = []
var attr, name, value, rawName, rawValue, dirName, arg, modifiers, dirDef, tokens
var attr, name, value, rawName, rawValue, dirName, arg, modifiers, dirDef, tokens, matched
while (i--) {
attr = attrs[i]
name = rawName = attr.name
Expand Down Expand Up @@ -701,14 +701,9 @@ function compileDirectives (attrs, options) {
} else

// normal directives
if (name.indexOf('v-') === 0) {
// check arg
arg = (arg = name.match(argRE)) && arg[1]
if (arg) {
name = name.replace(argRE, '')
}
// extract directive name
dirName = name.slice(2)
if ((matched = name.match(dirAttrRE))) {
dirName = matched[1]
arg = matched[2]

// skip v-else (when used with v-show)
if (dirName === 'else') {
Expand Down