Re: Where should UA insert text when the focus is changed in a keypress event handler?

Ryosuke Niwa <> skreiv Tue, 20 Mar 2012 18:54:11 +0100

> We're trying to figure out inside which element the editing operation  
> must
> be done when a keypress event handler changes the focused element /
> selection for
> Should it be done at wherever focus is after keypress event is  
> dispatched?
> Or whatever keypress event's target was?

FWIW, Opera does #1 - inserts character in the newly focused input. I  
recall bugs where typing bank account numbers/pin codes and such on pages  
where a script changed focus automatically failing, so I believe that  
compatibility problems has shaped our implementation. This doesn't mean  
we'll never change it again, but it does mean we will thread carefully..

> According to a fellow WebKit contributor, WebKit and Internet Explorer  
> use the current focused element whereas Firefox uses the event target.

This statement is a bit confusing because I have a few tests here where  
Chrome uses the event target.. :-o so it's WebKit and Gecko versus Trident  
and Presto in terms of behaviour.

data:text/html,<input autofocus onkeypress="i2.focus()"><input id="i2">

Typing a character inserts the character in the first input even though  
focus is changing.

Hallvord R. M. Steen
Core tester, Opera Software

Received on Tuesday, 27 March 2012 08:59:08 UTC