This project is archived and is in readonly mode.

#337 ✓resolved
Sebastian Markbåge

Custom Element.Events with condition false causes event.stop()

Reported by Sebastian Markbåge | August 26th, 2008 @ 02:16 PM | in 1.2.1

If one adds a custom event type to Element.Events with a condition, if the condition returns false, it will cause stop propagation of that event, including any base event.

This is an incorrect assumption. Imagine this:

<div id="box" style="width: 200px; height: 200px"><strong>text</strong></div>

document.addEvent('mouseover', function() { ... });
$('box').addEvent('mouseenter', function() { ... });

In this case the mouseover event should be triggered three times as the mouse moves over the body, the div and finally the strong element. The mouseenter event should only trigger as it enters the div.

However, since the mouseenter's condition returns false, it will cause propagation to stop and there for not trigger mouseover on document as it reaches the strong element.

There are more examples, for examples with custom key events.

Easy fix:

On line 24-27 of Element.Events.js return true instead of false:

condition = function(event){
  if (, event)) return, event);
  return true;

It shouldn't be a problem to let the event bubble up in any of the custom events I know about.

Comments and changes to this ticket

  • Tom Occhino

    Tom Occhino October 3rd, 2008 @ 04:03 PM

    • Assigned user changed from “Valerio” to “Tom Occhino”
    • State changed from “new” to “resolved”
    • Milestone changed from 2.0 to 1.2.1

    fixed for 1.2.1

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Referenced by