File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,12 @@ module.exports = {
1414 if ( this . arg ) {
1515 this . setProp ( this . arg , value )
1616 } else {
17- if ( typeof value === 'object' ) {
18- this . objectHandler ( value )
19- } else {
17+ if ( typeof value === 'string' ) {
2018 this . el . style . cssText = value
19+ } else if ( _ . isArray ( value ) ) {
20+ this . objectHandler ( value . reduce ( _ . extend , { } ) )
21+ } else {
22+ this . objectHandler ( value )
2123 }
2224 }
2325 } ,
@@ -59,7 +61,6 @@ module.exports = {
5961 this . el . style . removeProperty ( prop )
6062 }
6163 }
62-
6364}
6465
6566/**
Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ if (_.inBrowser) {
8383 expect ( el . style . getPropertyValue ( 'padding' ) ) . toBeFalsy ( )
8484 } )
8585
86+ it ( 'update with array of objects' , function ( ) {
87+ el . style . padding = '10px'
88+ dir . update ( [ { color : 'red' } , { marginRight : '30px' } ] )
89+ expect ( el . style . getPropertyValue ( 'color' ) ) . toBe ( 'red' )
90+ expect ( el . style . getPropertyValue ( 'margin-right' ) ) . toBe ( '30px' )
91+ expect ( el . style . getPropertyValue ( 'padding' ) ) . toBe ( '10px' )
92+ dir . update ( [ { color : 'blue' } , { padding : null } ] )
93+ expect ( el . style . getPropertyValue ( 'color' ) ) . toBe ( 'blue' )
94+ expect ( el . style . getPropertyValue ( 'margin-right' ) ) . toBeFalsy ( )
95+ expect ( el . style . getPropertyValue ( 'padding' ) ) . toBeFalsy ( )
96+ } )
97+
8698 it ( 'update with object and auto prefix' , function ( ) {
8799 var prop = checkPrefixedProp ( 'transform' )
88100 var val = 'scale(0.5)'
You can’t perform that action at this time.
0 commit comments