mouseup event has incorrect target and missing change event after DOM change

RESOLVED INVALID

Status

()

Firefox
Untriaged
RESOLVED INVALID
3 years ago
3 years ago

People

(Reporter: Ian Goodacre, Unassigned)

Tracking

34 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Build ID: 20141126041045

Steps to reproduce:

I have a page with an empty div, a text input and a span containing text. Similar to the page at http://jsfiddle.net/4zx8rm7c/.

There is a change event handler on the input. This adds some content to the div when the input is changed.

There is a click event handler on the span.

I edit the content of the input then click on the span. I do not remove focus on the input before clicking on the span.


I am using jQuery for the DOM manipulation and for attaching the event handlers. Perhaps I need to write a version that uses raw javascript.

I am observing the events with firebug.


Actual results:

The change event handler runs but the click event handler does not run.

In firebug, I see the following events:

1) mousedown with span as target
2) change with input as target
3) mouseup with input as target but same X/Y coordinates as the mousedown

There is no click event.


Expected results:

The change event handler on the input should run, then the click event handler on the span should run.

The events should be:
1) mousedown with the span as target
2) change with the input as target
3) mouseup with the span as target and same coordinates as mousedown
4) click with the span as target and same coordinates as mousedown

This is exactly what I see, as long as the change event doesn't do any DOM manipulate (e.g. if it only writes to the console log), but if the change event handler adds content to the div (using jQuery append), then the mouseup has a different target, which is inconsistent with its coordinates and, I assume becuase there is not a single target with mousedown and mouseup events, the click event handler on the span is never called - there is no click event.
(Reporter)

Comment 1

3 years ago
I rewrote the change event handler to use simple javascript to add to the div, instead of jQuery append, but I still the the same unexpected behaviour.

While I am using jQuery to attach the event handlers, the events reported by firebug are, I think, independent of jQuery, so this behaviour is not, I think, caused by jQuery.
(Reporter)

Comment 2

3 years ago
Apologies for the bother - I see now that while the mouse didn't move the document layout changed so that the mouse down occurred over the span but then the div expanded, moving the input and span down the screen, so that the same coordinate was over the input by the time the mouse up occurred.

I will have to go back to the real case now to investigate further, there must be some other problem there.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.