- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 03 Dec 2012 08:58:14 -0500
- To: Ian Hickson <ian@hixie.ch>
- Cc: whatwg <whatwg@lists.whatwg.org>
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? -Boris
Received on Monday, 3 December 2012 15:37:32 UTC