@@ -108,28 +108,46 @@ if (_.inBrowser) {
108108 el . setAttribute ( ':class' , 'a' )
109109 el . setAttribute ( ':style' , 'b' )
110110 el . setAttribute ( ':title' , 'c' )
111+
112+ // The order of setAttribute is not guaranteed to be the same with
113+ // the order of attribute enumberation, therefore we need to save
114+ // it here!
115+ var descriptors = {
116+ ':class' : {
117+ name : 'class' ,
118+ attr : ':class' ,
119+ expression : 'a' ,
120+ def : internalDirectives . class
121+ } ,
122+ ':style' : {
123+ name : 'style' ,
124+ attr : ':style' ,
125+ expression : 'b' ,
126+ def : internalDirectives . style
127+ } ,
128+ ':title' : {
129+ name : 'bind' ,
130+ attr : ':title' ,
131+ expression : 'c' ,
132+ arg : 'title' ,
133+ def : publicDirectives . bind
134+ }
135+ }
136+ var expects = [ ] . map . call ( el . attributes , function ( attr ) {
137+ return descriptors [ attr . name ]
138+ } )
139+
111140 var linker = compile ( el , Vue . options )
112141 linker ( vm , el )
113142 expect ( vm . _bindDir . calls . count ( ) ) . toBe ( 3 )
114- // 1
115- var args = vm . _bindDir . calls . argsFor ( 0 )
116- expect ( args [ 0 ] . name ) . toBe ( 'class' )
117- expect ( args [ 0 ] . expression ) . toBe ( 'a' )
118- expect ( args [ 0 ] . def ) . toBe ( internalDirectives . class )
119- expect ( args [ 1 ] ) . toBe ( el )
120- // 2
121- args = vm . _bindDir . calls . argsFor ( 1 )
122- expect ( args [ 0 ] . name ) . toBe ( 'style' )
123- expect ( args [ 0 ] . expression ) . toBe ( 'b' )
124- expect ( args [ 0 ] . def ) . toBe ( internalDirectives . style )
125- expect ( args [ 1 ] ) . toBe ( el )
126- // 3
127- args = vm . _bindDir . calls . argsFor ( 2 )
128- expect ( args [ 0 ] . name ) . toBe ( 'bind' )
129- expect ( args [ 0 ] . expression ) . toBe ( 'c' )
130- expect ( args [ 0 ] . arg ) . toBe ( 'title' )
131- expect ( args [ 0 ] . def ) . toBe ( publicDirectives . bind )
132- expect ( args [ 1 ] ) . toBe ( el )
143+
144+ expects . forEach ( function ( e , i ) {
145+ var args = vm . _bindDir . calls . argsFor ( i )
146+ for ( var key in e ) {
147+ expect ( args [ 0 ] [ key ] ) . toBe ( e [ key ] )
148+ }
149+ expect ( args [ 1 ] ) . toBe ( el )
150+ } )
133151 } )
134152
135153 it ( 'v-on shorthand' , function ( ) {
0 commit comments