<?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>83490</bug_id>
          
          <creation_ts>2012-04-09 11:36:10 -0700</creation_ts>
          <short_desc>history pushState doesn&apos;t affect :target selector</short_desc>
          <delta_ts>2017-03-30 02:31:30 -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>History</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://jsbin.com/esunoh/2/</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="Paul Irish">paulirish</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>7raivis</cc>
    
    <cc>archil</cc>
    
    <cc>beidson</cc>
    
    <cc>ben</cc>
    
    <cc>christopher.bentley</cc>
    
    <cc>contact</cc>
    
    <cc>edwardjsabol</cc>
    
    <cc>ericbidelman</cc>
    
    <cc>fishd</cc>
    
    <cc>laughinghan</cc>
    
    <cc>lzsoft.cja</cc>
    
    <cc>medikoo+webkit.org</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>598465</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Irish">paulirish</who>
    <bug_when>2012-04-09 11:36:10 -0700</bug_when>
    <thetext>0. open http://jsbin.com/esunoh/2/
1. click &quot;select two&quot;
2. hash on url changes
3. click button to remove hash from url
4. :target selector is still active

What is the expected result?

Should remove the :target selector as the hash is no longer on the url

What happens instead?

Doesn&apos;t update the selector.  However, if you try location.hash = &apos;&apos;; button, it will remove the :target selector - therefore I&apos;d expect the pushState to work the same.


Downstream: http://code.google.com/p/chromium/issues/detail?id=89165</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>599594</commentid>
    <comment_count>1</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2012-04-10 13:49:23 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; 0. open http://jsbin.com/esunoh/2/
&gt; 1. click &quot;select two&quot;
&gt; 2. hash on url changes
&gt; 3. click button to remove hash from url
&gt; 4. :target selector is still active
&gt; 
&gt; What is the expected result?
&gt; 
&gt; Should remove the :target selector as the hash is no longer on the url
&gt; 
&gt; What happens instead?
&gt; 
&gt; Doesn&apos;t update the selector.  However, if you try location.hash = &apos;&apos;; button, it will remove the :target selector - therefore I&apos;d expect the pushState to work the same.
&gt; 
&gt; 
&gt; Downstream: http://code.google.com/p/chromium/issues/detail?id=89165


What do other browsers do?  What does the relevant spec say?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>688299</commentid>
    <comment_count>2</comment_count>
    <who name="Edward Sabol">edwardjsabol</who>
    <bug_when>2012-08-06 11:14:15 -0700</bug_when>
    <thetext>It doesn&apos;t work in Firefox either, but I agree with the reporter that it should, FWIW.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158376</commentid>
    <comment_count>3</comment_count>
    <who name="Steven Vachon">contact</who>
    <bug_when>2016-01-25 10:42:23 -0800</bug_when>
    <thetext>I&apos;m experiencing this issue as well. 4 years and it hasn&apos;t been fixed? WTF.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158399</commentid>
    <comment_count>4</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-01-25 11:21:29 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; I&apos;m experiencing this issue as well. 4 years and it hasn&apos;t been fixed? WTF.

This is not a bug.

The state object is about session history, and not the actual URL of the document.

