   #
   # Returns an Array of TextNode instances.
   textNodes: ->
-    textNodes = getTextNodes(this.commonAncestor)
+    textNodes = getNodes(this.commonAncestor, isTextNode)
     [start, end] = [textNodes.indexOf(this.start), textNodes.indexOf(this.end)]
     # Return the textNodes that fall between the start and end indexes.
     return textNodes[start..end]

        origParent = node.parentNode

      path = xpath.fromNode(origParent, root)
      textNodes = getTextNodes(origParent)

      # Calculate real offset as the combined length of all the
      # preceding textNode siblings. We include the length of the

  return insertAfter(tail, node)


# Predicate for checking if a node is a TextNode.
isTextNode = (node) ->
  return node.nodeType is TEXT_NODE
