Skip to content

Commit

Permalink
Merge pull request #11 from ehaynes99/master
Browse files Browse the repository at this point in the history
Add null check before registering event handlers
  • Loading branch information
jthoms1 committed Nov 8, 2019
2 parents 7479764 + 2e20239 commit b99f399
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ export function syncEvent(node: Element, eventName: string, newEventHandler: (e:
node.removeEventListener(eventName, oldEventHandler);
}

// Bind new listener.
node.addEventListener(
eventName,
(eventStore[eventName] = function handler(e: Event) {
newEventHandler.call(this, e);
}),
);
if (newEventHandler != null) {
// Bind new listener.
node.addEventListener(
eventName,
(eventStore[eventName] = function handler(e: Event) {
newEventHandler.call(this, e);
}),
);
}
}

function arrayToMap(arr: string[] | DOMTokenList) {
Expand Down

0 comments on commit b99f399

Please sign in to comment.