<?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>28630</bug_id>
          
          <creation_ts>2009-08-21 15:10:16 -0700</creation_ts>
          <short_desc>document.activeElement is not changing when clicking on a link</short_desc>
          <delta_ts>2022-08-19 17:56:49 -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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</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=122768</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="jasneet">jasneet</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>jasneet</cc>
    
    <cc>peter_lenahan</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>142010</commentid>
    <comment_count>0</comment_count>
      <attachid>38402</attachid>
    <who name="jasneet">jasneet</who>
    <bug_when>2009-08-21 15:10:16 -0700</bug_when>
    <thetext>Created attachment 38402
reduced testcase

I Steps:
Go to
http://www.mlslistings.com/App_Dialog/ViewAll.aspx?systemname=_ListingArea&amp;clientid=ctl00_cph1_sq1__ListingArea_textbox&amp;Values=
Or
1. go to www.mlslistings.com
2. click &quot;View All&quot; link under either city or area
3. Attempt to choose one of the areas using the checkboxes

II Issue:
Checkboxes for choosing city or area don&apos;t work for selecting search
parameters in www.mlslistings.com

III Conclusion:
The &quot;checkbox&quot; is faked checkbox, it is actually an image embraced with a link. When click on it, javascript function _RSNodeClicked() is invoked to execute the functionalities.

In webkit, the functionalities fails because there is an uncaught exception thrown in backend, which is:
......
Uncaught TypeError: Cannot read property &apos;nodeName&apos; of null
......
This exception is thrown because the DOM attribute document.activeElement is not correct in webkit. When click on a link, the document.activeElement is body element in webkit, however it should be the link element itself, like what in IE and FF.

IV Other Browsers:
IE7: ok
FF3: ok

V Nightly tested: 46809

Bug in Chromium : http://code.google.com/p/chromium/issues/detail?id=14436</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>280343</commentid>
    <comment_count>1</comment_count>
    <who name="Peter Lenahan">peter_lenahan</who>
    <bug_when>2010-09-16 14:01:25 -0700</bug_when>
    <thetext>
Here is a JavaScript workaround to the ActiveElement problem in Safari and Chrome.

Add a listener on the mousedown event or any other event which you are depending on.

The event listener will keep the status of the active element, 
so when you want to reference it, you can use it.


// Declare a global variable to track the elements
var myActiveElement = null;


// define the event listener first
function _dom_trackActiveElement(evt) {
    if (evt &amp;&amp; evt.target) { 
        myActiveElement= evt.target == document ? null : evt.target;
    }
}

if(navigator.userAgent.toLowerCase().indexOf(&apos;webkit&apos;) &gt; -1)
{
    // Register the event listener here
    document.addEventListener(&quot;mousedown&quot;,_dom_trackActiveElement,true);
}


...
Now in a method where I need to use the activeElement, I have it available 
as a global variable it is always set in the event listener which tracks it.

    if (myActiveElement != null)
        myfunctioncall(myActiveElement);
    else
   	myfunctioncall(document.activeElement);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1890550</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-11 04:40:03 -0700</bug_when>
    <thetext>I am able to reproduce this bug in Safari 15.6 on macOS 12.5 using attached &quot;reduction&quot; test case and it shows following across browsers upon clicking link:

*** Safari 15.6 on macOS 12.5 ***

document.activeElement is: BODY

*** Firefox Nightly 105 ***

document.activeElement is: A

*** Chrome Canary 106 ***

document.activeElement is: A

_____

I am not sure on web-spec but I am going to change status to &quot;New&quot; since Safari is different from other browsers. If Safari / Webkit is right, please ignore and mark this as &quot;RESOLVED WONTFIX&quot;. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892573</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-08-19 17:56:49 -0700</bug_when>
    <thetext>The website is no longer affected. 

I think that this is essentially a dupe of bug 22261, although we could theoretically change document.activeElement temporarily, only while handling the click. We do set the :active pseudo-class, after all.

*** This bug has been marked as a duplicate of bug 22261 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>38402</attachid>
            <date>2009-08-21 15:10:16 -0700</date>
            <delta_ts>2009-08-21 15:10:16 -0700</delta_ts>
            <desc>reduced testcase</desc>
            <filename>test-standard (1).html</filename>
            <type>text/html</type>
            <size>751</size>
            <attacher name="jasneet">jasneet</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPg0KPGh0bWwgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiPg0KPGhl
YWQ+DQo8bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNvbnRlbnQ9InRleHQvaHRtbDsg
Y2hhcnNldD11dGYtOCIgLz4NCjx0aXRsZT5VbnRpdGxlZCBEb2N1bWVudDwvdGl0bGU+DQo8c2Ny
aXB0Pg0KZnVuY3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