Skip to content

Commit

Permalink
Limit scope of delegateTarget selector to the base element
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Brigante <[email protected]>
  • Loading branch information
fregante committed Mar 7, 2019
1 parent dfa1abd commit c6bb88c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ function listener(element, selector, type, callback) {
e.delegateTarget = closest(e.target, selector);
}

if (e.delegateTarget) {
// Closest may match elements outside of the currentTarget
// so it needs to be limited to it elements inside
if (e.delegateTarget && e.currentTarget.contains(e.delegateTarget)) {
callback.call(element, e);
}
}
Expand Down

0 comments on commit c6bb88c

Please sign in to comment.