aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/source.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index c3da9f46..5be521fa 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -108,6 +108,10 @@ class TextSourceRange {
static seekForward(node, offset, length) {
const state = {node, offset, remainder: length, content: ''};
+ if (length <= 0) {
+ return state;
+ }
+
const TEXT_NODE = Node.TEXT_NODE;
const ELEMENT_NODE = Node.ELEMENT_NODE;
let resetOffset = false;
@@ -166,6 +170,10 @@ class TextSourceRange {
static seekBackward(node, offset, length) {
const state = {node, offset, remainder: length, content: ''};
+ if (length <= 0) {
+ return state;
+ }
+
const TEXT_NODE = Node.TEXT_NODE;
const ELEMENT_NODE = Node.ELEMENT_NODE;
let resetOffset = false;