File tree 2 files changed +19
-5
lines changed 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ var React = require('react');
2
2
var attributesToProps = require ( './attributes-to-props' ) ;
3
3
var utilities = require ( './utilities' ) ;
4
4
5
+ var setStyleProp = utilities . setStyleProp ;
6
+
5
7
/**
6
8
* Converts DOM nodes to React elements.
7
9
*
@@ -62,8 +64,10 @@ function domToReact(nodes, options) {
62
64
}
63
65
64
66
props = node . attribs ;
65
- if ( ! skipAttributesToProps ( node ) ) {
66
- props = attributesToProps ( node . attribs ) ;
67
+ if ( skipAttributesToProps ( node ) ) {
68
+ setStyleProp ( props . style , props ) ;
69
+ } else if ( props ) {
70
+ props = attributesToProps ( props ) ;
67
71
}
68
72
69
73
children = null ;
@@ -110,7 +114,7 @@ function domToReact(nodes, options) {
110
114
111
115
/**
112
116
* Determines whether DOM element attributes should be transformed to props.
113
- * Web Components (custom elements) should not have their attributes transformed.
117
+ * Web Components should not have their attributes transformed except for `style` .
114
118
*
115
119
* @param {DomElement } node
116
120
* @return {boolean }
Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ exports[`domToReact converts custom element with attributes 1`] = `
19
19
<custom-element
20
20
class = " myClass"
21
21
custom-attribute = " value"
22
- style = " -o-transition: all .5s; line-height: 1;"
22
+ style = {
23
+ Object {
24
+ " OTransition" : " all .5s" ,
25
+ " lineHeight" : " 1" ,
26
+ }
27
+ }
23
28
/>
24
29
`;
25
30
@@ -87,6 +92,11 @@ exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
87
92
<custom-element
88
93
class = " myClass"
89
94
custom-attribute = " value"
90
- style = " -o-transition: all .5s; line-height: 1;"
95
+ style = {
96
+ Object {
97
+ " OTransition" : " all .5s" ,
98
+ " lineHeight" : " 1" ,
99
+ }
100
+ }
91
101
/>
92
102
`;
You can’t perform that action at this time.
0 commit comments