Skip to content

Commit

Permalink
Merge pull request #6516 from gaearon/ignore-dom-writes-outside-batch
Browse files Browse the repository at this point in the history
Ignore DOM writes outside the batch in ReactPerf
(cherry picked from commit 6a93137)
  • Loading branch information
gaearon authored and zpao committed Apr 28, 2016
1 parent a771458 commit c98f0e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/test/ReactDefaultPerfAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
Expand Down
12 changes: 12 additions & 0 deletions src/test/__tests__/ReactDefaultPerf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit c98f0e6

Please sign in to comment.