import nextNode from './next-node';

function rangeNodes(range) {
    let node = range && range.start || null,
        endNode = range && range.end || null,
        nodes = [];

    if (!node || !endNode) return nodes;
    if (node === endNode) return [node];
    if (node.nodeType === 3) {
        nodes.push(node);
    }
    while (node && node !== endNode) {
        node = nextNode(node);
        if (node.nodeType === 3) {
            nodes.push(node);
        }
    }
    return nodes;
}

export default rangeNodes;
@@ -30,16 +30,73 @@
 node';%0A%0A
+const isTextNode = node =%3E node && node.nodeType === 3;%0A%0A
 function
@@ -151,24 +151,16 @@
 ge.start
- %7C%7C null
 ,%0A      
@@ -193,16 +193,8 @@
 .end
- %7C%7C null
 ,%0A  
@@ -225,25 +225,25 @@
 f (!
+(
 node 
-%7C%7C !
+&& 
 endNode)
  ret
@@ -230,32 +230,43 @@
 node && endNode)
+) %7B%0A       
  return nodes;%0A 
@@ -272,72 +272,94 @@
     
-if (node === endNode) return %5Bnode%5D;%0A    if (node.nodeType === 3
+%7D%0A    if (isTextNode(node)) %7B%0A        nodes.push(node);%0A    %7D%0A    if (node === endNode
 ) %7B%0A
@@ -366,32 +366,28 @@
         
-nodes.push(
+return 
 node
-)
+s
 ;%0A    %7D%0A
@@ -468,35 +468,32 @@
     if (
-node.
+isTextNode(
 node
-Type === 3
+)
 ) %7B%0A    

add isTextNode function