W3C home > Mailing lists > Public > public-webapi@w3.org > December 2006

capturing load events

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Thu, 28 Dec 2006 02:19:49 +0100
To: public-webapi@w3.org
Cc: mjs@apple.com, "Joao Eiras" <joao.eiras@gmail.com>
Message-ID: <op.tk8wnbska3v5gv@hr-opera.oslo.opera.com>

[Originally sent to www-dom, re-sent here on Björn's request. Including  
extra questions from joao.eiras@gmail.com]

Hi,
I have a request for clarification regarding the behaviour of capturing
events.

Opera has implemented capture of load events in the document, meaning that  
an event listener added with

window.addEventListener('load', func, true);

would run for every load event on IMG, SCRIPT, LINK rel="stylesheet" etc.
in the document.

This is also implemented in Safari but not supported in Mozilla until
recently (see bug 331306 - [1])

While we think Opera's/Safari's implementation is correct according to the  
spec, a number of sites out there rely on Mozilla's bug and expect such an  
event listener to run only once.

Mozilla developers have proposed a solution in bug 335251 [2]. They
suggest that load events should not propagate to the "window" object in
the browser's JavaScript environment.

Pros of Mozilla's suggestion:
   - it's backwards compatible with existing content

Cons:
- we introduce an inconsistency to the whole event listener model that
means for example these two will mean very different things..

window.addEventListener('click', func, true); // runs for any click event
window.addEventListener('load', func, true); // runs once only


It is not clear from the DOM Events spec how the "window" object fits into  
the capturing/bubbling. Could this be clarified? Which behaviour should be  
considered correct per the spec?


João's questions:
   - is the window considered as a target in the entire event capturing and  
bubbling phases ?
     * in Gecko yes, in Opera no.

   - should events registered to the window have the document as target ?
     * both in Gecko and Opera yes.

   - should capturing of load events be supported too when registering a  
capturing event listener in the window ?
     * in Opera yes, in Gecko no as consequence of their 'fix'

The ecmascript binding needs clarification in this regard.


[1] https://bugzilla.mozilla.org/show_bug.cgi?id=331306

[2] https://bugzilla.mozilla.org/show_bug.cgi?id=335251

Commentary:
http://my.opera.com/hallvors/blog/2006/12/23/firechicken

-- 
Hallvord R. M. Steen
Core QA JavaScript tester, Opera Software
http://www.opera.com/
Opera - simply the best Internet experience
Received on Thursday, 28 December 2006 01:19:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:56 GMT