Auto merge of #11934 - jdm:navigatefragment, r=emilio

Special-case setting location.hash to the empty string

This avoids endless redirect loops on facebook and makes us compliant with https://github.com/whatwg/html/pull/1318.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #10952
- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11934)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-29 17:39:58 -05:00 committed by GitHub
commit e30b288ed6
4 changed files with 45 additions and 2 deletions

View file

@ -66,7 +66,10 @@ impl LocationMethods for Location {
}
// https://html.spec.whatwg.org/multipage/#dom-location-hash
fn SetHash(&self, value: USVString) {
fn SetHash(&self, mut value: USVString) {
if value.0.is_empty() {
value = USVString("#".to_owned());
}
self.set_url_component(value, UrlHelper::SetHash);
}