Skip to content

Commit

Permalink
location.hash = "" should result in a fragment
Browse files Browse the repository at this point in the history
Although some browsers currently do not add a fragment if hash is set
to the empty string, they won’t remove a fragment either when hash is
set to the empty string. Therefore aligning with Firefox makes more
sense, which consistently gives a fragment.

This makes the location API slightly inconsistent from the point of
<a>, <area>, and URL, but compatibility has to win.

Fixes #1177.
  • Loading branch information
annevk authored and zcorpan committed May 26, 2016
1 parent 00dcb3c commit c630787
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions source
Expand Up @@ -81047,28 +81047,23 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
<li><p>If <var>copyURL</var>'s <span data-x="concept-url-scheme">scheme</span> is "<code
data-x="">javascript</code>", terminate these steps.</p></li>

<li><p>If the given value is the empty string, set <var>copyURL</var>'s <span
data-x="concept-url-fragment">fragment</span> to null.

<li>
<p>Otherwise, run these substeps:</p>

<ol>
<li><p>Let <var>input</var> be the given value with a single leading "<code data-x="">#</code>"
removed, if any.</p></li>
<li><p>Let <var>input</var> be the given value with a single leading "<code data-x="">#</code>"
removed, if any.</p></li>

<li><p>Set <var>copyURL</var>'s <span data-x="concept-url-fragment">fragment</span> to the
empty string.</p></li>
<li><p>Set <var>copyURL</var>'s <span data-x="concept-url-fragment">fragment</span> to the empty
string.</p></li>

<li><p><span data-x="basic url parser">Basic URL parse</span> <var>input</var>, with
<var>copyURL</var> as <var>url</var> and <span>fragment state</span> as <var>state
override</var>.</p></li>
</ol>
</li>
<li><p><span data-x="basic url parser">Basic URL parse</span> <var>input</var>, with
<var>copyURL</var> as <var>url</var> and <span>fragment state</span> as <var>state
override</var>.</p></li>

<li><p><span><code>Location</code>-object-setter navigate</span> to <var>copyURL</var>.</p></li>
</ol>

<p class="note">Unlike the equivalent API for the <code>a</code> and <code>area</code> elements,
the <code data-x="dom-location-hash">hash</code> attribute's setter does not special case the
empty string to remain compatible with deployed scripts.</p>

<hr>

<p>When the <dfn><code data-x="dom-location-assign">assign(<var>url</var>)</code></dfn>
Expand Down

0 comments on commit c630787

Please sign in to comment.