W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2012

Re: [whatwg] Specification unclear about how HTMLElement.prototype.onscroll's getter/setter should behave for "body" elements

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 3 Dec 2012 19:05:35 +0000 (UTC)
To: Boris Zbarsky <bzbarsky@MIT.EDU>, Cameron McCormack <cam@mcc.id.au>
Message-ID: <Pine.LNX.4.64.1212031904100.12469@ps20323.dreamhostps.com>
Cc: whatwg <whatwg@lists.whatwg.org>
On Mon, 3 Dec 2012, Boris Zbarsky wrote:
>
> Consider this testcase:
> 
>   var desc = Object.getOwnPropertyDescriptor(HTMLElement.prototype,
>                                              "onscroll");
>   desc.set.call(document.body, function() { alert(this); });
> 
> Is the listener added on the body, or the window?
> 
> The relevant parts of the spec are:
> 
> 1)  "onscroll" is present on both HTMLElement.prototype and
> HTMLBodyElement.prototype.  This testcase explicitly invokes the setter for
> the former.
> 
> 2)  The spec text at
> http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#handler-onscroll
> (scroll up; there is no way to link to the actual text) says:
> 
>   The following are the event handlers (and their corresponding event
>   handler event types) that must be supported by all HTML elements
>   other than body and frameset, as both content attributes and IDL
>   attributes, and on Document objects, as IDL attributes
> 
> It's not clear to me what this means since the properties are on 
> HTMLElement.prototype so they can be applied to all HTML elements.  
> What does this text mean in terms of the testcase above?
> 
> Basically, I can see three possible behaviors here.  Either the 
> HTMLElement.prototype.onscroll setter behaves the same way on all 
> elements (and hence the above adds the event handler on the body) or it 
> behaves specially for the body element, forwarding to the window (and 
> then we don't need HTMLBodyElement.prototype.onscroll), or it throws for 
> the body element. Which one is intended?

What do browsers do?

This should probably be defined in WebIDL. It relatess also to:

   https://www.w3.org/Bugs/Public/show_bug.cgi?id=17201

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 3 December 2012 19:18:08 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:50 UTC