mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user