I searched the forum (and Jira is locked), so my apologies if this is a
dupe.

We're using jQuery's QUnit for our JavaScript unit tests.  With a browser
(e.g., Firefox, IE, Safari, Chrome, etc.), the following code in QUnit can
be used to simulate mouse click events and test the click event handlers
without triggering the default action, e.g., QUnit.triggerEvent( elem,
'click' );

        triggerEvent: function( elem, type, event ) {
                if ( document.createEvent ) {
                        event = document.createEvent("MouseEvents");
                        event.initMouseEvent(type, true, true,
elem.ownerDocument.defaultView,
                                0, 0, 0, 0, 0, false, false, false, false,
0, null);
                        elem.dispatchEvent( event );

                } else if ( elem.fireEvent ) {
                        elem.fireEvent("on"+type);
                }
        },

But with R_1810, the default action is also triggered.  Moreover, it doesn't
appear that I can stop this behavior using something like this in my click
event handler:

    if(!e) var e = window.event;
    e.cancelBubble = true;
    e.returnValue = false;
    if (e.stopPropagation) {
        e.stopPropagation();
        e.preventDefault();
    }
    return false;

I'd appreciate some tips.  Thanks.

Reply via email to