Re: 3.5.2. Focus

On 7/31/07, Marcin Hanclik <Marcin.Hanclik@access-company.com> wrote:
>
>
> Inconsistency:
> 3.5.2 [1] reads:
> "There is always an element focused; in the absence of other elements
> being focused, the document's root element is it."
> Root element is html element as per 3.6.1 [2].
>
> But
> 3.5.2.1 [3] reads:
> "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."
>
> Contradiction: which element is focused if none has explicit focus?
>
> I suggest removal of the following sentence:
> "If no element specifically has focus, this must return the body
> element."
> It would result in html element being returned by activeElement.
>
> .Marcin
>
> [1] 3.5.2 http://dev.w3.org/html5/spec/Overview.html#focus
> [2] 3.6.1 http://dev.w3.org/html5/spec/Overview.html#the-html
> [3] 3.5.2.1 http://dev.w3.org/html5/spec/Overview.html#focus-management
>
>
>

This isn't the friendliest test case, but:
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Cscript%3EsetInterval%28%22w%28document.activeElement.tagName%29%22%2C%20500%29%3B%3C/script%3E%0A%3Cinput%20type%3D%22text%22%3E%0A%3Ctextarea%3E%3C/textarea%3E%0A%3Cdiv%20tabindex%3D%220%22%3Ealpha%20%3Ca%20href%3D%22%23%22%20onclick%3D%22return%20false%3B%22%3Ebeta%3C/a%3E%20gamma%3C/div%3E

Firefox doesn't support document.activeElement or any equivalent, AFAIK.
Konqueror doesn't support document.activeElement or any equivalent, AFAIK.
Opera supports document.activeElement, returns either the explicitly
active element or null
Internet Explorer 6 returns either the explicitly active element or
the body element
I don't have Safari handy

Maybe the body element is better in this case.

-- 
Jon Barnett

Received on Tuesday, 31 July 2007 20:53:44 UTC