WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
148177
Replacing input element using outerHTML with new element containing "autofocus" focuses newly replaced element
https://bugs.webkit.org/show_bug.cgi?id=148177
Summary
Replacing input element using outerHTML with new element containing "autofocu...
Martijn Dashorst
Reported
2015-08-19 07:00:50 PDT
When replacing an existing <input> element using outerHTML where the new markup has <input autofocus> puts the focus on the new element instead of keeping the focus on the current form element. The markup below illustrates the issue: <!DOCTYPE html> <html> <head> <script type="text/javascript"> function replaceLastName() { var newMarkup = "<input type='text' id='lastname' autofocus placeholder='Last name' value='Banana'>"; document.getElementById("lastname").outerHTML = newMarkup; } </script> </head> <body> <form> <input type="text" id="lastname" autofocus placeholder="Last name"> <input type="text" id="firstname" placeholder="First name" onfocus="replaceLastName();"> <input type="submit"> </form> </body> </html> When you modify the contents of field 'lastname' and switch the focus to 'firstname', Safari 8 and Webkit nightly remove the focus from the 'firstname' field and put the focus on 'lastname'. All other major browsers retain the focus on the 'firstname' field.
Attachments
Add attachment
proposed patch, testcase, etc.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug