Merge pull request #6028 from sambev/issue/6027-uncaught-type-error

Fix for issue/6027.
This commit is contained in:
Jim
2016-02-13 13:19:11 -08:00
2 changed files with 23 additions and 1 deletions
@@ -236,7 +236,9 @@ function _handleChange(event) {
var props = this._currentElement.props;
var returnValue = LinkedValueUtils.executeOnChange(props, event);
this._wrapperState.pendingUpdate = true;
if (this._rootNodeID) {
this._wrapperState.pendingUpdate = true;
}
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
return returnValue;
}
@@ -517,4 +517,24 @@ describe('ReactDOMSelect', function() {
);
expect(console.error.argsForCall.length).toBe(1);
});
it('should be able to safely remove select onChange', function() {
function changeView() {
ReactDOM.unmountComponentAtNode(container);
}
var container = document.createElement('div');
var stub =
<select value="giraffe" onChange={changeView}>
<option value="monkey">A monkey!</option>
<option value="giraffe">A giraffe!</option>
<option value="gorilla">A gorilla!</option>
</select>;
stub = ReactDOM.render(stub, container);
var node = ReactDOM.findDOMNode(stub);
expect(() => ReactTestUtils.Simulate.change(node)).not.toThrow(
"Cannot set property 'pendingUpdate' of null"
);
});
});