@@ -242,15 +242,15 @@ CompilerProto.compile = function (node, root) {
242
242
if ( repeatExp = utils . attr ( node , 'repeat' ) ) {
243
243
244
244
// repeat block cannot have v-id at the same time.
245
- directive = Directive . parse ( config . attrs . repeat , repeatExp , compiler , node )
245
+ directive = Directive . parse ( ' repeat' , repeatExp , compiler , node )
246
246
if ( directive ) {
247
247
compiler . bindDirective ( directive )
248
248
}
249
249
250
250
// v-component has 2nd highest priority
251
251
} else if ( ! root && ( componentExp = utils . attr ( node , 'component' ) ) ) {
252
252
253
- directive = Directive . parse ( config . attrs . component , componentExp , compiler , node )
253
+ directive = Directive . parse ( ' component' , componentExp , compiler , node )
254
254
if ( directive ) {
255
255
// component directive is a bit different from the others.
256
256
// when it has no argument, it should be treated as a
@@ -293,28 +293,44 @@ CompilerProto.compile = function (node, root) {
293
293
* Compile a normal node
294
294
*/
295
295
CompilerProto . compileNode = function ( node ) {
296
- var i , j , attrs = node . attributes
296
+ var i , j ,
297
+ attrs = node . attributes ,
298
+ prefix = config . prefix + '-'
297
299
// parse if has attributes
298
300
if ( attrs && attrs . length ) {
299
- var attr , valid , exps , exp
301
+ var attr , isDirective , exps , exp , directive
300
302
// loop through all attributes
301
303
i = attrs . length
302
304
while ( i -- ) {
303
305
attr = attrs [ i ]
304
- valid = false
305
- exps = Directive . split ( attr . value )
306
- // loop through clauses (separated by ",")
307
- // inside each attribute
308
- j = exps . length
309
- while ( j -- ) {
310
- exp = exps [ j ]
311
- var directive = Directive . parse ( attr . name , exp , this , node )
312
- if ( directive ) {
313
- valid = true
314
- this . bindDirective ( directive )
306
+ isDirective = false
307
+
308
+ if ( attr . name . indexOf ( prefix ) === 0 ) {
309
+ // a directive - split, parse and bind it.
310
+ isDirective = true
311
+ exps = Directive . split ( attr . value )
312
+ // loop through clauses (separated by ",")
313
+ // inside each attribute
314
+ j = exps . length
315
+ while ( j -- ) {
316
+ exp = exps [ j ]
317
+ directive = Directive . parse ( attr . name . slice ( prefix . length ) , exp , this , node )
318
+ if ( directive ) {
319
+ this . bindDirective ( directive )
320
+ }
321
+ }
322
+ } else {
323
+ // non directive attribute, check interpolation tags
324
+ exp = TextParser . parseAttr ( attr . value )
325
+ if ( exp ) {
326
+ directive = Directive . parse ( 'attr' , attr . name + ':' + exp , this , node )
327
+ if ( directive ) {
328
+ this . bindDirective ( directive )
329
+ }
315
330
}
316
331
}
317
- if ( valid ) node . removeAttribute ( attr . name )
332
+
333
+ if ( isDirective ) node . removeAttribute ( attr . name )
318
334
}
319
335
}
320
336
// recursively compile childNodes
@@ -332,8 +348,7 @@ CompilerProto.compileNode = function (node) {
332
348
CompilerProto . compileTextNode = function ( node ) {
333
349
var tokens = TextParser . parse ( node . nodeValue )
334
350
if ( ! tokens ) return
335
- var dirname = config . attrs . text ,
336
- el , token , directive
351
+ var el , token , directive
337
352
for ( var i = 0 , l = tokens . length ; i < l ; i ++ ) {
338
353
token = tokens [ i ]
339
354
if ( token . key ) { // a binding
@@ -346,7 +361,7 @@ CompilerProto.compileTextNode = function (node) {
346
361
}
347
362
} else { // a binding
348
363
el = document . createTextNode ( '' )
349
- directive = Directive . parse ( dirname , token . key , this , el )
364
+ directive = Directive . parse ( 'text' , token . key , this , el )
350
365
if ( directive ) {
351
366
this . bindDirective ( directive )
352
367
}
0 commit comments