Skip to content

Commit

Permalink
Merge pull request #64 from Shopify/add-paste-event
Browse files Browse the repository at this point in the history
add paste event
  • Loading branch information
richardmonette committed Apr 14, 2016
2 parents 1842a21 + 0b28e0d commit 647be0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/assets/javascripts/twine.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,7 @@ setupEventBinding = (eventName) ->
return teardown: ->
$(node).off eventName, onEventHandler

for eventName in ['click', 'dblclick', 'mouseenter', 'mouseleave', 'mouseover', 'mouseout', 'mousedown', 'mouseup', 'submit', 'dragenter', 'dragleave', 'dragover', 'drop', 'drag', 'change', 'keypress', 'keydown', 'keyup', 'input', 'error', 'done', 'success', 'fail', 'blur', 'focus', 'load']
for eventName in ['click', 'dblclick', 'mouseenter', 'mouseleave', 'mouseover', 'mouseout', 'mousedown', 'mouseup',
'submit', 'dragenter', 'dragleave', 'dragover', 'drop', 'drag', 'change', 'keypress', 'keydown', 'keyup', 'input',
'error', 'done', 'success', 'fail', 'blur', 'focus', 'load', 'paste']
setupEventBinding(eventName)
8 changes: 8 additions & 0 deletions test/twine_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,14 @@ suite "TwineLegacy", ->
$(node).click()
assert.equal context.fn.callCount, 0

suite "bind-event-paste attribute", ->
test "should run the handler on paste", ->
testView = "<div bind-event-paste=\"fn()\"></div>"
node = setupView(testView, context = fn: @spy())

$(node).trigger 'paste'
assert.isTrue context.fn.calledOnce

suite "bind-event-click attribute", ->
test "should run the handler on click", ->
testView = "<div bind-event-click=\"fn()\"></div>"
Expand Down

0 comments on commit 647be0d

Please sign in to comment.