This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14534 - Specify the target of the keyboard events when no element has focus
Summary: Specify the target of the keyboard events when no element has focus
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 20:25 UTC by Olli Pettay
Modified: 2011-10-25 18:44 UTC (History)
6 users (show)

See Also:


Attachments

Description Olli Pettay 2011-10-21 20:25:08 UTC
Usually key events are dispatched to the focused element of the focused
document. But there are cases when there is no focused element.

Currently Gecko dispatches key events in such case to documentElement, 
webkit to body if there is one. (Opera couldn't handle my testcase and
I haven't yet tested IE)

I'm probably going to change Gecko to follow Webkit in this case since that
behavior follows how activeElement works.
Comment 1 Ian 'Hixie' Hickson 2011-10-25 05:04:27 UTC
This is in fact already specified:
   http://www.whatwg.org/specs/web-apps/current-work/#focus

"There may be no element focused; when no element is focused, key events received by the document must be targeted at" "the first child of the html element that is either a body element or a frameset element. If there is no such element, [...] they must instead be fired at the Document object".


EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: no spec change
Rationale: This seems to have been fixed already.

Please don't hesitate to reopen if the current definition is now Web-compatible.
Comment 2 Olli Pettay 2011-10-25 10:47:52 UTC
Looks like the event should be dispatched to documentElement if there is
no body or frameset.
Comment 3 Ian 'Hixie' Hickson 2011-10-25 18:44:02 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter's comments based on light testing.
Comment 4 contributor 2011-10-25 18:44:34 UTC
Checked in as WHATWG revision r6753.
Check-in comment: Compatibility fix for how events are fired when nothing is focused and there's no body element. Also, editorial tweaks around how drag and drop events are fired to the body element.
http://html5.org/tools/web-apps-tracker?from=6752&to=6753