[whatwg] Focus, html vs body and the activeElement property

On Wed, 30 Apr 2008, Hans S. T?mmerholt wrote:
> 
> I'm reading this part:
> http://www.whatwg.org/specs/web-apps/current-work/#focus
> 
> The intro states:
> "When an element is focused, key events received by the document must be
> targeted at that element. There is always an element focused; in the
> absence of other elements being focused, the document's root element is
> it."
> 
> Under "Focus management", I read:
> 
> "The activeElement attribute must return the element in the document that
> has focus. If no element specifically has focus, this must return the body
> element."
> 
> First: Isn't this a contradiction? The first paragraph states that there
> is always an element focused. The second gives a case where this is not so.
> 
> Second: I presume the document's root is defined as html, but the
> activeElement returns the body element. Why?

The contradiction has been fixed; the behavior described is mostly the way 
it is because that's what browsers do.


> This seems to refer to the same issue:
> http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2007-October/012654.html
> Searching through the archive I can't find a response, for example in Ian's
> "several messages" posts.

The response was sent after your e-mail:

   http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-June/014969.html


> The spec also mentions "system focus" and seems to imply that this is 
> different from the focus of elements. But the term is not particularly 
> defined. I'm guessing this means that this is the page the user is 
> currently looking at, i.e. that the window containing the document has 
> focus? But then this line is confusing:
> 
> "The hasFocus attribute must return true if the document, one of its 
> nested browsing contexts, or any element in the document or its browsing 
> contexts currently has the system focus."
> 
> This seems to imply that an element inside a document can have system 
> focus. What does this mean?

I've clarified this in the spec. Please let me know if it is ok now.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 17 December 2008 19:58:26 UTC