From b8a3e2f163af3782dff78a24ab2ae3fcef26bd36 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 28 Feb 2017 18:12:17 -0700 Subject: [PATCH] Don't clear elements owned by other components from line nodes map We should really be recycling elements when they move between lines, but that's a bigger project. --- src/text-editor-component.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 78c3655f9..cbee96c94 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -984,8 +984,11 @@ class LineComponent { update () {} destroy () { - this.props.lineNodesByScreenLineId.delete(this.props.screenLine.id) - this.props.textNodesByScreenLineId.delete(this.props.screenLine.id) + const {lineNodesByScreenLineId, textNodesByScreenLineId, screenLine} = this.props + if (lineNodesByScreenLineId.get(screenLine.id) === this.element) { + lineNodesByScreenLineId.delete(screenLine.id) + textNodesByScreenLineId.delete(screenLine.id) + } } }