Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ src/renderers/dom/shared/__tests__/ReactDOM-test.js
* throws in render() if the update callback is not a function
* preserves focus
* calls focus() on autoFocus elements after they have been mounted to the DOM
* shouldn't fire duplicate event handler while handling other nested dispatch

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
* should handle className
Expand Down
50 changes: 50 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,54 @@ describe('ReactDOM', () => {
HTMLElement.prototype.focus = originalFocus;
}
});

it("shouldn't fire duplicate event handler while handling other nested dispatch", () => {
const actual = [];

function click(node) {
var fakeNativeEvent = function() {};
fakeNativeEvent.target = node;
fakeNativeEvent.path = [node, container];
ReactTestUtils.simulateNativeEventOnNode(
'topClick',
node,
fakeNativeEvent,
);
}

class Wrapper extends React.Component {
componentDidMount() {
click(this.ref1);
}

render() {
return (
<div>
<div
onClick={() => {
actual.push('1st node clicked');
click(this.ref2);
}}
ref={ref => (this.ref1 = ref)}
/>
<div
onClick={ref => {
actual.push("2nd node clicked imperatively from 1st's handler");
}}
ref={ref => (this.ref2 = ref)}
/>
</div>
);
}
}

var container = document.createElement('div');
ReactDOM.render(<Wrapper />, container);

const expected = [
'1st node clicked',
"2nd node clicked imperatively from 1st's handler",
];
expect(actual).toEqual(expected);
});
});