From c4391b8a2a785cbfe832db9ef588d92e169fb8b0 Mon Sep 17 00:00:00 2001 From: xiongyang Date: Thu, 21 Jan 2016 11:39:07 +0800 Subject: [PATCH] =?UTF-8?q?modify:=E6=8C=87=E4=BB=A4=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/compile.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/compiler/compile.js b/src/compiler/compile.js index 9cc954b7668..48f021ad57b 100644 --- a/src/compiler/compile.js +++ b/src/compiler/compile.js @@ -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$/ @@ -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 @@ -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') {