Commit 41d5c153 authored by Robert Knight's avatar Robert Knight

Use `Text.data` instead of `Text.nodeValue`

`nodeValue` is an alias for `data` in text nodes, but `data` is never
null, which keeps TS happy.
parent a5540581
...@@ -271,7 +271,7 @@ export class NormalizedRange { ...@@ -271,7 +271,7 @@ export class NormalizedRange {
const nodes = textNodes.slice(0, textNodes.indexOf(node)); const nodes = textNodes.slice(0, textNodes.indexOf(node));
let offset = 0; let offset = 0;
for (let n of nodes) { for (let n of nodes) {
offset += n.nodeValue?.length ?? 0; offset += n.data.length ?? 0;
} }
if (isEnd) { if (isEnd) {
...@@ -397,15 +397,12 @@ export class SerializedRange { ...@@ -397,15 +397,12 @@ export class SerializedRange {
} }
for (let tn of getTextNodes(node)) { for (let tn of getTextNodes(node)) {
if (tn.nodeValue === null) { if (length + tn.data.length > targetOffset) {
continue;
}
if (length + tn.nodeValue.length > targetOffset) {
range[p + 'Container'] = tn; range[p + 'Container'] = tn;
range[p + 'Offset'] = this[p + 'Offset'] - length; range[p + 'Offset'] = this[p + 'Offset'] - length;
break; break;
} else { } else {
length += tn.nodeValue.length; length += tn.data.length;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment