Don't throw when ::getDefaultCharacterWidth is called while detached

This commit is contained in:
Max Brunsfeld
2014-12-08 16:56:46 -08:00
parent d03cfda6c4
commit 5c37d208f5
2 changed files with 2 additions and 5 deletions

View File

@@ -147,9 +147,9 @@ describe "TextEditorElement", ->
expect(element.shadowRoot.textContent).toContain "goodbye"
describe "::getDefaultCharacterWidth", ->
it "throws an exception if the editor is not attached", ->
it "returns null before the element is attached", ->
element = new TextEditorElement
expect(-> element.getDefaultCharacterWidth()).toThrow("The editor must be attached to get the default character width")
expect(element.getDefaultCharacterWidth()).toBeNull()
it "returns the width of a character in the root scope", ->
element = new TextEditorElement

View File

@@ -60,7 +60,6 @@ class TextEditorElement extends HTMLElement
@__spacePenView = new TextEditorView(this)
attachedCallback: ->
@attached = true
@buildModel() unless @getModel()?
@mountComponent() unless @component?.isMounted()
@component.checkForVisibilityChange()
@@ -68,7 +67,6 @@ class TextEditorElement extends HTMLElement
@emitter.emit("did-attach")
detachedCallback: ->
@attached = false
@emitter.emit("did-detach")
initialize: (model) ->
@@ -173,7 +171,6 @@ class TextEditorElement extends HTMLElement
#
# Returns a {Number} of pixels.
getDefaultCharacterWidth: ->
throw new Error("The editor must be attached to get the default character width") unless @attached
@getModel().getDefaultCharWidth()
# Extended: call the given `callback` when the editor is attached to the DOM.