File tree Expand file tree Collapse file tree 5 files changed +30
-6
lines changed
Filter options
Expand file tree Collapse file tree 5 files changed +30
-6
lines changed
Original file line number Diff line number Diff line change 27
27
"build" : " node build/build.js" ,
28
28
"install-hook" : " ln -s ../../build/git-hooks/pre-commit .git/hooks/pre-commit" ,
29
29
"dev" : " webpack --watch --config build/webpack.dev.config.js & npm run serve-test" ,
30
- "serve-test" : " webpack-dev-server --config build/webpack.test.config.js" ,
30
+ "serve-test" : " webpack-dev-server --config build/webpack.test.config.js --host 0.0.0.0 " ,
31
31
"build-test" : " webpack --config build/webpack.test.config.js" ,
32
32
"lint" : " eslint src/** test/e2e/** test/unit/specs/** build/**.js" ,
33
33
"e2e" : " casperjs test --concise ./test/e2e" ,
Original file line number Diff line number Diff line change @@ -652,8 +652,12 @@ function compileDirectives (attrs, options) {
652
652
// attribute interpolations
653
653
if ( tokens ) {
654
654
value = tokensToExp ( tokens )
655
- arg = name
656
- pushDir ( 'bind' , publicDirectives . bind , true )
655
+ if ( name === 'class' ) {
656
+ pushDir ( 'class' , internalDirectives [ 'class' ] , true )
657
+ } else {
658
+ arg = name
659
+ pushDir ( 'bind' , publicDirectives . bind , true )
660
+ }
657
661
// warn against mixing mustaches with v-bind
658
662
if ( process . env . NODE_ENV !== 'production' ) {
659
663
if ( name === 'class' && Array . prototype . some . call ( attrs , function ( attr ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
warn
11
11
} from './util/index'
12
12
import Watcher from './watcher'
13
+ import { removeTags } from './parsers/text'
13
14
import { parseExpression , isSimplePath } from './parsers/expression'
14
15
15
16
function noop ( ) { }
@@ -82,7 +83,15 @@ Directive.prototype._bind = function () {
82
83
this . el && this . el . removeAttribute
83
84
) {
84
85
var attr = descriptor . attr || ( 'v-' + name )
85
- this . el . removeAttribute ( attr )
86
+ if ( attr !== 'class' ) {
87
+ this . el . removeAttribute ( attr )
88
+ } else {
89
+ // for class interpolations, only remove the parts that
90
+ // need to be interpolated.
91
+ this . el . className = removeTags ( this . el . className )
92
+ . trim ( )
93
+ . replace ( / \s + / g, ' ' )
94
+ }
86
95
}
87
96
88
97
// copy def properties
Original file line number Diff line number Diff line change @@ -159,3 +159,14 @@ function inlineFilters (exp, single) {
159
159
}
160
160
}
161
161
}
162
+
163
+ /**
164
+ * Replace all interpolation tags in a piece of text.
165
+ *
166
+ * @param {String } text
167
+ * @return {String }
168
+ */
169
+
170
+ export function removeTags ( text ) {
171
+ return text . replace ( tagRE , '' )
172
+ }
Original file line number Diff line number Diff line change @@ -516,12 +516,12 @@ describe('Compile', function () {
516
516
}
517
517
} )
518
518
expect ( el . firstChild . id ) . toBe ( 'aaa' )
519
- expect ( el . firstChild . className ) . toBe ( 'b ccc d ' )
519
+ expect ( el . firstChild . className ) . toBe ( 'b d ccc ' )
520
520
vm . a = 'aa'
521
521
vm . c = 'cc'
522
522
_ . nextTick ( function ( ) {
523
523
expect ( el . firstChild . id ) . toBe ( 'aa' )
524
- expect ( el . firstChild . className ) . toBe ( 'b cc d ' )
524
+ expect ( el . firstChild . className ) . toBe ( 'b d cc ' )
525
525
done ( )
526
526
} )
527
527
} )
You can’t perform that action at this time.
0 commit comments