Closed Bug 989805 Opened 11 years ago Closed 9 years ago

Correct e.target for unload event

Categories

(Developer Documentation Graveyard :: API: DOM, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: crimsteam, Assigned: teoli)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140314220517

Steps to reproduce:

In HTML5 for load event we have this (http://www.w3.org/html/wg/drafts/html/master/syntax.html#stop-parsing):

 [7.2 If the Document is in a browsing context, create a trusted event named load that does not bubble and is not cancelable and which uses the Event interface, and dispatch it at the Document's Window object, with target override set to the Document object.]

So, event is send only for Window but e.target is override to Document. It looks properly and works fine.

In HTML5 for unload event we have this (http://www.w3.org/html/wg/drafts/html/master/browsers.html#unload-a-document):

 [7. Unload event: If the Document's fired unload flag is false, fire a simple event named unload at the Document's Window object.]
 [Firing a simple event named e means that a trusted event with the name e, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the Event interface, must be created and dispatched at the given target.]

In this rule I don't see any info that e.target for unload event must be override too. So, at now for unload event object we have:
Firefox: e.target >> [object HTMLDocument]
IE: e.target >> [object Window]
Chrome: not suport this event

In conclusion, either the HTML5 specification has a small error or Firefox.
BTW, from D3E (https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-load):
load/unload >>  If this event type is dispatched, implementations are REQUIRED to dispatch this event at least on the Document node.
Summary: Correct e.target for onunload event → Correct e.target for unload event
Chrome sure supports unload event, and it has the same behavior as Gecko.
Right, I missed it because by default the logs disappear after reload (and of course block alert, etc.). We have to turn in options DevTools "Preserve log."

So, in HTML5 should be:

 [7. Unload event: If the Document's fired unload flag is false, fire a simple event named unload at the Document's Window object, with target override set to the Document object.]
The definition in HTML has changed (for the above) so if you do not have to upgrade any of the materials on MDN then this bug can be closed.
Luke, is this something you could check up on in MDN? Thanks!
Assignee: nobody → jypenator
Component: DOM: Events → API: DOM
Flags: needinfo?(lcrouch)
Product: Core → Developer Documentation
Version: 31 Branch → unspecified
301 :teoli or :sheppy
Flags: needinfo?(lcrouch)
Flags: needinfo?(jypenator)
Flags: needinfo?(eshepherd)
Flags: needinfo?(jypenator)
Flags: needinfo?(eshepherd)
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.