Skip to content

Commit 3d17807

Browse files
committed
add warning for mixing mustaches and v-bind for class
1 parent 9a66ece commit 3d17807

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/compiler/compile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,17 @@ function compileDirectives (attrs, options) {
615615
value = textParser.tokensToExp(tokens)
616616
arg = name
617617
pushDir('bind', publicDirectives.bind, true)
618+
// warn against mixing mustaches with v-bind
619+
if (process.env.NODE_ENV !== 'production') {
620+
if (name === 'class' && Array.prototype.some.call(attrs, function (attr) {
621+
return attr.name === ':class' || attr.name === 'v-bind:class'
622+
})) {
623+
_.warn(
624+
name + '="' + rawValue + '": Do not mix mustache interpolation ' +
625+
'and v-bind for "class" on the same element. Use one or the other.'
626+
)
627+
}
628+
}
618629
} else
619630

620631
// special attribute: transition

0 commit comments

Comments
 (0)