<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>148177</bug_id>
          
          <creation_ts>2015-08-19 07:00:50 -0700</creation_ts>
          <short_desc>Replacing input element using outerHTML with new element containing &quot;autofocus&quot; focuses newly replaced element</short_desc>
          <delta_ts>2015-08-19 07:00:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martijn Dashorst">martijn.dashorst</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1118898</commentid>
    <comment_count>0</comment_count>
    <who name="Martijn Dashorst">martijn.dashorst</who>
    <bug_when>2015-08-19 07:00:50 -0700</bug_when>
    <thetext>When replacing an existing &lt;input&gt; element using outerHTML where the new markup has &lt;input autofocus&gt; puts the focus on the new element instead of keeping the focus on the current form element.

The markup below illustrates the issue:

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    function replaceLastName() {
        var newMarkup = &quot;&lt;input type=&apos;text&apos; id=&apos;lastname&apos; autofocus placeholder=&apos;Last name&apos; value=&apos;Banana&apos;&gt;&quot;;
        document.getElementById(&quot;lastname&quot;).outerHTML = newMarkup;
    }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form&gt;
        &lt;input type=&quot;text&quot; id=&quot;lastname&quot; autofocus placeholder=&quot;Last name&quot;&gt;
        &lt;input type=&quot;text&quot; id=&quot;firstname&quot; placeholder=&quot;First name&quot; onfocus=&quot;replaceLastName();&quot;&gt;
        &lt;input type=&quot;submit&quot;&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

When you modify the contents of field &apos;lastname&apos; and switch the focus to &apos;firstname&apos;, Safari 8 and Webkit nightly remove the focus from the &apos;firstname&apos; field and put the focus on &apos;lastname&apos;.

All other major browsers retain the focus on the &apos;firstname&apos; field.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>