<?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>267449</bug_id>
          
          <creation_ts>2024-01-12 01:53:00 -0800</creation_ts>
          <short_desc>`document.activeElement` for an `onclick` on a `&lt;input type=checkbox&gt;` returns HTMLBodyElement instead of HTMLInputElement</short_desc>
          <delta_ts>2026-04-02 18:34:06 -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>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>22261</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=276709</see_also>
          <bug_file_loc>https://codepen.io/webcompat/pen/zYbKgGd</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>22261</dependson>
          <blocked>267569</blocked>
    
    <blocked>311383</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2004642</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-12 01:53:00 -0800</bug_when>
    <thetext>`document.activeElement` for an `onclick` on a `&lt;input type=checkbox&gt;` returns:

* HTMLBodyElement on Safari
* HTMLInputElement on Chrome, Firefox

See https://codepen.io/webcompat/pen/zYbKgGd

&lt;input type=&quot;checkbox&quot; id=&quot;check&quot; onclick=&quot;logme(this)&quot;&gt;
&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;

var check = document.querySelector(&quot;#check&quot;);
var log = document.querySelector(&quot;#log&quot;);
function logme(element) {
  log.textContent += document.activeElement;
}
log.textContent = check;


I will upload a proper test case tomorrow if I can&apos;t find a WPT test for it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004643</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-12 01:53:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/120894916&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004659</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-12 03:39:13 -0800</bug_when>
    <thetext>https://html.spec.whatwg.org/multipage/interaction.html#dom-documentorshadowroot-activeelement-dev

Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document.

For the purposes of this API, when a child navigable is focused, its container is focused within its parent&apos;s active document. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe&apos;s node document.

Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that&apos;s located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005014</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-14 20:54:07 -0800</bug_when>
    <thetext>This behavior creates a webcompat issue for ceac.state.gov website on Safari.
I should open a bug on https://webcompat.com/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005514</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-16 23:59:30 -0800</bug_when>
    <thetext>MacOS Platform behaves differently than windows with regards to focus on Form Elements. This is a conscious decision to keep.
I&apos;m closing this as a duplicate of Bug 193478

ceac.state.gov was a regression introduced by a modification of the Quirks which was handling this.

*** This bug has been marked as a duplicate of bug 193478 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075740</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-17 20:50:48 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 22261 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>