Commit bcb55d44 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #3475 from hypothesis/wyan/bugfix-whole-page-annotation-highlights

Bugfix: whole page annotation highlights
parents 61974f4e 7881c7bf
...@@ -50,6 +50,11 @@ exports.anchor = (root, selectors, options = {}) -> ...@@ -50,6 +50,11 @@ exports.anchor = (root, selectors, options = {}) ->
when 'RangeSelector' when 'RangeSelector'
range = selector range = selector
# Assert that there is a quote selector, since otherwise we cannot validate
# the rest of the annotation's selectors.
if not quote?
return Promise.reject(new Error('quote selector not found'))
# Assert the quote matches the stored quote, if applicable # Assert the quote matches the stored quote, if applicable
maybeAssertQuote = (range) -> maybeAssertQuote = (range) ->
if quote?.exact? and range.toString() != quote.exact if quote?.exact? and range.toString() != quote.exact
......
...@@ -99,4 +99,22 @@ describe('anchoring', function () { ...@@ -99,4 +99,22 @@ describe('anchoring', function () {
], ],
expectFail: true, expectFail: true,
}]); }]);
unroll('should silently fail when an annotation does not have a quote selector', function (testCase) {
var annotation = testCase.annotation;
var anchored = guest.anchor(annotation);
return anchored.then(function (result) {
assert.deepEqual(result, []);
});
}, [{
annotation: [{
target: [{
selector: [{
type: 'FragmentSelector',
value: 't=30,60'
}]
}]
}],
}]);
}); });
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