Skip to content

Commit

Permalink
fix(MotorcycleDomSource): correctly simulate events (#118)
Browse files Browse the repository at this point in the history
Before, events weren’t simulated correctly.

Now, we traverse up the DOM graph to correctly simulate events.
  • Loading branch information
TylorS committed Dec 20, 2016
1 parent 28af10d commit 9bd15be
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dom-driver/DomSources/MotorcycleDomSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ function scopeEventStream(
}

function ensureMatches(selector: string, element: Element, ev: Event) {
return !selector ||
(ev.target as Element).matches(selector) ||
element.matches(selector);
if (!selector) return true;

for (let target = ev.target as Element; target !== element; target = target.parentElement as Element)
if (target.matches(selector))
return true;

return element.matches(selector);
}

0 comments on commit 9bd15be

Please sign in to comment.