Skip to content

Commit

Permalink
Merge pull request #6028 from sambev/issue/6027-uncaught-type-error
Browse files Browse the repository at this point in the history
Fix for issue/6027.
  • Loading branch information
jimfb committed Feb 13, 2016
2 parents 8aacf1e + 57d59ea commit 2410dc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/renderers/dom/client/wrappers/ReactDOMSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
});
});

0 comments on commit 2410dc7

Please sign in to comment.