Commit bcc1db6e authored by Robert Knight's avatar Robert Knight

Remove an incorrect `checkQuote` helper which worked by accident

The `checkQuote` helper's code suggested that it was expected to be
passed a range. However it was being called with a string. This happened
to work because the implementation only used the `toString` method,
which exists in both Range objects and strings.
parent 8eb5b2c9
......@@ -437,13 +437,6 @@ export function anchor(root, selectors) {
/** @type {Promise<Range>} */
let result = Promise.reject('unable to anchor');
const checkQuote = range => {
if (quote && quote.exact !== range.toString()) {
throw new Error('quote mismatch');
}
return range;
};
if (position) {
result = result.catch(() => {
return findPage(position.start).then(({ index, offset, textContent }) => {
......@@ -451,7 +444,10 @@ export function anchor(root, selectors) {
const end = position.end - offset;
const length = end - start;
checkQuote(textContent.substr(start, length));
const matchedText = textContent.substr(start, length);
if (quote && quote.exact !== matchedText) {
throw new Error('quote mismatch');
}
return anchorByPosition(index, start, end);
});
......
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