Merge pull request #6516 from gaearon/ignore-dom-writes-outside-batch

Ignore DOM writes outside the batch in ReactPerf
This commit is contained in:
Dan Abramov 2016-04-15 00:03:17 +01:00
commit 6a93137f0e
2 changed files with 15 additions and 2 deletions

View File

@ -175,12 +175,13 @@ function getUnchangedComponents(measurement) {
// the amount of time it took to render the entire subtree.
var cleanComponents = {};
var writes = measurement.writes;
var hierarchy = measurement.hierarchy;
var dirtyComposites = {};
Object.keys(writes).forEach(function(id) {
writes[id].forEach(function(write) {
// Root mounting (innerHTML set) is recorded with an ID of ''
if (id !== '') {
measurement.hierarchy[id].forEach((c) => dirtyComposites[c] = true);
if (id !== '' && hierarchy.hasOwnProperty(id)) {
hierarchy[id].forEach((c) => dirtyComposites[c] = true);
}
});
});

View File

@ -239,6 +239,18 @@ describe('ReactDefaultPerf', function() {
expect(summary).toEqual([]);
});
it('should not fail on input change events', function() {
var container = document.createElement('div');
var onChange = () => {};
var input = ReactDOM.render(
<input checked={true} onChange={onChange} />,
container
);
expectNoWaste(() => {
ReactTestUtils.Simulate.change(input);
});
});
it('should print a table after calling printOperations', function() {
var container = document.createElement('div');
var measurements = measure(() => {