         nodes.push(node)
 
     nodes
+
+  createElementsForAttributes = (attributes, parentAttribute) ->
+    elements = []
+    styles = []
+
+    for key, value of attributes when config = Trix.attributes[key]
+      if config.style
+        styles.push(config.style)
+
+      if config.tagName
+        unless config.parent and key is parentAttribute
+          element = document.createElement(config.tagName)
+          element.setAttribute(key, value) unless typeof(value) is "boolean"
+
+          if config.parent
+            elements.unshift(element)
+          else
+            elements.push(element)
+
+    unless elements.length
+      if styles.length
+        elements.push(document.createElement("span"))
+      else
+        elements.push(document.createDocumentFragment())
+
+    for style in styles
+      elements[0].style[key] = value for key, value of style
+
+    elements
 
   preserveSpaces = (string) ->
     string

  createExtraNewlineElement: ->
    if string = @currentRun?.string
      if /\n$/.test(string)
        node = createNodesForString("\n", @text.getLength())[0]
        @elements.push(node)

  createElementsForAttributes = (attributes, parentAttribute) ->
    elements = []
    styles = []

    for key, value of attributes when config = Trix.attributes[key]
      if config.style
        styles.push(config.style)

      if config.tagName
        unless config.parent and key is parentAttribute
          element = document.createElement(config.tagName)
          element.setAttribute(key, value) unless typeof(value) is "boolean"

          if config.parent
            elements.unshift(element)
          else
            elements.push(element)

    unless elements.length
      if styles.length
        elements.push(document.createElement("span"))
      else
        elements.push(document.createDocumentFragment())

    for style in styles
      elements[0].style[key] = value for key, value of style

    elements

  createAttachmentElementForCurrentRun: ->
    {attachment, attributes, position} = @currentRun

        element.style[key] = attributes[key] + "px" for key in ["width", "height"] when attributes[key]?
        element

  createStringNodesForCurrentRun: ->
    {string, position} = @currentRun
    nodes = []

    for substring, index in string.split("\n")
