diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
index 1ad9b0bb64540..6729f994fdafa 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
@@ -246,4 +246,34 @@ describe('ReactDOMServerIntegrationSelect', () => {
expect(option.selected).toBe(true);
},
);
+
+ itRenders(
+ 'a boolean true select value match the string "true"',
+ async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.firstChild.selected).toBe(false);
+ expect(e.lastChild.selected).toBe(true);
+ },
+ );
+
+ itRenders(
+ 'a missing select value does not match the string "undefined"',
+ async render => {
+ const e = await render(
+ ,
+ 1,
+ );
+ expect(e.firstChild.selected).toBe(true);
+ expect(e.lastChild.selected).toBe(false);
+ },
+ );
});
diff --git a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js
index 7cc5c72a16e5f..a42cb3188722b 100644
--- a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+++ b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js
@@ -749,7 +749,7 @@ function pushStartOption(
}
}
- if (selectedValue !== null) {
+ if (selectedValue != null) {
let stringValue;
if (value !== null) {
if (__DEV__) {
@@ -782,8 +782,13 @@ function pushStartOption(
break;
}
}
- } else if (selectedValue === stringValue) {
- target.push(selectedMarkerAttribute);
+ } else {
+ if (__DEV__) {
+ checkAttributeStringCoercion(selectedValue, 'select.value');
+ }
+ if ('' + selectedValue === stringValue) {
+ target.push(selectedMarkerAttribute);
+ }
}
} else if (selected) {
target.push(selectedMarkerAttribute);