mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 04:04:06 +02:00
Don't attempt to remove event listeners from non-existent window (#1495)
``` <IFrameComponent> <SlateEditor {...props} /> </IFrameComponent> ``` Since react unmounts from top down, `IFrameComponent` will unmount first (destroying its window), then `SlateEditor` will unmount and attempt to access the iframe window (which no longer exists) throwing `Uncaught TypeError: Cannot read property 'document' of undefined`. It should be safe to skip removing event listeners from windows that no longer exist since they will be garbage collected upon destruction of the window anyway
This commit is contained in:
committed by
Ian Storm Taylor
parent
02c4837d4c
commit
29bcb1c8d6
@@ -117,7 +117,9 @@ class Content extends React.Component {
|
||||
componentWillUnmount() {
|
||||
const window = getWindow(this.element)
|
||||
|
||||
window.document.removeEventListener('selectionchange', this.onNativeSelectionChange)
|
||||
if (window) {
|
||||
window.document.removeEventListener('selectionchange', this.onNativeSelectionChange)
|
||||
}
|
||||
|
||||
// COMPAT: Restrict scope of `beforeinput` to mobile.
|
||||
if ((IS_IOS || IS_ANDROID) && SUPPORTED_EVENTS.beforeinput) {
|
||||
|
Reference in New Issue
Block a user