     @currentAttributes[attributeName]?
 
   toggleCurrentAttribute: (attributeName) ->
-    if ("header" in @getBlock()?.getAttributes() and 
+    if (@hasCurrentAttribute("header") and 
     attributeName in @getBlock()?.getAttributes() and
     attributeName != "header")
       @removeBlockAttribute("header")

        position += 1

    newDocument = new Trix.Document [block.removeLastAttribute().copyWithoutText()]
    if "header" in block.attributes
      document = document.removeTextAtRange([position - 1, position])
      @setDocument(document.insertDocumentAtRange(newDocument, [position - 1, position]))
    else

          @removeLastBlockAttribute()
        else if block.text.getStringAtRange([endLocation.offset - 1, endLocation.offset]) is "\n"
          @breakFormattedBlock()
        else if @hasCurrentAttribute("header") and block.text.getStringAtRange([endLocation.offset, endLocation.offset + 1]) is "\n"
          @breakFormattedBlock()
        else
          @insertString("\n")
