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

Re: onclick after removing element from document during onmouseup

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Sun, 8 May 2011 19:10:23 -0700
Message-ID: <BANLkTi=h70NGZXCxg+dHFaJ6vr0i87gRLQ@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: www-dom@w3.org
On Sun, May 8, 2011 at 5:45 PM, Glenn Maynard <glenn@zewt.org> wrote:

> 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?
>>
>
Why?  Are there websites that break due to WebKit's current behavior?

<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.)
>

It's definitely nice to spec this but I'd like to know which behavior is
more preferable or predominant.  Have you tested IE & Opera?

- Ryosuke
Received on Monday, 9 May 2011 02:11:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:07 GMT