Implement Location.replace

This commit is contained in:
Pu Xingyu 2016-11-18 12:38:12 +08:00
parent 9863149043
commit fb6cc15208
3 changed files with 14 additions and 2 deletions

View file

@ -62,6 +62,18 @@ impl LocationMethods for Location {
fn Reload(&self) {
self.window.load_url(self.get_url(), true, true, None);
}
// https://html.spec.whatwg.org/multipage/#dom-location-replace
fn Replace(&self, url: USVString) -> ErrorResult {
// TODO: per spec, we should use the _API base URL_ specified by the
// _entry settings object_.
let base_url = self.window.get_url();
if let Ok(url) = base_url.join(&url.0) {
self.window.load_url(url, true, false, None);
Ok(())
} else {
Err(Error::Syntax)
}
}
// https://html.spec.whatwg.org/multipage/#dom-location-hash