diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-04-23 22:34:56 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-04-23 22:34:56 -0700 |
commit | 75d5d84811354cc6dc92c635fb77ad62b4c0aafe (patch) | |
tree | dcfde49f58cdba0ae4336c957199032c2d17fa3c /ext/fg/js | |
parent | 4b46a2988b690379c2833eea23c30e9a8db040c1 (diff) |
WIP
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/range.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js index 85430a7b..75decc20 100644 --- a/ext/fg/js/range.js +++ b/ext/fg/js/range.js @@ -19,23 +19,23 @@ class Range { constructor(range) { - this.range = range; + this.rng = range; } text() { - return this.range.toString(); + return this.rng.toString(); } setLength(length) { - const node = this.range.startContainer; - const offset = this.range.startOffset; + const node = this.rng.startContainer; + const offset = this.rng.startOffset; length = Math.min(node.length - offset, length); if (length === 0) { return null; } - this.range.setEnd(node, offset + length); + this.rng.setEnd(node, offset + length); return length; } @@ -45,7 +45,7 @@ class Range { } getBoundingClientRect() { - const range = this.range.cloneRange(); + const range = this.rng.cloneRange(); const startOffset = range.startOffset; const endOffset = range.endOffset; const node = range.startContainer; @@ -57,7 +57,7 @@ class Range { } select(length) { - const range = this.range.cloneRange(); + const range = this.rng.cloneRange(); range.setEnd(range.startContainer, range.startOffset + length); const selection = window.getSelection(); @@ -72,8 +72,8 @@ class Range { equals(range) { const equal = - range.range.compareBoundaryPoints(Range.END_TO_END, this.range) === 0 && - range.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0; + range.rng.compareBoundaryPoints(Range.END_TO_END, this.rng) === 0 && + range.rng.compareBoundaryPoints(Range.START_TO_START, this.rng) === 0; return equal; |