mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Merge pull request #2935 from Ms2ger/location-hash
Implement Location.hash.
This commit is contained in:
commit
7e7af3fca7
2 changed files with 9 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -21,4 +21,5 @@ interface URLUtils {
|
|||
readonly attribute DOMString search;
|
||||
// attribute URLSearchParams searchParams;
|
||||
// attribute ScalarValueString hash;
|
||||
readonly attribute DOMString hash;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue