Node sample

Clojure code posted by Alex
created at 23 Mar 20:51, updated at 31 Mar 09:28

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
function getTextFromTextNode(range, textNode) {
        if (range.startContainer.equals(textNode) && range.startOffset > 0) {
            if (range.endContainer.equals(textNode)) {
                return textNode.getText().substr(range.startOffset, range.endOffset - range.startOffset);
            }
            return textNode.getText().substr(range.startOffset);
        }
        if (range.endContainer.equals(textNode)) {
            return textNode.getText().substr(0, range.endOffset);
        }
        return textNode.getText();
    }
554 Bytes in 2 ms with coderay