[whatwg] Two propositions for the autofocus attribute

Markus Ernst derernst at gmx.ch
Fri Apr 16 00:06:07 PDT 2010


Am 16.04.2010 02:44 schrieb Kit Grose:
> On 16/04/2010, at 9:08 AM, Jonas Sicking wrote:
> 
>> While we could deploy a bunch of heuristics, it seems much simpler to
>> just say that it is the *first* element with autofocus that should
>> receive focus. I can't think of any significant downsides with this.
> 
> I agree with you both generally, but I disagree that there are no downsides. I imagine the main use-case where this sort of behaviour might be expected is a Javascript application which dynamically adds a new form to the page based on some user interaction and one of those fields should be autofocused when it's been added to the DOM.
> 
> For instance, picture the Gmail model. When you first load, the autofocus attribute could conceivably be on the inbox search field. When you click Compose, the compose form will be dynamically added and the "To" field should be autofocused (but the search field is still on-screen)

Is it not possible to say the autofocus attribute is readonly? It dose 
IMO not make sense to apply it via scripting, as focus() is available 
for scripting.



More information about the whatwg mailing list