 
     endIndex
 
+  WHITESPACE = /^\s*$/
+
+  # Decides whether a given node is a text node that only contains whitespace
+  isWhitespace: (node) ->
+    node.nodeType is Node.TEXT_NODE and WHITESPACE.test node.data

    content = pathInfo?.content

    if not content? or content is ""
      # node has no content
      pathInfo.start = parentIndex + index
      pathInfo.end = parentIndex + index
      pathInfo.atomic = true
      return index
        
    startIndex = if parentContent? then (parentContent.indexOf content, index) else index
    if startIndex is -1
       # content of node is not present in parent's content - probably hidden, or something similar

        # This is a text element that should not even be here.
        # Selecting it might select the whole table,
        # so we don't select anything
      else
        # Normal element, should be selected
        try
          range.setStartBefore node
          range.setEndAfter node
          sel.addRange range
        catch exception
          # This might be caused by the fact that FF can't select a
          # TextNode containing only whitespace.
          # If this is the case, then it's OK.
          unless USE_EMPTY_TEXT_WORKAROUND and @isWhitespace node
            # No, this is not the case. Then this is an error.
            throw exception
    if scroll
      sn = node
      while not sn.scrollIntoViewIfNeeded?
