-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unbind global listeners after the map is removed (patch) (#1434)
* fix global keyboard and window listeners are not removed after the map is destroyed * test: add a test case for keyboard mixin * change `map.on` to `map.once` & extract keyboard event listener unbind function Co-authored-by: Florian Bischof <[email protected]> * fix missing dot operator * tweak the mixins test case Co-authored-by: Florian Bischof <[email protected]> * Fix test naming --------- Co-authored-by: Florian Bischof <[email protected]>
- Loading branch information
1 parent
9994568
commit 77b6545
Showing
3 changed files
with
38 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
describe('KeyboardMixin', () => { | ||
it('Should unbind event listeners that bound by the KeyboardMixin after the map is destroyed', () => { | ||
cy.window().then((window) => { | ||
const { map, document } = window; | ||
|
||
map.remove(); | ||
|
||
const isWindowBlurEventUnbound = !Object.entries( | ||
window._leaflet_events | ||
).some(([name, handler]) => name.startsWith('blur') && handler); | ||
expect( | ||
isWindowBlurEventUnbound, | ||
'window blur event listener is not unbound' | ||
).to.eq(true); | ||
|
||
const isKeyUpDownEventUnbound = !Object.entries( | ||
document._leaflet_events | ||
).some(([name, handler]) => name.startsWith('key') && handler); | ||
expect( | ||
isKeyUpDownEventUnbound, | ||
'document keyboard event listener is not unbound' | ||
).to.eq(true); | ||
}); | ||
}); | ||
}); |
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