Commit 6be1be70 authored by Kristof Csillag's avatar Kristof Csillag

Merge pull request #1658 from hypothesis/fix-adder-event-handler

Fix adder event handler in Annotator.Guest
parents 4ab2b058 30704ff9
......@@ -350,7 +350,7 @@ class Annotator.Guest extends Annotator
method: 'addToken'
params: token
onAdderMouseup: ->
onAdderMouseup: (event) ->
event.preventDefault()
event.stopPropagation()
......
......@@ -46,6 +46,7 @@ module.exports = function(config) {
'h/static/scripts/auth.js',
'h/static/scripts/helpers.js',
'h/static/scripts/session.js',
'h/static/scripts/hypothesis.js',
'h/static/scripts/vendor/sinon.js',
'h/static/scripts/vendor/chai.js',
'h/templates/*.html',
......
assert = chai.assert
sinon.assert.expose(assert, prefix: '')
describe 'Annotator.Guest', ->
createGuest = (options) ->
element = document.createElement('div')
return new Annotator.Guest(element, options || {})
# Silence Annotator's sassy backchat
before -> sinon.stub(console, 'log')
after -> console.log.restore()
describe 'onAdderMouseUp', ->
it 'it prevents the default browser action when triggered', () ->
event = jQuery.Event('mouseup')
guest = createGuest()
guest.onAdderMouseup(event)
assert.isTrue(event.isDefaultPrevented())
it 'it stops any further event bubbling', () ->
event = jQuery.Event('mouseup')
guest = createGuest()
guest.onAdderMouseup(event)
assert.isTrue(event.isPropagationStopped())
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