Updated trigger_fragment to take a string instead of URL and updated callers

This commit is contained in:
Keith Yeung 2015-02-07 20:54:11 +08:00
parent f5cb1690bf
commit 3e33a0b633
2 changed files with 12 additions and 9 deletions

View file

@ -372,10 +372,13 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
// FIXME: handle URL parse errors more gracefully.
let url = url.unwrap();
if href.as_slice().starts_with("#") {
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, url));
} else {
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
match url.fragment {
Some(fragment) => {
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment));
},
None => {
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
}
}
}