mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Don't throw when ::getDefaultCharacterWidth is called while detached
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user