Closed
Bug 36573
Opened 26 years ago
Closed 24 years ago
[DOM] onchange -> event.target is wrong element
Categories
(Core :: DOM: Events, defect)
Tracking
()
VERIFIED
FIXED
mozilla0.9.9
People
(Reporter: joe, Assigned: joki)
References
Details
(Keywords: dom2, Whiteboard: [eapp?])
Attachments
(2 files, 1 obsolete file)
|
593 bytes,
text/html
|
Details | |
|
1.20 KB,
patch
|
saari
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
When an input element's onchange event fires, the target of the event should be
a reference to the input element itself. However, instead the target is the
input's FORM element, or if the input element has no siblings, the HTML element.
| Reporter | ||
Comment 1•26 years ago
|
||
| Assignee | ||
Comment 3•25 years ago
|
||
This is valid though the bug actually seems to be that the target of the current
mouse event is being taken for the onchange event target. I can see how that
might happend. I'll keep looking at it.
| Assignee | ||
Comment 4•25 years ago
|
||
Adding [DOM] prefix to bugs related to DOM Level 0, 1, or 2
compatibility/compliance.
Status: NEW → ASSIGNED
Summary: onchange -> event.target is wrong element → [DOM] onchange -> event.target is wrong element
Comment 5•25 years ago
|
||
Per heikki, saari, ckritzer:
This bug has been marked "future" because the original netscape engineer working
on this is over-burdened. If you feel this is an error, that you or another
known resource will be working on this bug,or if it blocks your work in some way
-- please attach your concern to the bug for reconsideration.
Target Milestone: --- → Future
Comment 6•25 years ago
|
||
Dragging and dropping a file onto a text input produces and event with an
undefined target. The following INPUT field types do not work:
Text
File (Dropping on the 'Browse' button *does* work)
TEXTAREA
The following do work:
Submit
Checkbox
SELECT
Updated•25 years ago
|
Component: DOM Level 2 → DOM Events
Comment 8•25 years ago
|
||
Please change the target to 0.9 I tried doing it myself as per:
http://www.mozilla.org/roadmap.html "how you can help"/"Mozilla embedders"
but, apparently I'm not "sufficiently empowered" :-(
Comment 9•25 years ago
|
||
After much digging I found the problem and a solution.
The problem is as follows:
nsEventStateManager has a target mCurrentTarget which is set
by the mouse press event the problem is that for change event
this target is incorrect e.g.: the user enters text in the input
and than presses outside of the text input - the resulting target
is whatever the user pressed on.
The solution:
Set mCurrentTarget before dispatching the event, and reset it afterwards.
The code:
In nsEventStateManager::PreHandleEvent at the top add:
///////////////////////////
if (!aPresContext && !aEvent && !aStatus && !aView && aTargetFrame)
{
mCurrentTarget = aTargetFrame;
return NS_OK;
}
////////////////////////////
In our case the only preprocessing needed is to set mCurrentTarget
In nsGfxTextControlFrame2::CallOnChange
add #include "nsIEventStateManager.h"
replace ... mContent->HandleDOMEvent ...
with:
/////////////////////////////
{
nsIFrame* oldTarget;
nsCOMPtr<nsIEventStateManager> manager;
context->GetEventStateManager(getter_AddRefs(manager));
if (manager)
{
manager->GetEventTarget(&oldTarget);
manager->PreHandleEvent(nsnull, nsnull, this, nsnull, nsnull);
}
nsresult result = mContent->HandleDOMEvent(context, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
if (manager)
manager->PreHandleEvent(nsnull, nsnull, oldTarget, nsnull, nsnull);
return result;
}
/////////////////////////////
Can someone please check this fix and submit it if OK ?
Comment 10•24 years ago
|
||
joki can you please take a look at the suggestion offered by Guy?
Comment 12•24 years ago
|
||
jst, can you take a look at this patch please? thanks.
Assignee: joki → jst
Status: ASSIGNED → NEW
Keywords: mozilla0.9.4,
patch
Priority: P3 → --
Target Milestone: Future → ---
Comment 13•24 years ago
|
||
This is really joki's code, I'd prefere if he'd have a look once he has a
chance. Back to joki.
Assignee: jst → joki
Comment 14•24 years ago
|
||
Comment 16•24 years ago
|
||
Too late for 0.9.6, this needs retargeting.
Keywords: mozilla0.9.7
| Assignee | ||
Comment 17•24 years ago
|
||
0.9.6 has passed, moving to 0.9.7. Load balancing 0.9.7 list shortly
Target Milestone: mozilla0.9.6 → mozilla0.9.7
| Assignee | ||
Comment 18•24 years ago
|
||
Moving bugs from 0.9.7 for triaging in 0.9.8
Target Milestone: mozilla0.9.7 → mozilla0.9.8
| Assignee | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Comment 19•24 years ago
|
||
Looking at the sequence of events as you tab out of the testcase's input field
to the select box gives:
================= begin event =================
Event called on obj [object HTMLInputElement]
[element[INPUT]]
evt[type]=change
evt[target]=[object HTMLSelectElement][element[SELECT]]
evt[currentTarget]=[object HTMLInputElement][element[INPUT]]
evt[eventPhase]=2
evt[bubbles]=true
evt[cancelable]=true
evt[view]=[object Window]
evt[originalTarget]=[object HTMLSelectElement][element[SELECT]]
evt[button]=65535
evt[rangeParent]=[object HTMLFormElement][element[FORM]]
evt[rangeOffset]=9
================= end event ===================
Which agrees with the earlier analysis. It seems to me that AT_TARGET, target ==
currentTarget should be an invariant. What is the meaning of originalTarget?
Does this value of originalTarget==SELECT when tabbing from the INPUT to SELECT
make sense?
Getting event targets wrong is a bad thing.
Whiteboard: [eapp?]
Major corporations depend on eapp bugs, and need them to be fixed before they
can recommend Mozilla-based products to their customers. Adding nsbeta1+ keyword
and making sure the bugs get re-evaluated if they are targeted beyond 1.0.
Keywords: nsbeta1+
Comment 21•24 years ago
|
||
eapp was incorrectly used to change this to nsbeta1+. Resetting to nsbeta1 to
nominate. This is an important issue and deserves to be nsbeta1+ by the ADT.
Comment 22•24 years ago
|
||
Note that after typing into the input field in the test case and either tab or
the mouse is used to transfer focus to the select box, the blur event fires on
the imput element but does not bubble before the focus event fires on the select
box.
| Assignee | ||
Comment 23•24 years ago
|
||
The patch is definitely the right idea but there's actually a mechanism in
nsPresShell that achieves it more cleanly. Posting new patch.
| Assignee | ||
Comment 24•24 years ago
|
||
Attachment #48151 -
Attachment is obsolete: true
Comment 25•24 years ago
|
||
Comment on attachment 70056 [details] [diff] [review]
Patch for bug
r=saari
Attachment #70056 -
Flags: review+
Comment 26•24 years ago
|
||
Comment on attachment 70056 [details] [diff] [review]
Patch for bug
sr=jst
Attachment #70056 -
Flags: superreview+
| Assignee | ||
Comment 27•24 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 28•24 years ago
|
||
verifying on build 2002-02-22-03-trunk windows 98
Status: RESOLVED → VERIFIED
Comment 29•19 years ago
|
||
If this is working can someone update
http://www.mozilla.org/docs/dom/mozilla/bug-events.html
Comment 30•19 years ago
|
||
http://www.mozilla.org/docs/dom/mozilla/bug-events.html
has been updated accordingly.
You need to log in
before you can comment on or make changes to this bug.
Description
•