@@ -36,20 +36,37 @@ var ELEMENT_ATTRIBUTE_MAPPING = {
36
36
} ;
37
37
38
38
var HTMLDOMPropertyConfig = require ( 'react-dom/lib/HTMLDOMPropertyConfig' ) ;
39
+ var SVGDOMPropertyConfig = require ( 'react-dom/lib/SVGDOMPropertyConfig' ) ;
39
40
40
- // Populate property map with ReactJS's attribute and property mappings
41
- // TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attr
42
- for ( var propname in HTMLDOMPropertyConfig . Properties ) {
43
- if ( ! HTMLDOMPropertyConfig . Properties . hasOwnProperty ( propname ) ) {
44
- continue ;
41
+ /**
42
+ * Iterates over elements of object invokes iteratee for each element
43
+ *
44
+ * @param {object } obj Collection object
45
+ * @param {function } iteratee Callback function called in iterative processing
46
+ * @param {any } context This arg (aka Context)
47
+ */
48
+ function eachObj ( obj , iteratee , context ) {
49
+ for ( var key in obj ) {
50
+ if ( obj . hasOwnProperty ( key ) ) {
51
+ iteratee . call ( context || obj , key , obj [ key ] ) ;
52
+ }
45
53
}
54
+ }
46
55
47
- var mapFrom = HTMLDOMPropertyConfig . DOMAttributeNames [ propname ] || propname . toLowerCase ( ) ;
56
+ // Populate property map with ReactJS's attribute and property mappings
57
+ // TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attr
58
+ function mappingAttributesFromReactConfig ( config ) {
59
+ eachObj ( config . Properties , function ( propname ) {
60
+ var mapFrom = config . DOMAttributeNames [ propname ] || propname . toLowerCase ( ) ;
48
61
49
- if ( ! ATTRIBUTE_MAPPING [ mapFrom ] )
50
- ATTRIBUTE_MAPPING [ mapFrom ] = propname ;
62
+ if ( ! ATTRIBUTE_MAPPING [ mapFrom ] )
63
+ ATTRIBUTE_MAPPING [ mapFrom ] = propname ;
64
+ } ) ;
51
65
}
52
66
67
+ mappingAttributesFromReactConfig ( HTMLDOMPropertyConfig ) ;
68
+ mappingAttributesFromReactConfig ( SVGDOMPropertyConfig ) ;
69
+
53
70
/**
54
71
* Repeats a string a certain number of times.
55
72
* Also: the future is bright and consists of native string repetition:
@@ -562,12 +579,9 @@ StyleParser.prototype = {
562
579
*/
563
580
toJSXString : function ( ) {
564
581
var output = [ ] ;
565
- for ( var key in this . styles ) {
566
- if ( ! this . styles . hasOwnProperty ( key ) ) {
567
- continue ;
568
- }
569
- output . push ( this . toJSXKey ( key ) + ': ' + this . toJSXValue ( this . styles [ key ] ) ) ;
570
- }
582
+ eachObj ( this . styles , function ( key , value ) {
583
+ output . push ( this . toJSXKey ( key ) + ': ' + this . toJSXValue ( value ) ) ;
584
+ } , this ) ;
571
585
return output . join ( ', ' ) ;
572
586
} ,
573
587
0 commit comments