       # Target the string index of the last character inside the range.
       if p is 'end' then targetOffset -= 1
 
-      for tn in getTextNodes(node)
+      for tn in getNodes(node, isTextNode)
         if (length + tn.nodeValue.length > targetOffset)
           range[p + 'Container'] = tn
           range[p + 'Offset'] = this[p + 'Offset'] - length

    }


# Split a TextNode at an offset, returning the successor.
# https://github.com/Raynos/DOM-shim/issues/11
splitText = (node, offset) ->

  #
  # Returns an Array of TextNode instances.
  textNodes: ->
    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]
