mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Merge pull request #2728 from Ms2ger/location-search
Implement Location.search.
This commit is contained in:
commit
0e394a65d3
2 changed files with 15 additions and 4 deletions
|
@ -6,13 +6,13 @@ use dom::bindings::codegen::Bindings::LocationBinding;
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
use page::Page;
|
||||||
|
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use page::Page;
|
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use serialize::{Encoder, Encodable};
|
use serialize::{Encoder, Encodable};
|
||||||
|
use std::rc::Rc;
|
||||||
|
use url::query_to_str;
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct Location {
|
pub struct Location {
|
||||||
|
@ -37,12 +37,22 @@ impl Location {
|
||||||
|
|
||||||
pub trait LocationMethods {
|
pub trait LocationMethods {
|
||||||
fn Href(&self) -> DOMString;
|
fn Href(&self) -> DOMString;
|
||||||
|
fn Search(&self) -> DOMString;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LocationMethods for JSRef<'a, Location> {
|
impl<'a> LocationMethods for JSRef<'a, Location> {
|
||||||
fn Href(&self) -> DOMString {
|
fn Href(&self) -> DOMString {
|
||||||
self.page.get_url().to_str()
|
self.page.get_url().to_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn Search(&self) -> DOMString {
|
||||||
|
let query = query_to_str(&self.page.get_url().query);
|
||||||
|
if query.as_slice() == "" {
|
||||||
|
query
|
||||||
|
} else {
|
||||||
|
"?".to_string().append(query.as_slice())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for Location {
|
impl Reflectable for Location {
|
||||||
|
|
|
@ -18,6 +18,7 @@ interface URLUtils {
|
||||||
// attribute ScalarValueString port;
|
// attribute ScalarValueString port;
|
||||||
// attribute ScalarValueString pathname;
|
// attribute ScalarValueString pathname;
|
||||||
// attribute ScalarValueString search;
|
// attribute ScalarValueString search;
|
||||||
|
readonly attribute DOMString search;
|
||||||
// attribute URLSearchParams searchParams;
|
// attribute URLSearchParams searchParams;
|
||||||
// attribute ScalarValueString hash;
|
// attribute ScalarValueString hash;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue