Skip to content

Commit

Permalink
fix(synthetic-shadow): bug fix for async retargeting
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy committed Apr 26, 2019
1 parent 1ae8153 commit cb32917
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/@lwc/synthetic-shadow/src/faux-shadow/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { pathComposer } from './../3rdparty/polymer/path-composer';
import { retarget } from './../3rdparty/polymer/retarget';

import '../polyfills/event-listener/main';
import { getOwnerDocument } from '../shared/utils';

// intentionally extracting the patched addEventListener and removeEventListener from Node.prototype
// due to the issues with JSDOM patching hazard.
Expand Down Expand Up @@ -76,7 +77,8 @@ function targetGetter(this: ComposableEvent): EventTarget | null {
// Handle cases where the currentTarget is null (for async events),
// and when an event has been added to Window
if (!(originalCurrentTarget instanceof Node)) {
return retarget(originalCurrentTarget, composedPath);
const doc = getOwnerDocument(originalTarget as Node);
return retarget(doc, composedPath);
}

const eventContext = eventToContextMap.get(this);
Expand Down

0 comments on commit cb32917

Please sign in to comment.