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 26826 - document.body.focus() behaviour
Summary: document.body.focus() behaviour
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-17 00:17 UTC by Ian 'Hixie' Hickson
Modified: 2014-09-24 18:55 UTC (History)
7 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2014-09-17 00:17:35 UTC
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3182
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3183

Looks like we can drop the magic for body in the focusable steps.
Make sure to update the domintro bit as well.
Comment 1 Ian 'Hixie' Hickson 2014-09-24 18:54:43 UTC
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3204
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3206
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3208
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3209

Chrome and Safari also don't focus the inner frame if you call focus() on the documentElement. Firefox and IE do. IE also focuses it if you focus the <body>. They all focus the inner frame if you call focus() on the window, all but IE focus the inner frame if you call focus() on the iframe. What a mess as usual. The last two tests in particular I couldn't quite understand what IE was doing.

I've gone with the most popular sane answers, counting Safari+Chrome as 1.5 browsers since they have a shared history.

body: no longer magical
documentElement: focuses viewport, not affected by existence of body
window, iframe: focuses browsing context, doesn't change currently focused node

Let me know if there's anything wrong with this.
Comment 2 contributor 2014-09-24 18:55:01 UTC
Checked in as WHATWG revision r8810.
Check-in comment: Try to match browsers better around focus.
https://html5.org/tools/web-apps-tracker?from=8809&to=8810