diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-15 20:52:21 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-15 20:52:21 -0500 |
commit | 10ec165f14e829f73c232b531ea2981c043b17c3 (patch) | |
tree | 88b9883bcfcb2b24e99b4340bc793a0123af8c99 /ext | |
parent | 217bd36abc08e03eff21144122e0bacff90e856f (diff) |
Check type of other for equals functions
Fixes #361
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fg/js/source.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index 11d3ff0e..fa785ec4 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -82,7 +82,11 @@ class TextSourceRange { } equals(other) { - if (other === null) { + if (!( + typeof other === 'object' && + other !== null && + other instanceof TextSourceRange + )) { return false; } if (this.imposterSourceElement !== null) { @@ -409,6 +413,12 @@ class TextSourceElement { } equals(other) { - return other && other.element === this.element && other.content === this.content; + return ( + typeof other === 'object' && + other !== null && + other instanceof TextSourceElement && + other.element === this.element && + other.content === this.content + ); } } |