W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Re: onclick after removing element from document during onmouseup

From: Glenn Maynard <glenn@zewt.org>
Date: Sun, 8 May 2011 20:45:58 -0400
Message-ID: <BANLkTi=+Vz2XZ8VTC-TDL5mrkQ185At9eg@mail.gmail.com>
To: www-dom@w3.org
On Sun, Feb 27, 2011 at 4:40 AM, Glenn Maynard <glenn@zewt.org> wrote:

> If an element is removed from the document during mouseup, should the click
> event still fire?
> Example below.  In FF3/4, when the link is clicked, no click event is
> dispatched and the link doesn't activate.  In Chrome 9, the click event
> still fires.  (This doesn't happen with keydown/keypress; for that event
> sequence, both browsers match FF.)
> I think Gecko's behavior makes more sense.  I can't find this in the
> spec--is this covered?
> <a href="http://www.google.com" id="test">test</a>
> <script>
> var elem = document.getElementById("test");
> elem.addEventListener("mouseup", function(e) {
>         elem.parentNode.removeChild(elem);
> }, false);
> </script>

Any input on this?  I've hit variants of this issue more than once.

For example, with a dropdown menu open, the user can middle-click on a menu
item to open it in a tab.  The script hides the menu on mouseup.  In WebKit
this did what was intended: the menu closed and the menu item opened in a
tab.  In Firefox it didn't: the menu was closed but the default action
didn't happen.

(I'm not overly concerned with which behavior is correct, only with the
interoperability failure that resulted.)

Glenn Maynard
Received on Monday, 9 May 2011 00:46:25 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:17 UTC