           @documentChangedSinceLastRender = false
           @notify("change")
       when "change", "attachment-add", "attachment-edit", "attachment-remove"
-        @inputElement.value = Trix.serializeToContentType(this, "text/html")
+        @inputElement?.value = Trix.serializeToContentType(this, "text/html")
 
     if @editorController
       triggerEvent("trix-#{message}", onElement: this, attributes: data)

  inputElement:
    get: ->
      if @hasAttribute("input")
        document.getElementById(@getAttribute("input"))
      else
        inputId = "trix-input-#{@trixId}"
        @setAttribute("input", inputId)
        element = makeElement("input", type: "hidden", id: inputId)


  name:
    get: ->
      @inputElement?.name

  value:
    get: ->
      @inputElement?.value
    set: (@defaultValue) ->
      @editorController?.loadHTML(@defaultValue)

