1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-17 20:51:20 +02:00

Improve performance on large documents with many nodes (#2710)

* don't evaluate expensive debug payloads unless debugging is actually enabled

* fix for linter
This commit is contained in:
Yonah Forst
2019-04-26 23:20:57 +02:00
committed by Ian Storm Taylor
parent 62ca870304
commit 31a4bf4fa9

View File

@@ -162,7 +162,10 @@ class Content extends React.Component {
const window = getWindow(this.element) const window = getWindow(this.element)
const native = window.getSelection() const native = window.getSelection()
const { activeElement } = window.document const { activeElement } = window.document
if (debug.enabled) {
debug.update('updateSelection', { selection: selection.toJSON() }) debug.update('updateSelection', { selection: selection.toJSON() })
}
// COMPAT: In Firefox, there's a but where `getSelection` can return `null`. // COMPAT: In Firefox, there's a but where `getSelection` can return `null`.
// https://bugzilla.mozilla.org/show_bug.cgi?id=827585 (2018/11/07) // https://bugzilla.mozilla.org/show_bug.cgi?id=827585 (2018/11/07)
@@ -274,7 +277,7 @@ class Content extends React.Component {
}) })
} }
if (updated) { if (updated && debug.enabled) {
debug('updateSelection', { selection, native, activeElement }) debug('updateSelection', { selection, native, activeElement })
debug.update('updateSelection-applied', { selection }) debug.update('updateSelection-applied', { selection })
} }
@@ -483,11 +486,13 @@ class Content extends React.Component {
debug('render', { props }) debug('render', { props })
if (debug.enabled) {
debug.update('render', { debug.update('render', {
text: value.document.text, text: value.document.text,
selection: value.selection.toJSON(), selection: value.selection.toJSON(),
value: value.toJSON(), value: value.toJSON(),
}) })
}
return ( return (
<Container <Container