Bug 12999 - Invisible <A> element inside a <div> does not receive focus
Summary: Invisible <A> element inside a <div> does not receive focus
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-07 02:23 PST by Raul Hudea
Modified: 2010-10-24 15:46 PDT (History)
2 users (show)

See Also:


Attachments
Testcase for both visible and invisible <a> element (121.67 KB, application/zip)
2007-03-07 02:25 PST, Raul Hudea
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raul Hudea 2007-03-07 02:23:26 PST
Test case attached.
Clicking on the left div does not dispatch the keydown event because the invisible <a> element does not receive focus.
Adding a border to the <a> element (div in the right) will make it to receive focus, hence it will dispatch keydown event.
Comment 1 Raul Hudea 2007-03-07 02:25:13 PST
Created attachment 13512 [details]
Testcase for both visible and invisible <a> element
Comment 2 Alexey Proskuryakov 2007-06-22 05:51:34 PDT
WebKit behavior is different from Firefox, but seems more sensible to me - why focus an invisible element?

Could you please describe why such technique is necessary?
Comment 3 Alexey Proskuryakov 2007-07-19 05:11:17 PDT
See also: bug 10614.
Comment 4 Daniel Bates 2010-10-24 15:21:42 PDT
As far as I can tell, the test case works as of Mac Safari version 5.0.2 (6533.18.5) and matches the behavior observed in Mac Firefox 3.6.8. Marking this as Resolved Fixed. If this is not the case, then please re-open this bug.
Comment 5 Daniel Bates 2010-10-24 15:42:48 PDT
(In reply to comment #2)
> WebKit behavior is different from Firefox, but seems more sensible to me - why focus an invisible element?

Notice, the test case  defines the <a> to be "visible" if it has a red border and "invisible" if it does not have a red border. This terminology differs from the terminology used in the HTML5 spec, which talks about elements "being rendered" <http://www.w3.org/TR/html5/rendering.html#being-rendered> or not. By the definition of "being rendered", the <a> is "being rendered" (since it doesn't specify "display: none" or "visibility: collapse" or any other styling that would exclude its rendering). Note, the <a> in the "invisible" case does not have an visible styling.

For completeness, section 7.4.2 of the HTML5 spec <http://www.w3.org/TR/html5/editing.html#focus-management>,  defines a focusable element.
Comment 6 Daniel Bates 2010-10-24 15:46:28 PDT
(In reply to comment #5)
> (In reply to comment #2)
> > WebKit behavior is different from Firefox, but seems more sensible to me - why focus an invisible element?
> 
> ... Note, the <a> in the "invisible" case does not have an visible styling.

I meant to say:

Note, the <a> in the "invisible" case does not have any visible traits or markings.