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 = {
14
14
if ( this . arg ) {
15
15
this . setProp ( this . arg , value )
16
16
} else {
17
- if ( typeof value === 'object' ) {
18
- this . objectHandler ( value )
19
- } else {
17
+ if ( typeof value === 'string' ) {
20
18
this . el . style . cssText = value
19
+ } else if ( _ . isArray ( value ) ) {
20
+ this . objectHandler ( value . reduce ( _ . extend , { } ) )
21
+ } else {
22
+ this . objectHandler ( value )
21
23
}
22
24
}
23
25
} ,
@@ -59,7 +61,6 @@ module.exports = {
59
61
this . el . style . removeProperty ( prop )
60
62
}
61
63
}
62
-
63
64
}
64
65
65
66
/**
Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ if (_.inBrowser) {
83
83
expect ( el . style . getPropertyValue ( 'padding' ) ) . toBeFalsy ( )
84
84
} )
85
85
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
+
86
98
it ( 'update with object and auto prefix' , function ( ) {
87
99
var prop = checkPrefixedProp ( 'transform' )
88
100
var val = 'scale(0.5)'
You can’t perform that action at this time.
0 commit comments