• Robert Knight's avatar
    Catch mouseup/mousedown events earlier in SelectionObserver · e70287cf
    Robert Knight authored
    Listen for mouseup/mousedown events on the document body rather than document
    itself, so that we can still capture them if an event listener on
    `document.body` or `document.documentElement` stops propagation of the event.
    The VitalSource integration does this for example to prevent VitalSource's own
    selection UI appearing, but ordinary web pages could do something similar.
    
    In VitalSource books, this change makes the adder behave the same as it does in
    HTML and PDF documents where, when making a selection with the mouse, the adder
    only appears when the mouse is released so it doesn't get in the way during the
    selection.
    
    While updating the tests for this change, they were converted to use a real
    document, as the complexity of mocking the relevant parts of the DOM document
    interface accurately is now too high.
    e70287cf
vitalsource-test.js 13.6 KB