target.dispatch('event')
expect(spy.calls.count()).toBe(1)
})
+
+ it('removes an event binding with options from the target', () => {
+ const target = new EventTarget()
+ const spy = createSpy()
+ target.on('event', spy, undefined, { capture: true })
+ target.dispatch('event')
+ expect(spy.calls.count()).toBe(1)
+ target.off('event', spy, { capture: true })
+ target.dispatch('event')
+ expect(spy.calls.count()).toBe(1)
+ })
})
describe('on()', () => {
}
// Unbind event from listener
- off (event, listener) {
- off(this, event, listener)
+ off (event, listener, options) {
+ off(this, event, listener, options)
return this
}
function on(el: Node | Window, events: string, cb: EventListener, binbind?: any, options?: AddEventListenerOptions): void;\r
function on(el: Node | Window, events: Event[], cb: EventListener, binbind?: any, options?: AddEventListenerOptions): void;\r
\r
- function off(el: Node | Window, events?: string, cb?: EventListener | number): void;\r
- function off(el: Node | Window, events?: Event[], cb?: EventListener | number): void;\r
+ function off(el: Node | Window, events?: string, cb?: EventListener | number, options?: AddEventListenerOptions): void;\r
+ function off(el: Node | Window, events?: Event[], cb?: EventListener | number, options?: AddEventListenerOptions): void;\r
\r
function dispatch(node: Node | Window, event: Event, data?: object, options?: object): Event\r
\r
getEventTarget(): this | Node\r
\r
on(events: string | Event[], cb: EventListener, binbind?: any, options?: AddEventListenerOptions): this;\r
- off(events?: string | Event[], cb?: EventListener | number): this;\r
+ off(events?: string | Event[], cb?: EventListener | number, options?: AddEventListenerOptions): this;\r
\r
removeEventListener(): void\r
}\r