diff --git a/src/renderers/dom/client/wrappers/ReactDOMOption.js b/src/renderers/dom/client/wrappers/ReactDOMOption.js index 917ed0ee4a167..18f9bc631ebfd 100644 --- a/src/renderers/dom/client/wrappers/ReactDOMOption.js +++ b/src/renderers/dom/client/wrappers/ReactDOMOption.js @@ -12,6 +12,7 @@ 'use strict'; var ReactChildren = require('ReactChildren'); +var ReactDOMComponentTree = require('ReactDOMComponentTree'); var ReactDOMSelect = require('ReactDOMSelect'); var warning = require('warning'); @@ -57,6 +58,15 @@ var ReactDOMOption = { inst._wrapperState = {selected: selected}; }, + postMountWrapper: function(inst) { + // value="" should make a value attribute (#6219) + var props = inst._currentElement.props; + if (props.value != null) { + var node = ReactDOMComponentTree.getNodeFromInstance(inst); + node.setAttribute('value', props.value); + } + }, + getNativeProps: function(inst, props) { var nativeProps = Object.assign({selected: undefined, children: undefined}, props); diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js index 0d52d83df373b..4b78000f264c0 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js @@ -71,4 +71,15 @@ describe('ReactDOMOption', function() { var node = ReactDOM.findDOMNode(stub); expect(node.innerHTML).toBe('foobar'); }); + + it('should set attribute for empty value', function() { + var container = document.createElement('div'); + var option = ReactDOM.render(