Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils');

const TEXT_NODE_TYPE = 3;

let React;
let ReactDOM;
let ReactDOMServer;
Expand All @@ -37,6 +39,8 @@ const {
itClientRenders,
renderIntoDom,
serverRender,
streamRender,
clientRenderOnServerString,
} = ReactDOMServerIntegrationUtils(initModules);

describe('ReactDOMServerIntegration', () => {
Expand All @@ -45,6 +49,11 @@ describe('ReactDOMServerIntegration', () => {
});

describe('form controls', function() {
function expectNode(node, type, value) {
expect(node).not.toBe(null);
expect(node.nodeType).toBe(type);
expect(node.nodeValue).toMatch(value);
}
describe('inputs', function() {
itRenders('an input with a value and an onChange', async render => {
const e = await render(<input value="foo" onChange={() => {}} />);
Expand Down Expand Up @@ -341,6 +350,31 @@ describe('ReactDOMServerIntegration', () => {
);
});

describe('options', function() {
itRenders('an option with multiple text children', async render => {
const e = await render(
<select value="bar" readOnly={true}>
<option value="bar">A {'B'}</option>
</select>,
0,
);
const option = e.options[0];
if (
render === serverRender ||
render === streamRender ||
render === clientRenderOnServerString
) {
// We have three nodes because there is a comment between them.
expect(option.childNodes.length).toBe(3);
expectNode(option.childNodes[0], TEXT_NODE_TYPE, 'A');
expectNode(option.childNodes[2], TEXT_NODE_TYPE, 'B');
} else {
expect(option.childNodes.length).toBe(1);
expectNode(option.childNodes[0], TEXT_NODE_TYPE, 'A B');
}
});
});

describe('user interaction', function() {
let ControlledInput,
ControlledTextArea,
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,10 @@ class ReactDOMServerRenderer {
props = Object.assign(
{
selected: undefined,
children: undefined,
},
props,
{
selected: selected,
children: optionChildren,
},
);
}
Expand Down