Add ‘mini’ attribute to TextEditorElement if .isMini() is true on model

This commit is contained in:
Nathan Sobo
2014-11-12 15:45:54 -07:00
committed by Ben Ogle
parent 9f194ff4df
commit b6b6b6d12b
2 changed files with 12 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
TextEditorElement = require '../src/text-editor-element'
TextEditor = require '../src/text-editor'
# The rest of text-editor-component-spec will be moved to this file when React
# is eliminated. This covers only concerns related to the wrapper element for now
@@ -19,6 +20,13 @@ describe "TextEditorElement", ->
element = jasmineContent.firstChild
expect(element.getModel().getPlaceholderText()).toBe 'testing'
describe "when the model is assigned", ->
it "adds the 'mini' attribute if .isMini() returns true on the model", ->
element = new TextEditorElement
model = new TextEditor(mini: true)
element.setModel(model)
expect(element.hasAttribute('mini')).toBe true
describe "focus and blur handling", ->
describe "when the editor.useShadowDOM config option is true", ->
it "proxies focus/blur events to/from the hidden input inside the shadow root", ->

View File

@@ -70,6 +70,7 @@ class TextEditorElement extends HTMLElement
@model = model
@mountComponent()
@addGrammarScopeAttribute()
@addMiniAttributeIfNeeded()
@model.onDidChangeGrammar => @addGrammarScopeAttribute()
@addEncodingAttribute()
@model.onDidChangeEncoding => @addEncodingAttribute()
@@ -131,6 +132,9 @@ class TextEditorElement extends HTMLElement
grammarScope = @model.getGrammar()?.scopeName?.replace(/\./g, ' ')
@dataset.grammar = grammarScope
addMiniAttributeIfNeeded: ->
@setAttributeNode(document.createAttribute("mini")) if @model.isMini()
addEncodingAttribute: ->
@dataset.encoding = @model.getEncoding()