Implement Location.hash.

This commit is contained in:
Ms2ger 2014-07-27 11:04:49 +02:00
parent ecd816cdd6
commit 4225cdcac3
2 changed files with 9 additions and 0 deletions

View file

@ -37,6 +37,7 @@ impl Location {
pub trait LocationMethods { pub trait LocationMethods {
fn Href(&self) -> DOMString; fn Href(&self) -> DOMString;
fn Search(&self) -> DOMString; fn Search(&self) -> DOMString;
fn Hash(&self) -> DOMString;
} }
impl<'a> LocationMethods for JSRef<'a, Location> { impl<'a> LocationMethods for JSRef<'a, Location> {
@ -50,6 +51,13 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
Some(ref query) => "?".to_string().append(query.as_slice()) Some(ref query) => "?".to_string().append(query.as_slice())
} }
} }
fn Hash(&self) -> DOMString {
match self.page.get_url().fragment {
None => "".to_string(),
Some(ref query) => "#".to_string().append(query.as_slice())
}
}
} }
impl Reflectable for Location { impl Reflectable for Location {

View file

@ -21,4 +21,5 @@ interface URLUtils {
readonly attribute DOMString search; readonly attribute DOMString search;
// attribute URLSearchParams searchParams; // attribute URLSearchParams searchParams;
// attribute ScalarValueString hash; // attribute ScalarValueString hash;
readonly attribute DOMString hash;
}; };