         origParent = node.parentNode
 
       path = xpath.fromNode(origParent, root)
-      textNodes = getTextNodes(origParent)
+      textNodes = getNodes(origParent, isTextNode)
 
       # Calculate real offset as the combined length of all the
       # preceding textNode siblings. We include the length of the

  #
  # Returns an Array of TextNode instances.
  textNodes: ->
    textNodes = getTextNodes(this.commonAncestor)
    [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]

      # Target the string index of the last character inside the range.
      if p is 'end' then targetOffset -= 1

      for tn in getNodes(node, isTextNode)
        if (length + tn.nodeValue.length > targetOffset)
          range[p + 'Container'] = tn
          range[p + 'Offset'] = this[p + 'Offset'] - length
