diff --git a/spec/spec/types/EventTarget.js b/spec/spec/types/EventTarget.js index e27a71c3..82e5a947 100644 --- a/spec/spec/types/EventTarget.js +++ b/spec/spec/types/EventTarget.js @@ -101,6 +101,17 @@ describe('EventTarget.js', () => { 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()', () => { diff --git a/src/types/EventTarget.js b/src/types/EventTarget.js index 68896056..58f5d5ca 100644 --- a/src/types/EventTarget.js +++ b/src/types/EventTarget.js @@ -39,8 +39,8 @@ export default class EventTarget extends Base { } // Unbind event from listener - off (event, listener) { - off(this, event, listener) + off (event, listener, options) { + off(this, event, listener, options) return this } diff --git a/svg.js.d.ts b/svg.js.d.ts index 0560a62c..baef3b96 100644 --- a/svg.js.d.ts +++ b/svg.js.d.ts @@ -27,8 +27,8 @@ declare module "@svgdotjs/svg.js" { function on(el: Node | Window, events: string, cb: EventListener, binbind?: any, options?: AddEventListenerOptions): void; function on(el: Node | Window, events: Event[], cb: EventListener, binbind?: any, options?: AddEventListenerOptions): void; - function off(el: Node | Window, events?: string, cb?: EventListener | number): void; - function off(el: Node | Window, events?: Event[], cb?: EventListener | number): void; + function off(el: Node | Window, events?: string, cb?: EventListener | number, options?: AddEventListenerOptions): void; + function off(el: Node | Window, events?: Event[], cb?: EventListener | number, options?: AddEventListenerOptions): void; function dispatch(node: Node | Window, event: Event, data?: object, options?: object): Event @@ -579,7 +579,7 @@ declare module "@svgdotjs/svg.js" { getEventTarget(): this | Node on(events: string | Event[], cb: EventListener, binbind?: any, options?: AddEventListenerOptions): this; - off(events?: string | Event[], cb?: EventListener | number): this; + off(events?: string | Event[], cb?: EventListener | number, options?: AddEventListenerOptions): this; removeEventListener(): void }