W3C Event Emulation, Now Supports 'stopPropagation' and 'cancelBubble'

My addEvent replacement now supports the full emulation of W3C standard cancelBubble and stopPropagation in event capture and bubbling mode in browsers that don’t support W3C events (IE, Opera).

Here is a test case. If someone can break this and help me find any bugs I’d be very grateful.

Seems to work in Opera, IE5, IE5.5. IE6, Firefox 1.5, Mozilla, NS6.2, NS7.2, NS8

Will test it in Safari later, should work fine in but that browser has bitten me in the past.

/*!
    @fn         MetaWrap.Page.Element.stopPropagation = function(p_event)
    @param      p_event Reference to the event we want to cancel
    @return     void
    @brief      Cancels an event.
    @author     James Mc Parlane
    @date       23 October 2005

    Allows events listeners on the current element to fire,
    but prevents any listeners on any other events from firing.
*/
MetaWrap.Page.Event.stopPropagation = function(p_event)
{
    // If we have a native version
    if (p_event.stopPropagation)
    {
        // Then use it
        p_event.stopPropagation();
    }
    else
    {
        // Simulate it - the rest of the simulation code
        // will interpret cancelBubble correctly
        p_event.cancelBubble = true;
    }
}
Advertisements

About metawrap

CTO Massive Interactive. Ex Computer Whiz Kid - Now Grumpy Old Guru.
This entry was posted in JavaScript, MetaWrap Server. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s