@@ -15,6 +15,8 @@ module.exports = {
15
15
this . setProp ( this . arg , value )
16
16
} else {
17
17
if ( typeof value === 'object' ) {
18
+ // cache object styles so that only changed props
19
+ // are actually updated.
18
20
if ( ! this . cache ) this . cache = { }
19
21
for ( var prop in value ) {
20
22
this . setProp ( prop , value [ prop ] )
@@ -32,6 +34,7 @@ module.exports = {
32
34
33
35
setProp : function ( prop , value ) {
34
36
prop = normalize ( prop )
37
+ if ( ! prop ) return // unsupported prop
35
38
// cast possible numbers/booleans into strings
36
39
if ( value != null ) value += ''
37
40
if ( value ) {
@@ -49,6 +52,16 @@ module.exports = {
49
52
50
53
}
51
54
55
+ /**
56
+ * Normalize a CSS property name.
57
+ * - cache result
58
+ * - auto prefix
59
+ * - camelCase -> dash-case
60
+ *
61
+ * @param {String } prop
62
+ * @return {String }
63
+ */
64
+
52
65
function normalize ( prop ) {
53
66
if ( propCache [ prop ] ) {
54
67
return propCache [ prop ]
@@ -58,6 +71,14 @@ function normalize (prop) {
58
71
return res
59
72
}
60
73
74
+ /**
75
+ * Auto detect the appropriate prefix for a CSS property.
76
+ * https://gist.github.com/paulirish/523692
77
+ *
78
+ * @param {String } prop
79
+ * @return {String }
80
+ */
81
+
61
82
function prefix ( prop ) {
62
83
prop = prop . replace ( camelRE , '$1-$2' ) . toLowerCase ( )
63
84
var camel = _ . camelize ( prop )
0 commit comments