Skip to content

Commit 2374403

Browse files
committed
Test ev.path instead of el.contains
See #24 for details
1 parent e3c081a commit 2374403

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ function bind(el, binding) {
4141
}, 0);
4242

4343
el[HANDLER] = function(ev) {
44-
// @NOTE: IE 5.0+
45-
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
46-
if (initialMacrotaskEnded && !el.contains(ev.target)) {
44+
// @NOTE: this test used to be `el.containts`, but `ev.path` is better,
45+
// because it tests whether the element was there at the time of
46+
// the click, not whether it is there now, that the event has arrived
47+
// to the top.
48+
if (initialMacrotaskEnded && ev.path.indexOf(el) < 0) {
4749
return callback(ev);
4850
}
4951
};

0 commit comments

Comments
 (0)