     if not node
       return
 
+    if node.nodeName is '#text'
+      node.type = 'text'
+      if node.value.trim().length is 0
+        node.remove = true
+      else
+        @trimText node, lastPosition
+      return
+
+    if node.nodeName is '#comment'
+      node.type = 'comment'
+      return
+
+    if not @isBlockNode node
+      node.type = 'emptyTag'
+      if node.__location?
+        @setAttribs node, @text[node.__location.start...node.__location.end]
+      return
+
     if node.childNodes?
       for child, i in node.childNodes
         if i is node.childNodes.length - 1

          newList.push child
      node.childNodes = newList

    if node.nodeName is '#text'
      node.type = 'text'
      if node.value.trim().length is 0
        node.remove = true
      else
        @trimText node, lastPosition
      return

    if node.nodeName is '#comment'
      node.type = 'comment'
      return

    if not @isBlockNode node
      node.type = 'emptyTag'
      if node.__location?
        @setAttribs node, @text[node.__location.start...node.__location.end]
      return

    if node.nodeName is '#document' or node.nodeName is '#document-fragment'
      node.type = 'document'
      return

      node.__location.end = node.__indentLocation.end

    @setAttribs node, @text[node.__location.start...node.__indentLocation.start]

  trimText: (node, lastPosition) ->
    location = node.__location
