Skip to content

Commit

Permalink
cherry-pick regression test from master
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jul 19, 2017
1 parent 1a320eb commit ecba3d6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/renderers/dom/client/__tests__/inputValueTracking-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'use strict';

var React = require('React');
var ReactDOM = require('ReactDOM');
var ReactTestUtils = require('ReactTestUtils');
var inputValueTracking = require('inputValueTracking');

Expand Down Expand Up @@ -151,4 +152,31 @@ describe('inputValueTracking', function() {

expect(input.hasOwnProperty('value')).toBe(false);
});


it('does not crash for nodes with custom value property', () => {
// https://github.com/facebook/react/issues/10196
try {
var originalCreateElement = document.createElement;
document.createElement = function() {
var node = originalCreateElement.apply(this, arguments);
Object.defineProperty(node, 'value', {
get() {},
set() {},
});
return node;
};
var div = document.createElement('div');
// Mount
var node = ReactDOM.render(<input type="text" />, div);
// Update
ReactDOM.render(<input type="text" />, div);
// Change
ReactTestUtils.SimulateNative.change(node);
// Unmount
ReactDOM.unmountComponentAtNode(div);
} finally {
document.createElement = originalCreateElement;
}
});
});

0 comments on commit ecba3d6

Please sign in to comment.