Chromium noted this in their version of the bug (http://code.google.com/p/chromium/issues/detail?id=89165)

&quot;This behaviour is per spec as it says &quot;Since this is neither a navigation of the browsing context nor a history traversal, it does not cause a hashchange event to be fired.&quot; See https://html.spec.whatwg.org/multipage/browsers.html#dom-history-pushstate (Section 7.5.2).&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162374</commentid>
    <comment_count>5</comment_count>
    <who name="Archil Imnadze">archil</who>
    <bug_when>2016-02-05 05:44:13 -0800</bug_when>
    <thetext>When location.hash equals an empty string
how can document.querySelector(&apos;:target&apos;) be equal to an element?
How is it true?!

The spec says that hashchange event shouldn&apos;t be fired
But it doesn&apos;t restrict you in applying css styles.
So basically the bug is valid and you won&apos;t fix it because you are lazy.
This is true.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162421</commentid>
    <comment_count>6</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-02-05 10:21:05 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; When location.hash equals an empty string
&gt; how can document.querySelector(&apos;:target&apos;) be equal to an element?
&gt; How is it true?!
&gt; 
&gt; The spec says that hashchange event shouldn&apos;t be fired
&gt; But it doesn&apos;t restrict you in applying css styles.
&gt; So basically the bug is valid and you won&apos;t fix it because you are lazy.
&gt; This is true.

Since Archil contributed this respectful comment, engaging the community in a positive way, I took another look at this.

My most previous comment:

(In reply to comment #4)
&gt; This is not a bug.
&gt; 
&gt; The state object is about session history, and not the actual URL of the
&gt; document.

...was simply wrong.

It&apos;s always updated the Document URL (http://trac.webkit.org/changeset/51644) 

But does this automatically mean the CSS selector should be updated? 

I&apos;m not sure. I know very little about the specific rules of CSS style recalc. It does appear in https://drafts.csswg.org/selectors-3/#target-pseudo that the document&apos;s URL should apply. But what I don&apos;t know is if pushState/replaceState themselves should actually trigger a style recalc...  but of course anything else that triggers a recalc would come along and refresh it...

I&apos;ll ask some CSS folks to help resolve this uncertainty.

But, in the meantime, NOBODY does this. I just tried:
-Latest Chrome (48.0.2564.103)
-Latest Firefox (44.0)
-Latest Edge (12.10514)
-IE11

And this doesn&apos;t work in any of them.

So even if we conclusively say &quot;yes, this is the right thing&quot;, it&apos;s a compatibility concern.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162423</commentid>
    <comment_count>7</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-02-05 10:23:37 -0800</bug_when>
    <thetext>To summarize:
-It appears *likely* that specs do call for this, though not conclusively yet.
-It&apos;s a *very* easy fix in WebCore
-But it&apos;s a compatibility nightmare.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162429</commentid>
    <comment_count>8</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-02-05 10:36:20 -0800</bug_when>
    <thetext>I&apos;ve commented in the chromium bug.

I can&apos;t find a mozilla bug for this.

AFAIK Edge doesn&apos;t have a traditional bug tracker.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162446</commentid>
    <comment_count>9</comment_count>
    <who name="Archil Imnadze">archil</who>
    <bug_when>2016-02-05 11:46:30 -0800</bug_when>
    <thetext>I&apos;ve spent several days implementing pushState in a website that already used :target selectors. Only today I found that :target-s won&apos;t work anymore. That&apos;s reason of my frustration and I hope you understand.

Anyway I still think someone should be the first to propose a fix for this only css issue. Thanks Brandy and others for your attention. I&apos;ve also reported to Mozilla&apos;s Bugzilla at https://bugzilla.mozilla.org/show_bug.cgi?id=1246240

Let&apos;s see what they think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162792</commentid>
    <comment_count>10</comment_count>
    <who name="Chris Rebert">webkit</who>
    <bug_when>2016-02-07 15:45:15 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; AFAIK Edge doesn&apos;t have a traditional bug tracker.

They have https://connect.microsoft.com/IE/Feedback</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162825</commentid>
    <comment_count>11</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-02-07 21:04:16 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #8)
&gt; &gt; AFAIK Edge doesn&apos;t have a traditional bug tracker.
&gt; 
&gt; They have https://connect.microsoft.com/IE/Feedback

Which is something, but not a &quot;traditional bug tracker&quot;

Has anybody filed this issue with that tracker and seen activity on the report?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1162826</commentid>
    <comment_count>12</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2016-02-07 21:05:22 -0800</bug_when>
    <thetext>FWIW, the Mozilla folks stance is the compatibility concern is first and foremost, and they&apos;ve filed a bug with the spec to formalize the current agreed upon behavior.

https://github.com/whatwg/html/issues/639</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1183320</commentid>
    <comment_count>13</comment_count>
    <who name="Han">laughinghan</who>
    <bug_when>2016-04-12 18:58:06 -0700</bug_when>
    <thetext>People, we&apos;re all in agreement that the current behavior is stupid right?

I&apos;ve commented on the WHATWG ticket (1) suggesting we might be able to ascertain that this would be a safe breaking change (2) suggesting backwards-compatible fixes: https://github.com/whatwg/html/issues/639#issuecomment-209189744</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1185903</commentid>
    <comment_count>14</comment_count>
    <who name="Han">laughinghan</who>
    <bug_when>2016-04-21 13:25:19 -0700</bug_when>
    <thetext>@beidson

After discussion in the WHATWG IRC I think I&apos;ve found a good reason to believe that fixing this would not be a compatibility nightmare: though pushState indeed doesn&apos;t affect :target selector in all browsers, if you then hit Back then Fwd, :target will now be updated in all browsers: http://output.jsbin.com/quludi

(Tested in Chrome 48, Firefox 45, Safari 9.0.3.)

So the only way for a webapp to be broken by :target selectors being updated upon pushState, yet function correctly when you hit Back then Fwd, would be if the webapp&apos;s popstate/hashchange handlers had some kind of hysteresis that obscured the broken :target CSS. This seems highly unlikely to me. I have difficulty imagining why a popstate/hashchange handler would make a CSS change that depended on the sequence of Backs and Fwds to get to that history state, not to mention how it could obscure a :target rule that would&apos;ve been broken if it had been applied upon the first .pushState().</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>