@@ -2,7 +2,6 @@ var _ = require('../../util')
2
2
var prefixes = [ '-webkit-' , '-moz-' , '-ms-' ]
3
3
var camelPrefixes = [ 'Webkit' , 'Moz' , 'ms' ]
4
4
var importantRE = / ! i m p o r t a n t ; ? $ /
5
- var camelRE = / ( [ a - z ] ) ( [ A - Z ] ) / g
6
5
var testEl = null
7
6
var propCache = { }
8
7
@@ -14,33 +13,33 @@ module.exports = {
14
13
if ( typeof value === 'string' ) {
15
14
this . el . style . cssText = value
16
15
} else if ( _ . isArray ( value ) ) {
17
- this . objectHandler ( value . reduce ( _ . extend , { } ) )
16
+ this . handleObject ( value . reduce ( _ . extend , { } ) )
18
17
} else {
19
- this . objectHandler ( value )
18
+ this . handleObject ( value || { } )
20
19
}
21
20
} ,
22
21
23
- objectHandler : function ( value ) {
22
+ handleObject : function ( value ) {
24
23
// cache object styles so that only changed props
25
24
// are actually updated.
26
25
var cache = this . cache || ( this . cache = { } )
27
- var prop , val
28
- for ( prop in cache ) {
29
- if ( ! ( prop in value ) ) {
30
- this . setProp ( prop , null )
31
- delete cache [ prop ]
26
+ var name , val
27
+ for ( name in cache ) {
28
+ if ( ! ( name in value ) ) {
29
+ this . handleSingle ( name , null )
30
+ delete cache [ name ]
32
31
}
33
32
}
34
- for ( prop in value ) {
35
- val = value [ prop ]
36
- if ( val !== cache [ prop ] ) {
37
- cache [ prop ] = val
38
- this . setProp ( prop , val )
33
+ for ( name in value ) {
34
+ val = value [ name ]
35
+ if ( val !== cache [ name ] ) {
36
+ cache [ name ] = val
37
+ this . handleSingle ( name , val )
39
38
}
40
39
}
41
40
} ,
42
41
43
- setProp : function ( prop , value ) {
42
+ handleSingle : function ( prop , value ) {
44
43
prop = normalize ( prop )
45
44
if ( ! prop ) return // unsupported prop
46
45
// cast possible numbers/booleans into strings
@@ -88,7 +87,7 @@ function normalize (prop) {
88
87
*/
89
88
90
89
function prefix ( prop ) {
91
- prop = prop . replace ( camelRE , '$1-$2' ) . toLowerCase ( )
90
+ prop = _ . hyphenate ( prop )
92
91
var camel = _ . camelize ( prop )
93
92
var upper = camel . charAt ( 0 ) . toUpperCase ( ) + camel . slice ( 1 )
94
93
if ( ! testEl ) {
0 commit comments