File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,11 @@ module.exports = {
45
45
'in valid native attributes. "' + attr + '" ' +
46
46
'is not a valid attribute on <' + this . el . tagName . toLowerCase ( ) + '>.'
47
47
)
48
+ this . el . removeAttribute ( attr )
48
49
this . invalid = true
49
50
}
50
51
52
+ /* istanbul ignore if */
51
53
if ( process . env . NODE_ENV !== 'production' ) {
52
54
var raw = attr + '="' + this . descriptor . raw + '": '
53
55
// warn src
@@ -71,7 +73,9 @@ module.exports = {
71
73
} ,
72
74
73
75
update : function ( value ) {
74
- if ( this . invalid ) return
76
+ if ( this . invalid ) {
77
+ return
78
+ }
75
79
var attr = this . arg
76
80
if ( inputProps [ attr ] && attr in this . el ) {
77
81
if ( ! this . valueRemoved ) {
Original file line number Diff line number Diff line change @@ -469,5 +469,48 @@ if (_.inBrowser) {
469
469
expect ( el . innerHTML ) . toBe ( '<test test="1">{{a}}</test>' )
470
470
} )
471
471
472
+ it ( 'attribute interpolation' , function ( done ) {
473
+ var vm = new Vue ( {
474
+ el : el ,
475
+ template : '<div id="{{a}}" class="b {{c}} d"></div>' ,
476
+ data : {
477
+ a : 'aaa' ,
478
+ c : 'ccc'
479
+ }
480
+ } )
481
+ expect ( el . innerHTML ) . toBe ( '<div id="aaa" class="b ccc d"></div>' )
482
+ vm . a = 'aa'
483
+ vm . c = 'cc'
484
+ _ . nextTick ( function ( ) {
485
+ expect ( el . innerHTML ) . toBe ( '<div id="aa" class="b cc d"></div>' )
486
+ done ( )
487
+ } )
488
+ } )
489
+
490
+ it ( 'attribute interpolation: special cases' , function ( ) {
491
+ new Vue ( {
492
+ el : el ,
493
+ template : '<label for="{{a}}" data-test="{{b}}"></label><form accept-charset="{{c}}"></form>' ,
494
+ data : {
495
+ a : 'aaa' ,
496
+ b : 'bbb' ,
497
+ c : 'UTF-8'
498
+ }
499
+ } )
500
+ expect ( el . innerHTML ) . toBe ( '<label for="aaa" data-test="bbb"></label><form accept-charset="UTF-8"></form>' )
501
+ } )
502
+
503
+ it ( 'attribute interpolation: warn invalid' , function ( ) {
504
+ new Vue ( {
505
+ el : el ,
506
+ template : '<div hello="{{a}}"></div>' ,
507
+ data : {
508
+ a : '123'
509
+ }
510
+ } )
511
+ expect ( el . innerHTML ) . toBe ( '<div></div>' )
512
+ expect ( hasWarned ( _ , 'attribute interpolation is allowed only in valid native attributes' ) ) . toBe ( true )
513
+ } )
514
+
472
515
} )
473
516
}
You can’t perform that action at this time.
0 commit comments