From 0d9515b65733b0d9c25c0bba08d1f3b0470c554b Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 10 Apr 2023 22:03:24 -0400 Subject: [PATCH] Remove initOption --- .../src/client/ReactDOMComponent.js | 3 +-- .../src/client/ReactDOMOption.js | 7 ------ .../src/__tests__/ReactDOMSelect-test.js | 22 +++++++++---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index e2ba29ceb3aed..91bab1c90f2ef 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -32,7 +32,7 @@ import { updateInput, restoreControlledInputState, } from './ReactDOMInput'; -import {initOption, validateOptionProps} from './ReactDOMOption'; +import {validateOptionProps} from './ReactDOMOption'; import { validateSelectProps, initSelect, @@ -995,7 +995,6 @@ export function setInitialProperties( } } } - initOption(domElement, props); return; } case 'dialog': { diff --git a/packages/react-dom-bindings/src/client/ReactDOMOption.js b/packages/react-dom-bindings/src/client/ReactDOMOption.js index 7907609ad88fe..19ad588ba5309 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMOption.js +++ b/packages/react-dom-bindings/src/client/ReactDOMOption.js @@ -59,10 +59,3 @@ export function validateOptionProps(element: Element, props: Object) { } } } - -export function initOption(element: Element, props: Object) { - // value="" should make a value attribute (#6219) - if (props.value != null) { - element.setAttribute('value', toString(getToStringValue(props.value))); - } -} diff --git a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js index 901d20f8c2d83..2969e9cf1fd9a 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js @@ -849,7 +849,7 @@ describe('ReactDOMSelect', () => { }); describe('When given a Symbol value', () => { - it('treats initial Symbol value as an empty string', () => { + it('treats initial Symbol value as missing', () => { let node; expect(() => { @@ -862,10 +862,10 @@ describe('ReactDOMSelect', () => { ); }).toErrorDev('Invalid value for prop `value`'); - expect(node.value).toBe(''); + expect(node.value).toBe('A Symbol!'); }); - it('treats updated Symbol value as an empty string', () => { + it('treats updated Symbol value as missing', () => { let node; expect(() => { @@ -888,7 +888,7 @@ describe('ReactDOMSelect', () => { , ); - expect(node.value).toBe(''); + expect(node.value).toBe('A Symbol!'); }); it('treats initial Symbol defaultValue as an empty string', () => { @@ -904,7 +904,7 @@ describe('ReactDOMSelect', () => { ); }).toErrorDev('Invalid value for prop `value`'); - expect(node.value).toBe(''); + expect(node.value).toBe('A Symbol!'); }); it('treats updated Symbol defaultValue as an empty string', () => { @@ -930,12 +930,12 @@ describe('ReactDOMSelect', () => { , ); - expect(node.value).toBe(''); + expect(node.value).toBe('A Symbol!'); }); }); describe('When given a function value', () => { - it('treats initial function value as an empty string', () => { + it('treats initial function value as missing', () => { let node; expect(() => { @@ -948,7 +948,7 @@ describe('ReactDOMSelect', () => { ); }).toErrorDev('Invalid value for prop `value`'); - expect(node.value).toBe(''); + expect(node.value).toBe('A function!'); }); it('treats initial function defaultValue as an empty string', () => { @@ -964,7 +964,7 @@ describe('ReactDOMSelect', () => { ); }).toErrorDev('Invalid value for prop `value`'); - expect(node.value).toBe(''); + expect(node.value).toBe('A function!'); }); it('treats updated function value as an empty string', () => { @@ -990,7 +990,7 @@ describe('ReactDOMSelect', () => { , ); - expect(node.value).toBe(''); + expect(node.value).toBe('A function!'); }); it('treats updated function defaultValue as an empty string', () => { @@ -1016,7 +1016,7 @@ describe('ReactDOMSelect', () => { , ); - expect(node.value).toBe(''); + expect(node.value).toBe('A function!'); }); });