Skip to content

Commit 92582a8

Browse files
test(dom-to-react): update custom element with style snapshot
1 parent d4aa3c3 commit 92582a8

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

test/__snapshots__/dom-to-react.test.js.snap

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ exports[`domToReact converts SVG element with viewBox attribute 1`] = `
1515
</svg>
1616
`;
1717
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+
1826
exports[`domToReact converts multiple DOM nodes to React 1`] = `
1927
Array [
2028
<p>
@@ -52,13 +60,6 @@ exports[`domToReact does not escape <style> content 1`] = `
5260
/>
5361
`;
5462
55-
exports[`domToReact does not modify attributes on custom elements 1`] = `
56-
<custom-button
57-
class="myClass"
58-
custom-attribute="value"
59-
/>
60-
`;
61-
6263
exports[`domToReact skips doctype and comments 1`] = `
6364
Array [
6465
<p>
@@ -71,14 +72,21 @@ Array [
7172
`;
7273
7374
exports[`domToReact when React <16 removes unknown attributes 1`] = `
74-
<custom-button
75+
<custom-element
7576
className="myClass"
77+
style={
78+
Object {
79+
"OTransition": "all .5s",
80+
"lineHeight": "1",
81+
}
82+
}
7683
/>
7784
`;
7885
7986
exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
80-
<custom-button
87+
<custom-element
8188
class="myClass"
8289
custom-attribute="value"
90+
style="-o-transition: all .5s; line-height: 1;"
8391
/>
8492
`;

test/dom-to-react.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('domToReact', () => {
6868
expect(reactElement).toMatchSnapshot();
6969
});
7070

71-
it('does not modify attributes on custom elements', () => {
71+
it('converts custom element with attributes', () => {
7272
const reactElement = domToReact(htmlToDOM(data.html.customElement));
7373
expect(reactElement).toMatchSnapshot();
7474
});
@@ -115,7 +115,7 @@ describe('domToReact replace option', () => {
115115
if (node.name === 'p') {
116116
return React.createElement('p', {}, 'replaced foo');
117117
}
118-
if (node.name === 'custom-button') {
118+
if (node.name === 'custom-element') {
119119
return React.createElement(
120120
'custom-button',
121121
{

test/helpers/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports.html = {
1717
comment: '<!-- comment -->',
1818
doctype: '<!DOCTYPE html>',
1919
customElement:
20-
'<custom-button class="myClass" custom-attribute="value"></custom-button>'
20+
'<custom-element class="myClass" custom-attribute="value" style="-o-transition: all .5s; line-height: 1;"></custom-element>'
2121
};
2222

2323
/**

0 commit comments

Comments
 (0)