Merge pull request #2935 from Ms2ger/location-hash

Implement Location.hash.
This commit is contained in:
Josh Matthews 2014-07-27 10:19:30 -04:00
commit 7e7af3fca7
2 changed files with 9 additions and 0 deletions

View file

@ -37,6 +37,7 @@ impl Location {
pub trait LocationMethods {
fn Href(&self) -> DOMString;
fn Search(&self) -> DOMString;
fn Hash(&self) -> DOMString;
}
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())
}
}
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 {

View file

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