mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add $.fn.events, which returns a list of all handled events
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
|
||||
describe 'jQuery extensions', ->
|
||||
describe '$.fn.preempt(eventName, handler)', ->
|
||||
@@ -39,3 +40,20 @@ describe 'jQuery extensions', ->
|
||||
element.off('.bar')
|
||||
element.trigger 'foo'
|
||||
expect(events).toEqual [2,1,3]
|
||||
|
||||
describe "$.fn.events()", ->
|
||||
fit "returns a list of all events being listened for on the target node or its ancestors", ->
|
||||
view = $$ ->
|
||||
@div id: 'a', =>
|
||||
@div id: 'b', =>
|
||||
@div id: 'c'
|
||||
@div id: 'd'
|
||||
|
||||
view.on 'a1', ->
|
||||
view.on 'a2', ->
|
||||
view.find('#b').on 'b1', ->
|
||||
view.find('#b').on 'b2', ->
|
||||
view.find('#c').on 'c', ->
|
||||
view.find('#d').on 'd', ->
|
||||
|
||||
expect(view.find('#c').events()).toEqual ['c', 'b1', 'b2', 'a1', 'a2']
|
||||
@@ -1,4 +1,5 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
$.fn.scrollBottom = (newValue) ->
|
||||
if newValue?
|
||||
@@ -36,3 +37,10 @@ $.fn.trueHeight = ->
|
||||
|
||||
$.fn.trueWidth = ->
|
||||
this[0].getBoundingClientRect().width
|
||||
|
||||
$.fn.events = ->
|
||||
events = _.keys(@data('events') ? {})
|
||||
if @hasParent()
|
||||
events.concat(@parent().events())
|
||||
else
|
||||
events
|
||||
|
||||
Reference in New Issue
Block a user