diff --git a/src/components/script/dom/location.rs b/src/components/script/dom/location.rs index 4427fb32e40..1a4eead966b 100644 --- a/src/components/script/dom/location.rs +++ b/src/components/script/dom/location.rs @@ -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 { diff --git a/src/components/script/dom/webidls/URLUtils.webidl b/src/components/script/dom/webidls/URLUtils.webidl index f2e081e8963..58fe13c5508 100644 --- a/src/components/script/dom/webidls/URLUtils.webidl +++ b/src/components/script/dom/webidls/URLUtils.webidl @@ -21,4 +21,5 @@ interface URLUtils { readonly attribute DOMString search; // attribute URLSearchParams searchParams; // attribute ScalarValueString hash; + readonly attribute DOMString hash; };