1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 20:24:01 +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 native = window.getSelection()
const { activeElement } = window.document
debug.update('updateSelection', { selection: selection.toJSON() })
if (debug.enabled) {
debug.update('updateSelection', { selection: selection.toJSON() })
}
// COMPAT: In Firefox, there's a but where `getSelection` can return `null`.
// 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.update('updateSelection-applied', { selection })
}
@@ -483,11 +486,13 @@ class Content extends React.Component {
debug('render', { props })
debug.update('render', {
text: value.document.text,
selection: value.selection.toJSON(),
value: value.toJSON(),
})
if (debug.enabled) {
debug.update('render', {
text: value.document.text,
selection: value.selection.toJSON(),
value: value.toJSON(),
})
}
return (
<Container