Merge pull request #17702 from atom/fb-rh-text-editor-component-updateClassList

Modify TextEditorComponent updateClassList to always add managed classes to element
This commit is contained in:
Max Brunsfeld
2018-07-19 16:27:21 -07:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -818,6 +818,18 @@ describe('TextEditorComponent', () => {
expect(element.className).toBe('editor a b')
})
it('does not blow away class names managed by the component when packages change the element class name', async () => {
assertDocumentFocused()
const {component, element, editor} = buildComponent({mini: true})
element.classList.add('a', 'b')
element.focus()
await component.getNextUpdatePromise()
expect(element.className).toBe('editor mini a b is-focused')
element.className = 'a c d';
await component.getNextUpdatePromise()
expect(element.className).toBe('a c d editor is-focused mini')
})
it('ignores resize events when the editor is hidden', async () => {
const {component, element, editor} = buildComponent({autoHeight: false})
element.style.height = 5 * component.getLineHeight() + 'px'

View File

@@ -848,10 +848,7 @@ class TextEditorComponent {
}
for (let i = 0; i < newClassList.length; i++) {
const className = newClassList[i]
if (!oldClassList || !oldClassList.includes(className)) {
this.element.classList.add(className)
}
this.element.classList.add(newClassList[i])
}
this.classList = newClassList