• Sean Hammond's avatar
    Read annotations from the host page in settings.annotations() · dc1801f4
    Sean Hammond authored
    Add code to the `settings.annotations()` method so that, instead of
    reading the setting from the URL only, it reads the annotations setting
    from the `js-hypothesis-config` scripts in the host page or, failing
    that, tries to read it from the URL.
    
    In `index.js`, after `settings.annotations()` is called, there are two
    `Object.assign()` calls that overwrite values already in the `config`
    objects with any returned from `js-hypothesis-config` scripts or the
    `window.hypothesisConfig()` function in the host page. So a
    `config.annotations` setting from `settings.annotations()` already gets
    overwritten by a `annotations` setting in a `js-hypothesis-config`
    script or `hypothesisConfig()` function.
    
    This commit makes that overwriting explicit, encapsulates it in the
    `annotations()` method, and unit tests it.
    
    Note that the two `Object.assign()`s are still present in `index.js` so
    the `config.annotations` setting returned by the `annotations()` method
    still gets overwritten by them, but this now has no effect as the
    `annotations()` method will already have set `config.annotations` to the
    same value that it will be overwritten with.
    
    In a future commit the `Object.assign()`s will be removed and there
    won't be any overwriting.
    
    Note that **this will change the behaviour of the code** once the
    `Object.assign()`s have been removed: the `annotations()` method reads
    the annotations setting from `js-hypothesis-config` scripts but does not
    read it from `window.hypothesisConfig()` any longer. I don't believe
    it's necessary to read `annotations` from `hypothesisConfig()`.
    dc1801f4
Name
Last commit
Last update
..
anchoring Loading commit data...
config Loading commit data...
plugin Loading commit data...
test Loading commit data...
util Loading commit data...
vendor Loading commit data...
.eslintrc.js Loading commit data...
adder.html Loading commit data...
adder.js Loading commit data...
annotation-counts.js Loading commit data...
annotation-sync.js Loading commit data...
delegator.coffee Loading commit data...
guest.coffee Loading commit data...
highlighter.coffee Loading commit data...
host.coffee Loading commit data...
main.js Loading commit data...
pdf-sidebar.coffee Loading commit data...
pdfjs-rendering-states.js Loading commit data...
plugin.coffee Loading commit data...
range-util.js Loading commit data...
selections.js Loading commit data...
sidebar-trigger.js Loading commit data...
sidebar.coffee Loading commit data...