mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +02:00
fix(content): use handlers that actually exist in event listeners (#2131)
* fix(content): use handlers that actually exist in event listeners In a recent change, handlers now only exist in `Content#handlers`, but there were still a couple of places where they were being dereferenced directly from the instance. This was causing some side effects in iOS. Fixes #2125 Fixes #2129 * fix(content): also fix removeEventListeners
This commit is contained in:
committed by
Ian Storm Taylor
parent
ec42b18108
commit
9d0546fad3
@@ -91,13 +91,13 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
window.document.addEventListener(
|
window.document.addEventListener(
|
||||||
'selectionchange',
|
'selectionchange',
|
||||||
this.onNativeSelectionChange
|
this.handlers.onNativeSelectionChange
|
||||||
)
|
)
|
||||||
|
|
||||||
// COMPAT: Restrict scope of `beforeinput` to clients that support the
|
// COMPAT: Restrict scope of `beforeinput` to clients that support the
|
||||||
// Input Events Level 2 spec, since they are preventable events.
|
// Input Events Level 2 spec, since they are preventable events.
|
||||||
if (HAS_INPUT_EVENTS_LEVEL_2) {
|
if (HAS_INPUT_EVENTS_LEVEL_2) {
|
||||||
this.element.addEventListener('beforeinput', this.onBeforeInput)
|
this.element.addEventListener('beforeinput', this.handlers.onBeforeInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateSelection()
|
this.updateSelection()
|
||||||
@@ -113,12 +113,15 @@ class Content extends React.Component {
|
|||||||
if (window) {
|
if (window) {
|
||||||
window.document.removeEventListener(
|
window.document.removeEventListener(
|
||||||
'selectionchange',
|
'selectionchange',
|
||||||
this.onNativeSelectionChange
|
this.handlers.onNativeSelectionChange
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HAS_INPUT_EVENTS_LEVEL_2) {
|
if (HAS_INPUT_EVENTS_LEVEL_2) {
|
||||||
this.element.removeEventListener('beforeinput', this.onBeforeInput)
|
this.element.removeEventListener(
|
||||||
|
'beforeinput',
|
||||||
|
this.handlers.onBeforeInput
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user