-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(extensions): CellExternalCopyBuffer onKeyDown event leak, fix #635 (
#636)
- v8.12.0
- v8.11.0
- v8.10.2
- v8.10.1
- v8.10.0
- v8.9.0
- v8.8.1
- v8.7.0
- v8.6.2
- v8.6.1
- v8.6.0
- v8.5.2
- v8.5.1
- v8.5.0
- v8.4.0
- v8.3.2
- v8.3.1
- v8.3.0
- v8.2.0
- v8.1.0
- v8.0.0
- v7.7.0
- v7.6.1
- v7.6.0
- v7.5.0
- v7.4.1
- v7.4.0
- v7.3.1
- v7.3.0
- v7.2.0
- v7.1.0
- v7.0.3
- v7.0.2
- v7.0.1
- v7.0.0
- v6.6.6
- v6.6.5
- v6.6.4
- v6.6.3
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.1
- v6.5.0
- v6.4.0
- v6.3.1
- v6.3.0
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.0
- v6.0.1
- v6.0.0
- v5.6.4
- v5.6.3
- v5.6.1
- v5.6.0
- v5.5.1
- v5.5.0
- v5.4.1
- v5.4.0
- v5.3.0
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.2
- v5.0.1
- v5.0.0
- v5.0.0-alpha.0
- v4.3.1
- v4.3.0
- v4.2.7
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.0
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.1
- v3.0.0
- v2.30.5
- v2.30.4
- v2.30.3
- v2.30.2
- v2.30.1
- v2.30.0
- v2.29.1
- v2.29.0
- v2.28.2
- v2.28.1
- v2.28.0
- v2.27.0
- v2.26.1
- v2.26.0
- v2.25.1
- v2.25.0
- v2.24.1
- v2.24.0
- v2.23.3
- v2.23.2
1 parent
501908a
commit 9ce8326
Showing
11 changed files
with
145 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/app/modules/angular-slickgrid/models/domEvent.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface DOMEvent<T extends EventTarget> extends Event { | ||
target: T | ||
relatedTarget: T | ||
} |
5 changes: 5 additions & 0 deletions
5
src/app/modules/angular-slickgrid/models/elementEventListener.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ElementEventListener { | ||
element: Element; | ||
eventName: string; | ||
listener: EventListenerOrEventListenerObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/app/modules/angular-slickgrid/services/__tests__/bindingEvent.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { BindingEventService } from '../bindingEvent.service'; | ||
|
||
describe('BindingEvent Service', () => { | ||
let div: HTMLDivElement; | ||
let service: BindingEventService; | ||
|
||
beforeEach(() => { | ||
service = new BindingEventService(); | ||
div = document.createElement('div'); | ||
document.body.appendChild(div); | ||
}); | ||
|
||
afterEach(() => { | ||
div.remove(); | ||
service.unbindAll(); | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should be able to bind an event with listener to an element', () => { | ||
const mockElm = { addEventListener: jest.fn() } as unknown as HTMLElement; | ||
const mockCallback = jest.fn(); | ||
const addEventSpy = jest.spyOn(mockElm, 'addEventListener'); | ||
const elm = document.createElement('input'); | ||
div.appendChild(elm); | ||
|
||
service.bind(mockElm, 'click', mockCallback); | ||
|
||
expect(addEventSpy).toHaveBeenCalledWith('click', mockCallback, undefined); | ||
}); | ||
|
||
it('should be able to bind an event with listener and options to an element', () => { | ||
const mockElm = { addEventListener: jest.fn() } as unknown as HTMLElement; | ||
const mockCallback = jest.fn(); | ||
const addEventSpy = jest.spyOn(mockElm, 'addEventListener'); | ||
const elm = document.createElement('input'); | ||
div.appendChild(elm); | ||
|
||
service.bind(mockElm, 'click', mockCallback, { capture: true, passive: true }); | ||
|
||
expect(addEventSpy).toHaveBeenCalledWith('click', mockCallback, { capture: true, passive: true }); | ||
}); | ||
|
||
it('should call unbindAll and expect as many removeEventListener be called', () => { | ||
const mockElm = { addEventListener: jest.fn(), removeEventListener: jest.fn() } as unknown as HTMLElement; | ||
const addEventSpy = jest.spyOn(mockElm, 'addEventListener'); | ||
const removeEventSpy = jest.spyOn(mockElm, 'removeEventListener'); | ||
const mockCallback1 = jest.fn(); | ||
const mockCallback2 = jest.fn(); | ||
|
||
service = new BindingEventService(); | ||
service.bind(mockElm, 'keyup', mockCallback1); | ||
service.bind(mockElm, 'click', mockCallback2, { capture: true, passive: true }); | ||
service.unbindAll(); | ||
|
||
expect(addEventSpy).toHaveBeenCalledWith('keyup', mockCallback1, undefined); | ||
expect(addEventSpy).toHaveBeenCalledWith('click', mockCallback2, { capture: true, passive: true }); | ||
expect(removeEventSpy).toHaveBeenCalledWith('keyup', mockCallback1); | ||
expect(removeEventSpy).toHaveBeenCalledWith('click', mockCallback2); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/app/modules/angular-slickgrid/services/bindingEvent.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ElementEventListener } from '../models/elementEventListener.interface'; | ||
|
||
export class BindingEventService { | ||
private _boundedEvents: ElementEventListener[] = []; | ||
|
||
/** Bind an event listener to any element */ | ||
bind(element: Element, eventName: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) { | ||
element.addEventListener(eventName, listener, options); | ||
this._boundedEvents.push({ element, eventName, listener }); | ||
} | ||
|
||
/** Unbind all will remove every every event handlers that were bounded earlier */ | ||
unbindAll() { | ||
while (this._boundedEvents.length > 0) { | ||
const boundedEvent = this._boundedEvents.pop() as ElementEventListener; | ||
const { element, eventName, listener } = boundedEvent; | ||
if (element && element.removeEventListener) { | ||
element.removeEventListener(eventName, listener); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters