aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/source.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2020-01-26 11:29:30 -0800
committerAlex Yatskov <alex@foosoft.net>2020-01-26 11:29:30 -0800
commit0c5b9b1fa1599cbf769d96cdebc226310f9dd8bc (patch)
treee734e2c3005078dbc248b541d357a934baa8a116 /ext/fg/js/source.js
parent2a12036ca305044291f1f4105d6a8d249848b210 (diff)
parent0cf1cf3aa094585bd6db8db2c1f229ba0ea37b6e (diff)
Merge branch 'master' into testing
Diffstat (limited to 'ext/fg/js/source.js')
-rw-r--r--ext/fg/js/source.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index 5cdf47b5..11d3ff0e 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -25,14 +25,16 @@ const IGNORE_TEXT_PATTERN = /\u200c/;
*/
class TextSourceRange {
- constructor(range, content, imposterContainer) {
+ constructor(range, content, imposterContainer, imposterSourceElement) {
this.range = range;
+ this.rangeStartOffset = range.startOffset;
this.content = content;
this.imposterContainer = imposterContainer;
+ this.imposterSourceElement = imposterSourceElement;
}
clone() {
- return new TextSourceRange(this.range.cloneRange(), this.content, this.imposterContainer);
+ return new TextSourceRange(this.range.cloneRange(), this.content, this.imposterContainer, this.imposterSourceElement);
}
cleanup() {
@@ -55,6 +57,7 @@ class TextSourceRange {
setStartOffset(length) {
const state = TextSourceRange.seekBackward(this.range.startContainer, this.range.startOffset, length);
this.range.setStart(state.node, state.offset);
+ this.rangeStartOffset = this.range.startOffset;
this.content = state.content;
return length - state.remainder;
}
@@ -79,7 +82,17 @@ class TextSourceRange {
}
equals(other) {
- return other && other.range && other.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
+ if (other === null) {
+ return false;
+ }
+ if (this.imposterSourceElement !== null) {
+ return (
+ this.imposterSourceElement === other.imposterSourceElement &&
+ this.rangeStartOffset === other.rangeStartOffset
+ );
+ } else {
+ return this.range.compareBoundaryPoints(Range.START_TO_START, other.range) === 0;
+ }
}
static shouldEnter(node) {