Skip to content

Commit 9425bd3

Browse files
committed
Small performance fixes
According to the discussion in vuejs#262
1 parent 3180eab commit 9425bd3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/compiler.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -525,17 +525,18 @@ CompilerProto.compileElement = function (node, root) {
525525
var prefix = config.prefix + '-',
526526
attrs = slice.call(node.attributes),
527527
params = this.options.paramAttributes,
528-
attr, isDirective, exp, directives, directive, dirname
528+
attr, attrname, isDirective, exp, directives, directive, dirname
529529

530530
for (i = 0, l = attrs.length; i < l; i++) {
531531

532532
attr = attrs[i]
533+
attrname = attr.name
533534
isDirective = false
534535

535-
if (attr.name.indexOf(prefix) === 0) {
536+
if (attrname.indexOf(prefix) === 0) {
536537
// a directive - split, parse and bind it.
537538
isDirective = true
538-
dirname = attr.name.slice(prefix.length)
539+
dirname = attrname.slice(prefix.length)
539540
// build with multiple: true
540541
directives = this.parseDirective(dirname, attr.value, node, true)
541542
// loop through clauses (separated by ",")
@@ -553,8 +554,8 @@ CompilerProto.compileElement = function (node, root) {
553554
exp = TextParser.parseAttr(attr.value)
554555
if (exp) {
555556
directive = this.parseDirective('attr', exp, node)
556-
directive.arg = attr.name
557-
if (params && params.indexOf(attr.name) > -1) {
557+
directive.arg = attrname
558+
if (params && params.indexOf(attrname) > -1) {
558559
// a param attribute... we should use the parent binding
559560
// to avoid circular updates like size={{size}}
560561
this.bindDirective(directive, this.parent)
@@ -565,7 +566,7 @@ CompilerProto.compileElement = function (node, root) {
565566
}
566567

567568
if (isDirective && dirname !== 'cloak') {
568-
node.removeAttribute(attr.name)
569+
node.removeAttribute(attrname)
569570
}
570571
}
571572

src/directive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Directive.parse = function (str) {
162162
arg = str.slice(begin, i).trim()
163163
if (ARG_RE.test(arg)) {
164164
argIndex = i + 1
165-
dir.arg = str.slice(begin, i).trim()
165+
dir.arg = arg
166166
}
167167
} else if (c === '|' && str.charAt(i + 1) !== '|' && str.charAt(i - 1) !== '|') {
168168
if (dir.key === undefined) {

0 commit comments

Comments
 (0)