Re: onclick after removing element from document during onmouseup

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 UTC