Elementals.js

Latest Version: 3.0 RC 1 17 July 2017

Method _.Event.prevent

Summary:

Prevents the passed 'Event' object from bubbling or propagating.

Calling Convention:
_.Event.prevent(Event)
Parameters:
Event
The Event object you wish to prevent from bubbling or propagating.
Returns:
Nothing
Actions taken:

In modern browsers:

  • If browser supports Event.stopPropagation, do that.
  • If browser supports Event.preventDefault, do that too!

In Legacy IE where attachEvent is used instead of addEventListener

  • Set Event.cancelBubble to true
  • Set Event.returnValue to false

All of the above is probably overkill, but when dealing with cross browser and wanting your handler to be the ONLY handler for an event, overkill is a good thing. Sometimes you really just need to douse the corpse in gasoline and burn it to ash, JUST to be sure.

Advertisement