• Robert Knight's avatar
    Refactor `Guest#anchor` · d9085810
    Robert Knight authored
    Rewrite the `Guest#anchor` method to simplify the control flow and
    generally make it easier to understand and change. There are no
    functional changes for annotations with zero or one entry in the
    `target` field (all existing Hypothesis annotations).
    
    There is a functional change to handling of annotations with multiple
    targets. Previously `anchor` would try to be smart about only
    re-anchoring targets which were not already anchored. In the new
    implementation all targets for an annotation are re-anchored. This will have
    no effect in practice because the Hypothesis client only supports
    creating annotations with a single target and the h backend can only
    store a single target per annotation. However the Hypothesis API does
    allow for multiple targets per annotation, in line with the W3C Web
    Annotations specs in which a single annotation can refer to multiple
    parts of a document.
    
     - Convert `anchor` method to async and replace Promise chains with async/await
    
     - Replace the logic that removes existing anchors and highlights for an
       annotation with a call to the `detach` method. This required adding
       an internal parameter to `detach` to control whether `anchorsChanged`
       is emitted, so that `anchor` only emits `anchorsChanged` once.
    
     - Add an explicit error to `Promise.reject` calls in tests so that the
       tests are easier to debug if they fail
    d9085810
Name
Last commit
Last update
.github Loading commit data...
bin Loading commit data...
dev-server Loading commit data...
docs Loading commit data...
embedding-examples Loading commit data...
images Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.dockerignore Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.prettierignore Loading commit data...
.python-version Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Dockerfile Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
codecov.yml Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...
requirements-dev.in Loading commit data...
tox.ini Loading commit data...
tsconfig.json Loading commit data...
yarn.lock Loading commit data...