Skip to content

Commit

Permalink
rework to use isConnected
Browse files Browse the repository at this point in the history
  • Loading branch information
sgparrish committed Jan 12, 2024
1 parent 277ecfa commit 9dad9fa
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/propagating.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

var _firstTarget = null; // singleton, will contain the target element where the touch event started

function inDocument(el) {
var cur = el;
while (cur) {
if (cur.nodeType === Node.DOCUMENT_NODE) return true;
cur = cur.parentNode;
}
return false;
}

/**
* Extend an Hammer.js instance with event propagation.
*
Expand Down Expand Up @@ -205,7 +196,7 @@ export default function propagating(hammer, options) {
event.firstTarget = _firstTarget;

// propagate over all elements (until stopped)
var elem = inDocument(_firstTarget) ? _firstTarget : event.target;
var elem = _firstTarget.isConnected ? _firstTarget : event.target;
while (elem && !stopped) {
var elemHammer = elem.hammer;
if(elemHammer){
Expand Down

0 comments on commit 9dad9fa

Please sign in to comment.