Re: capturing load events

On 12/31/06, João Eiras <joao.eiras@gmail.com> wrote:
> > So, my question is, what's the reason for not wanting win t+b(2) to
> fire?
> The load event doesn't bubble, so it fires with the Document as
> target, and doesn't go up. But compatibility with the current web
> demands this.

Thanks João.

O.K., so we're just saying that window.addEventListener("load", func,
false) doesn't make sense, *technically*, because the document load
doesn't bubble up to the window.

So, it seems that:
win cap (1) ([object HTMLImageElement])
doc cap (1) ([object HTMLImageElement])
win cap (1) ([object HTMLDocument])
doc t+b (2) ([object HTMLDocument])
win t+b (2) ([object HTMLDocument])

is the way to go because it doesn't break the 'false' behavior and it
allows 'true' to work as mosts sites intend. (Opera can produce that
with the body -> document target fixes.)

Assuming the 'true' +"load" behavior for window.addEventListener is
solved, the the only problem is how to explain how
window.addEventListener("load", func, false) can work if load doesn't
bubble.

So, since we still need  window.addEventListener("load", func, false)
to work, can we just have the window spec say that in the case of
"load" and 'false' for window.addEventListener,
window.addEventListener("load", func, false) is just an alias to
document.addEventListener("load", func, false)?

That appears to be what Opera does anyway (or close to it)

window.addEventListener("load", function() {
alert(this);
}, false);

'this' is HTMLDocument in Opera. In FF it's 'window'.

And with:

function test() {
alert("test");
}
window.addEventListener("load", test, false);
document.removeEventListener("load", test, false);

you won't see an alert in Opera.

-- 
burnout426

Received on Monday, 1 January 2007 22:15:01 UTC