Skip to content

Commit 04f070f

Browse files
committed
Added an invariant to throw instead of potentially failing to terminate on unexpected condition.
1 parent 9d4a805 commit 04f070f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/renderers/dom/client/ReactEventListener.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var ReactUpdates = require('ReactUpdates');
2222
var assign = require('Object.assign');
2323
var getEventTarget = require('getEventTarget');
2424
var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
25+
var invariant = require('invariant');
2526

2627
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
2728

@@ -128,6 +129,12 @@ function handleTopLevelWithPath(bookKeeping) {
128129
// Jump to the root of this React render tree
129130
while (currentPathElementID !== newRootID) {
130131
i++;
132+
invariant(
133+
i < path.length,
134+
'Expected to find another React root ' +
135+
'before reaching end of event path (%s).',
136+
path
137+
);
131138
currentPathElement = path[i];
132139
currentPathElementID = ReactMount.getID(currentPathElement);
133140
}

0 commit comments

Comments
 (0)