Skip to content

Commit

Permalink
Merge pull request #57 from canjs/text-comment-delegate-fix
Browse files Browse the repository at this point in the history
Exclude nodes without 'matches' (e.g. comment and text) from delegation tests
  • Loading branch information
bmomberger-bitovi committed Oct 31, 2018
2 parents 39d3c16 + aa9bcb5 commit 2f81856
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion helpers/-make-delegate-event-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function makeDelegator (domEvents) {
var el = cur === document ? document.documentElement : cur;
var matches = el.matches || el.msMatchesSelector;

if (matches.call(el, selector)) {
// Text and comment nodes may be included in mutation event targets
// but will never match selectors (and do not implement matches)
if (matches && matches.call(el, selector)) {
handlers.forEach(function(handler){
handler.call(el, ev);
});
Expand Down

0 comments on commit 2f81856

Please sign in to comment.