File tree Expand file tree Collapse file tree 9 files changed +460
-280
lines changed Expand file tree Collapse file tree 9 files changed +460
-280
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ exports[`domToReact converts SVG element with viewBox attribute 1`] = `
15
15
</svg >
16
16
`;
17
17
18
+ exports[`domToReact converts custom element with attributes 1`] = `
19
+ <custom-element
20
+ class = " myClass"
21
+ custom-attribute = " value"
22
+ style = " -o-transition: all .5s; line-height: 1;"
23
+ />
24
+ `;
25
+
18
26
exports[`domToReact converts multiple DOM nodes to React 1`] = `
19
27
Array [
20
28
<p >
@@ -52,13 +60,6 @@ exports[`domToReact does not escape <style> content 1`] = `
52
60
/>
53
61
`;
54
62
55
- exports[`domToReact does not modify attributes on custom elements 1`] = `
56
- <custom-button
57
- class = " myClass"
58
- custom-attribute = " value"
59
- />
60
- `;
61
-
62
63
exports[`domToReact skips doctype and comments 1`] = `
63
64
Array [
64
65
<p >
@@ -71,14 +72,21 @@ Array [
71
72
`;
72
73
73
74
exports[`domToReact when React <16 removes unknown attributes 1`] = `
74
- <custom-button
75
+ <custom-element
75
76
className = " myClass"
77
+ style = {
78
+ Object {
79
+ " OTransition" : " all .5s" ,
80
+ " lineHeight" : " 1" ,
81
+ }
82
+ }
76
83
/>
77
84
`;
78
85
79
86
exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
80
- <custom-button
87
+ <custom-element
81
88
class = " myClass"
82
89
custom-attribute = " value"
90
+ style = " -o-transition: all .5s; line-height: 1;"
83
91
/>
84
92
`;
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` HTMLReactParser parses SVG 1` ] = `
4
+ <svg
5
+ height = " 400"
6
+ width = " 450"
7
+ >
8
+ <path
9
+ d = " M 100 350 l 150 -300"
10
+ fill = " none"
11
+ id = " lineAB"
12
+ stroke = " red"
13
+ strokeWidth = " 3"
14
+ />
15
+ <g
16
+ fill = " black"
17
+ stroke = " black"
18
+ strokeWidth = " 3"
19
+ >
20
+ <circle
21
+ cx = " 100"
22
+ cy = " 350"
23
+ id = " pointA"
24
+ r = " 3"
25
+ />
26
+ </g >
27
+ <g
28
+ fill = " black"
29
+ fontFamily = " sans-serif"
30
+ fontSize = " 30"
31
+ stroke = " none"
32
+ textAnchor = " middle"
33
+ >
34
+ <text
35
+ dx = " -30"
36
+ x = " 100"
37
+ y = " 350"
38
+ >
39
+ A
40
+ </text >
41
+ </g >
42
+ Your browser does not support inline SVG.
43
+ </svg >
44
+ ` ;
45
+
46
+ exports [` HTMLReactParser parses complex HTML with doctype 1` ] = `
47
+ <html >
48
+ <head >
49
+ <meta
50
+ charSet = " utf-8"
51
+ />
52
+ <title >
53
+ Title
54
+ </title >
55
+ <link
56
+ href = " style.css"
57
+ rel = " stylesheet"
58
+ />
59
+ </head >
60
+ <body >
61
+ <header
62
+ id = " header"
63
+ >
64
+ Header
65
+ </header >
66
+ <h1
67
+ style = {
68
+ Object {
69
+ " color" : " #000" ,
70
+ " fontSize" : " 42px" ,
71
+ }
72
+ }
73
+ >
74
+ Heading
75
+ </h1 >
76
+ <hr />
77
+ <p >
78
+ Paragraph
79
+ </p >
80
+ <img
81
+ src = " image.jpg"
82
+ />
83
+ <div
84
+ className = " class1 class2"
85
+ >
86
+ Some
87
+ <em >
88
+ text
89
+ </em >
90
+ .
91
+ </div >
92
+ <script
93
+ dangerouslySetInnerHTML = {
94
+ Object {
95
+ " __html" : " alert();" ,
96
+ }
97
+ }
98
+ />
99
+ </body >
100
+ </html >
101
+ ` ;
102
+
103
+ exports [` HTMLReactParser parses empty <script > 1`] = `<script />`;
104
+
105
+ exports[`HTMLReactParser parses empty <style > 1`] = `<style />`;
106
+
107
+ exports[`HTMLReactParser parses multiple HTML elements 1`] = `
108
+ Array [
109
+ <p >
110
+ foo
111
+ </p >,
112
+ <p >
113
+ bar
114
+ </p >,
115
+ ]
116
+ `;
117
+
118
+ exports[`HTMLReactParser parses single HTML element 1`] = `
119
+ <p >
120
+ foo
121
+ </p >
122
+ `;
123
+
124
+ exports[`HTMLReactParser parses single HTML element with comment 1`] = `
125
+ <p >
126
+ foo
127
+ </p >
128
+ `;
129
+
130
+ exports[`htmlparser2 option parses XHTML with xmlMode enabled 1`] = `
131
+ <ul >
132
+ <li />
133
+ <li />
134
+ </ul >
135
+ `;
136
+
137
+ exports[`replace option does not replace the element if an invalid React element is returned 1`] = `
138
+ <html >
139
+ <head >
140
+ <meta
141
+ charSet = " utf-8"
142
+ />
143
+ <title >
144
+ Title
145
+ </title >
146
+ <link
147
+ href = " style.css"
148
+ rel = " stylesheet"
149
+ />
150
+ </head >
151
+ <body >
152
+ <header
153
+ id = " header"
154
+ >
155
+ Header
156
+ </header >
157
+ <h1
158
+ style = {
159
+ Object {
160
+ " color" : " #000" ,
161
+ " fontSize" : " 42px" ,
162
+ }
163
+ }
164
+ >
165
+ Heading
166
+ </h1 >
167
+ <hr />
168
+ <p >
169
+ Paragraph
170
+ </p >
171
+ <img
172
+ src = " image.jpg"
173
+ />
174
+ <div
175
+ className = " class1 class2"
176
+ >
177
+ Some
178
+ <em >
179
+ text
180
+ </em >
181
+ .
182
+ </div >
183
+ <script
184
+ dangerouslySetInnerHTML = {
185
+ Object {
186
+ " __html" : " alert();" ,
187
+ }
188
+ }
189
+ />
190
+ </body >
191
+ </html >
192
+ `;
193
+
194
+ exports[`replace option replaces the element if a valid React element is returned 1`] = `
195
+ <html >
196
+ <head >
197
+ <meta
198
+ charSet = " utf-8"
199
+ />
200
+ <title >
201
+ Replaced Title
202
+ </title >
203
+ <link
204
+ href = " style.css"
205
+ rel = " stylesheet"
206
+ />
207
+ </head >
208
+ <body >
209
+ <header
210
+ id = " header"
211
+ >
212
+ Header
213
+ </header >
214
+ <h1
215
+ style = {
216
+ Object {
217
+ " color" : " #000" ,
218
+ " fontSize" : " 42px" ,
219
+ }
220
+ }
221
+ >
222
+ Heading
223
+ </h1 >
224
+ <hr />
225
+ <p >
226
+ Paragraph
227
+ </p >
228
+ <img
229
+ src = " image.jpg"
230
+ />
231
+ <div
232
+ className = " class1 class2"
233
+ >
234
+ Some
235
+ <em >
236
+ text
237
+ </em >
238
+ .
239
+ </div >
240
+ <script
241
+ dangerouslySetInnerHTML = {
242
+ Object {
243
+ " __html" : " alert();" ,
244
+ }
245
+ }
246
+ />
247
+ </body >
248
+ </html >
249
+ `;
Original file line number Diff line number Diff line change 1
- /**
2
- * HTML.
3
- */
4
- module . exports . html = {
1
+ module . exports = {
5
2
single : '<p>foo</p>' ,
6
3
multiple : '<p>foo</p><p>bar</p>' ,
7
4
nested : '<div><p>foo <em>bar</em></p></div>' ,
@@ -17,14 +14,5 @@ module.exports.html = {
17
14
comment : '<!-- comment -->' ,
18
15
doctype : '<!DOCTYPE html>' ,
19
16
customElement :
20
- '<custom-button class="myClass" custom-attribute="value"></custom-button>'
21
- } ;
22
-
23
- /**
24
- * SVG.
25
- */
26
- module . exports . svg = {
27
- simple : '<svg viewBox="0 0 512 512" id="foo">Inner</svg>' ,
28
- complex :
29
- '<svg height="400" width="450"><path id="lineAB" d="M 100 350 l 150 -300" stroke="red" stroke-width="3" fill="none"></path><g stroke="black" stroke-width="3" fill="black"><circle id="pointA" cx="100" cy="350" r="3"></circle></g><g font-size="30" font-family="sans-serif" fill="black" stroke="none" text-anchor="middle"><text x="100" y="350" dx="-30">A</text></g>Your browser does not support inline SVG.</svg>'
17
+ '<custom-element class="myClass" custom-attribute="value" style="-o-transition: all .5s; line-height: 1;"></custom-element>'
30
18
} ;
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ html : require ( './html' ) ,
3
+ svg : require ( './svg' )
4
+ } ;
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ simple : '<svg viewBox="0 0 512 512" id="foo">Inner</svg>' ,
3
+ complex :
4
+ '<svg height="400" width="450"><path id="lineAB" d="M 100 350 l 150 -300" stroke="red" stroke-width="3" fill="none"></path><g stroke="black" stroke-width="3" fill="black"><circle id="pointA" cx="100" cy="350" r="3"></circle></g><g font-size="30" font-family="sans-serif" fill="black" stroke="none" text-anchor="middle"><text x="100" y="350" dx="-30">A</text></g>Your browser does not support inline SVG.</svg>'
5
+ } ;
You can’t perform that action at this time.
0 commit comments