> I use this check in a jasmine spec to ensure a newly created element 
> has attached events.  The element is supposed to have events attached 
> to keydown and blur

How exactly events are attached? With element.observe() or element.on()? 
Directly to element or to one of its ancestors (with event delegation)? If 
event observer is attached with element.on() then there is no possibility 
to distinct one observer from another - we can check that some observer is 
attached to desired event, but cannot prove that this is our observer. It 
event delegation is used then things are much worse - we can check just 
that some observer is attached to e.g. blur event on ancestor of element 
under test.

I could simplify event cache parser to this code:

for (var e in Event.cache) {
  var event = Event.cache[e];
  if (event.element === YOUR_ELEMENT) {
    var handlers = event.blur;
    if (handlers.length > 0) {
      // possible match - at least someone is observing blur event
    for (var i = 0, len = handlers.length; i < len; i++) {
      if (handlers[i].handler === YOUR_OBSERVER) {
        // perfect match, does not work with element.on()

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to