Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: React DOM crashes when <option> contains three interpolated valu…
…e if one is a conditional. #11911
  • Loading branch information
stephenkingsley committed Jan 23, 2018
commit 752acda3e66ff65c8de6bba09ab68fcde866e90a
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMOption-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('ReactDOMOption', () => {
' in div (at **)\n' +
' in option (at **)',
);
expect(node.innerHTML).toBe('1 2');
expect(node.innerHTML).toBe('1 <div></div> 2');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a behavior change. I don't think we want this.

ReactTestUtils.renderIntoDocument(el);
});

Expand Down
11 changes: 10 additions & 1 deletion packages/react-dom/src/client/ReactDOMFiberOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ function flattenChildren(children) {
if (child == null) {
return;
}

if (typeof child === 'string' || typeof child === 'number') {
content += child;
if (typeof children === 'string') {
content += child;
} else {
if (!content) {
content = document.createElement('span');
}
const textNode = document.createTextNode(child);
content.appendChild(textNode);
}
}
});

Expand Down
24 changes: 12 additions & 12 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,43 @@
"filename": "react-dom.development.js",
"bundleType": "UMD_DEV",
"packageName": "react-dom",
"size": 569094,
"gzip": 133855
"size": 569227,
"gzip": 133885
},
{
"filename": "react-dom.production.min.js",
"bundleType": "UMD_PROD",
"packageName": "react-dom",
"size": 94278,
"gzip": 30883
"size": 94375,
"gzip": 30893
},
{
"filename": "react-dom.development.js",
"bundleType": "NODE_DEV",
"packageName": "react-dom",
"size": 553111,
"gzip": 130124
"size": 553244,
"gzip": 130155
},
{
"filename": "react-dom.production.min.js",
"bundleType": "NODE_PROD",
"packageName": "react-dom",
"size": 92696,
"gzip": 29923
"size": 92793,
"gzip": 29943
},
{
"filename": "ReactDOM-dev.js",
"bundleType": "FB_DEV",
"packageName": "react-dom",
"size": 571833,
"gzip": 132486
"size": 571966,
"gzip": 132522
},
{
"filename": "ReactDOM-prod.js",
"bundleType": "FB_PROD",
"packageName": "react-dom",
"size": 267496,
"gzip": 51395
"size": 267649,
"gzip": 51426
},
{
"filename": "react-dom-test-utils.development.js",
Expand Down