Re: capturing load events

On 1/1/07, João Eiras <joao.eiras@gmail.com> wrote:
> Shadow2531 <shadow2531@gmail.com> escreveu:
> > 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.
>
> That's an exception, although not covered in any specification.
> This rule will be part of the Window specification.

Yeh, I guess we could just say that's an exception and leave it at that.

> > 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'.
>
> Note that the specification doesn't make any claim related to this. It's
> implementation defined.
> The proper way to get that reference is using currentTarget.
> Making an alias between window.addEventListener("load", func, false) and
> document.addEventListener("load", func, false) only contributes to making
> the spec more ambiguous.
> The behaviour is quite simple: when the event is load and the target the
> document, fire load listeners in the document's view, if there are any.
>
> > And with:
> >
> > function test() {
> > alert("test");
> > }
> > window.addEventListener("load", test, false);
> > document.removeEventListener("load", test, false);
> >
> > you won't see an alert in Opera.
>
> That's a bug in Opera (see 168168), which window event listeners are
> registered to the document.

Cool. Thanks.

-- 
burnout426

Received on Monday, 1 January 2007 23:56:39 UTC