Skip to content

Commit

Permalink
Rewrite delegate function
Browse files Browse the repository at this point in the history
  • Loading branch information
demiazz committed May 4, 2017
1 parent 1a8b98c commit 0487629
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/events/delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { EventListener, EventType, Selector } from "../types";
import matches from "../traversing/matches";
import parent from "../traversing/parent";

import on from "./on";

function delegate(
element: Element,
selector: Selector,
Expand Down Expand Up @@ -33,9 +35,7 @@ function delegate(
}
}

element.addEventListener(eventType, wrappedListener);

return () => element.removeEventListener(eventType, wrappedListener);
return on(element, eventType, wrappedListener);
}

export default delegate;

0 comments on commit 0487629

Please sign in to comment.