[Bug 10898] Additional attributes should be wired up to window when on body


Travis Leithead [MSFT] <travil@microsoft.com> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
                 CC|                            |travil@microsoft.com
         Resolution|WONTFIX                     |

--- Comment #4 from Travis Leithead [MSFT] <travil@microsoft.com> 2010-11-12 00:26:56 UTC ---
Here's the details and testing methodology; please reconsider the resolution.

<!DOCTYPE html><html><head>
  <!-- This shows that in Firefox/IE9/Opera, for a full screen
       browser window, the body element is only a small block
       of yellow, the rest of the page is grey, represented by
       the HTML element. Chrome treats the body as the viewport
       which is not compliant with CSS 2.1 AFAIK, therefore I 
       automatically disqualify it from this testing -->
  <style>html { background-color: grey; }
         body { background-color: yellow; }
<body onclick="alert('Target: '+event.target + '\nCurrentTarget:
  Here's some text in the body element.</body>

So, open the test page in IE9, and click anywhere in the grey area (html
element). The event model will dispatch the click event to the HTML element and
bubble it down from there. If the body element retained the onclick event
handler, I would expect no alert to fire, and indeed this is what happens in
IE9. This is not the best behavior for the web, however, because many sites
expect those handlers to work and fire in the grey areas of the webpage (e.g.,
context menus). I believe that without a spec change, that IE9's behavior is
correct "per spec".

I like Firefox's approach.
In Firefox, the body element's onclick content attribute is mirrored on the
window's onclick IDL attribute (the two are bound together, just like onblur,
onfocus, etc.; those content attributes marked with an asterisk). So, in the
above scenario, the parser actually assigns the onclick handler to the window.
This is verified by the target and currentTarget of the alert when it fires:
Target: HTMLHtmlElement, currentTarget: Window

Opera supports this scenario, but not in the way firefox does--apparently they
fire the click event with target:HTMLBodyElement, and currentTarget:
HTMLBodyElement. This doesn't make much sense to me because I'm clicking on the
HTML element, but at least the event fires.

As noted in the test comment above, Chrome works in this scenario also because
I can't click on the HTML element--the BODY element takes up the whole

My conclusion is to have the spec changed by adding more of the body element's
content attributes to the list of event handlers mirrored on the window.

My testing in Firefox concludes that the list should be [at least]:

* onmouseup, 
* onmousemove, 
* onmouseover 
* onmouseout
* onclick
* onkeyup
* onkeypress
* onkeydown
* oncontextmenu
* ondblclick

I hope this helps,

Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Friday, 12 November 2010 00:26:59 UTC