Closed
Bug 48788
Opened 25 years ago
Closed 25 years ago
EventTarget.dispatchEvent() does not override target of existing event
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
RESOLVED
INVALID
People
(Reporter: dannyg, Assigned: joki)
References
()
Details
(Whiteboard: requested feedback from reporter [08.22.00]-ckritzer;)
Attachments
(1 file)
|
10.50 KB,
text/html
|
Details |
Found with M17.
If you pass the current event object as the parameter to
EventTarget.dispatchEvent(), the target property of the dispatched event picks
up the target property of the passed event, rather than setting the target
property to match the recipient of the dispatchEvent() method call. All other
current event object properties should carry on unmodified.
Here's an example that displays alerts with the tagName of the target of the
event object at various element hierarchy levels. When you check the "Redirect
Event to BODY" checkbox, the current event is passed as a parameter to the
document.body.dispatchEvent() method. But the alerts still show the original
button as being the target of the dispatched event (rather than the BODY
element, as it should be in this case).
<HTML onClick="revealEvent('HTML', event)">
<HEAD>
<TITLE>Event Cancelling & Redirecting</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// display alert with event object info
function revealEvent(elem, evt) {
var msg = "Event (from " + evt.target.tagName + " at "
msg += evt.clientX + "," + evt.clientY + ") is now at the "
msg += elem + " element."
alert(msg)
}
function init() {
document.onclick = docEvent
document.body.onclick = docBodEvent
}
function docEvent(evt) {
revealEvent("document", evt)
}
function docBodEvent(evt) {
revealEvent("BODY", evt)
}
function buttonEvent(form, evt) {
revealEvent("BUTTON", evt)
// redirect if checked
if (form.redirect.checked) {
document.body.dispatchEvent(evt)
}
// cancel if checked
if (form.bubbleCancelState.checked) {
evt.stopPropagation()
}
}
</SCRIPT>
</HEAD>
<BODY onLoad="init()">
<H1>Event Cancelling & Redirecting</H1>
<HR>
<FORM onClick="revealEvent('FORM', event)">
<P><BUTTON NAME="main1" onClick="buttonEvent(this.form, event)">
Button 'main1'
</BUTTON></P>
<P><INPUT TYPE="checkbox" NAME="bubbleCancelState"
onClick="event.stopPropagation()">Cancel Bubbling at BUTTON<BR>
<INPUT TYPE="checkbox" NAME="redirect" onClick="event.stopPropagation()">
Redirect Event to BODY</P>
</FORM>
</BODY>
</HTML>
My expectations with redirection turned on and bubbling left on are as follows:
Alert from BUTTON, with BUTTON as target
Alert from BODY, with BODY as target
Alert from HTML, with BODY as target
Alert from document, with BODY as target
Alert from FORM, with BUTTON as target
Alert from BODY, with BUTTON as target
Alert from HTML, with BUTTON as target
Alert from document, with BUTTON as target
While the dispatched event handlers are processing, the original event must be
queued somewhere so it can continue once the dispatched event handlers finish
and that dispatched event goes away.
Dispatching a current event can also trigger a crash, which may be a separate
(but related) bug.
Comment 1•25 years ago
|
||
Comment 2•25 years ago
|
||
Danny, I'm seeing what appears to be your expected results on M18 builds of
MacOS86 2000-08-21-08, Win98 2000-08-21-08, and LinuxRH62 2000-08-22-06. Could
you try with an M18 build and see if you still see this bug? Thanks, -ckritzer
Whiteboard: requested feedback from reporter [08.22.00]-ckritzer;
Comment 4•25 years ago
|
||
Closing this bug on Thursday, September 7 if I do not receive feedback from
reporter. If you disagree with this, tell me now or re-open the bug.
Comment 6•25 years ago
|
||
resolving this invalid -not enough info. dannyg@dannyg.com please reopen this
if you can still reproduce this problem with current builds and can provide
requested information. Thanks for your help in testing Mozilla and reporting bugs
Status: UNCONFIRMED → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
Comment 7•24 years ago
|
||
Reassigning QA Contact for all open and unverified bugs previously under Lorca's
care to Gerardo as per phone conversation this morning.
QA Contact: lorca → gerardok
Updated•23 years ago
|
QA Contact: madhur → rakeshmishra
Updated•23 years ago
|
QA Contact: rakeshmishra → trix
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•