Assign placeholder text on the model only when the attribute is present

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra
2017-04-18 19:03:32 +02:00
parent 6eed22aa90
commit 55950f9594
2 changed files with 7 additions and 1 deletions

View File

@@ -24,6 +24,12 @@ describe('TextEditorElement', () => {
expect(element.getModel().getPlaceholderText()).toBe('testing')
})
it("only assigns 'placeholder-text' on the model if the attribute is present", () => {
const editor = new TextEditor({placeholderText: 'placeholder'})
editor.getElement()
expect(editor.getPlaceholderText()).toBe('placeholder')
})
it("honors the 'gutter-hidden' attribute", () => {
jasmineContent.innerHTML = '<atom-text-editor gutter-hidden>'
const element = jasmineContent.firstChild

View File

@@ -87,8 +87,8 @@ class TextEditorElement extends HTMLElement {
updateModelFromAttributes () {
const props = {
mini: this.hasAttribute('mini'),
placeholderText: this.getAttribute('placeholder-text')
}
if (this.hasAttribute('placeholder-text')) props.placeholderText = this.getAttribute('placeholder-text')
if (this.hasAttribute('gutter-hidden')) props.lineNumberGutterVisible = false
this.getModel().update(props)