diff --git a/spec/text-editor-element-spec.coffee b/spec/text-editor-element-spec.coffee index ea5f55968..55b164d79 100644 --- a/spec/text-editor-element-spec.coffee +++ b/spec/text-editor-element-spec.coffee @@ -233,3 +233,13 @@ describe "TextEditorElement", -> element = new TextEditorElement jasmine.attachToDOM(element) expect(element.getDefaultCharacterWidth()).toBeGreaterThan(0) + + describe "on TextEditor::setMini", -> + it "changes the element's 'mini' attribute", -> + element = new TextEditorElement + jasmine.attachToDOM(element) + expect(element.hasAttribute('mini')).toBe false + element.getModel().setMini(true) + expect(element.hasAttribute('mini')).toBe true + element.getModel().setMini(false) + expect(element.hasAttribute('mini')).toBe false diff --git a/src/text-editor-element.coffee b/src/text-editor-element.coffee index 4c63f4ec0..1c23dca3b 100644 --- a/src/text-editor-element.coffee +++ b/src/text-editor-element.coffee @@ -83,11 +83,12 @@ class TextEditorElement extends HTMLElement @model = model @mountComponent() @addGrammarScopeAttribute() - @addMiniAttributeIfNeeded() + @addMiniAttribute() if @model.isMini() @addEncodingAttribute() @model.onDidChangeGrammar => @addGrammarScopeAttribute() @model.onDidChangeEncoding => @addEncodingAttribute() @model.onDidDestroy => @unmountComponent() + @model.onDidChangeMini (mini) => if mini then @addMiniAttribute() else @removeMiniAttribute() @__spacePenView.setModel(@model) if Grim.includeDeprecatedAPIs @model @@ -155,8 +156,11 @@ class TextEditorElement extends HTMLElement grammarScope = @model.getGrammar()?.scopeName?.replace(/\./g, ' ') @dataset.grammar = grammarScope - addMiniAttributeIfNeeded: -> - @setAttributeNode(document.createAttribute("mini")) if @model.isMini() + addMiniAttribute: -> + @setAttributeNode(document.createAttribute("mini")) + + removeMiniAttribute: -> + @removeAttribute("mini") addEncodingAttribute: -> @dataset.encoding = @model.getEncoding()