From e7b4ad48f087a0006aa04d1604eb20ec543bc3bb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 3 Jul 2017 16:10:41 -0600 Subject: [PATCH] Always render 'decoration' class on custom decorations --- spec/text-editor-component-spec.js | 10 +++++----- src/text-editor-component.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 7c211ef29..e36da68c1 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -1727,17 +1727,17 @@ describe('TextEditorComponent', () => { let [decorationNode1, decorationNode2] = gutterA.getElement().firstChild.children const [decorationNode3] = gutterB.getElement().firstChild.children - expect(decorationNode1.className).toBe('a') + expect(decorationNode1.className).toBe('decoration a') expect(decorationNode1.getBoundingClientRect().top).toBe(clientTopForLine(component, 2)) expect(decorationNode1.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 5)) expect(decorationNode1.firstChild).toBeNull() - expect(decorationNode2.className).toBe('b') + expect(decorationNode2.className).toBe('decoration b') expect(decorationNode2.getBoundingClientRect().top).toBe(clientTopForLine(component, 6)) expect(decorationNode2.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 8)) expect(decorationNode2.firstChild).toBe(decorationElement1) - expect(decorationNode3.className).toBe('') + expect(decorationNode3.className).toBe('decoration') expect(decorationNode3.getBoundingClientRect().top).toBe(clientTopForLine(component, 9)) expect(decorationNode3.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 12) + component.getLineHeight()) expect(decorationNode3.firstChild).toBe(decorationElement2) @@ -1746,9 +1746,9 @@ describe('TextEditorComponent', () => { decoration2.setProperties({type: 'gutter', gutterName: 'a', item: decorationElement2}) decoration3.destroy() await component.getNextUpdatePromise() - expect(decorationNode1.className).toBe('c') + expect(decorationNode1.className).toBe('decoration c') expect(decorationNode1.firstChild).toBe(decorationElement1) - expect(decorationNode2.className).toBe('') + expect(decorationNode2.className).toBe('decoration') expect(decorationNode2.firstChild).toBe(decorationElement2) expect(gutterB.getElement().firstChild.children.length).toBe(0) }) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 4e52c5d08..5f4c28415 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1105,7 +1105,7 @@ class TextEditorComponent { const height = this.pixelPositionBeforeBlocksForRow(screenRange.end.row + 1) - top decorations.push({ - className: decoration.class, + className: 'decoration' + (decoration.class ? ' ' + decoration.class : ''), element: TextEditor.viewForItem(decoration.item), top, height