Implement URLSearchParams::getAll

This commit is contained in:
Fernando Martins 2016-01-15 22:40:55 +00:00
parent 4cb2c87982
commit 29b14d4b3d
4 changed files with 13 additions and 16 deletions

View file

@ -87,6 +87,18 @@ impl URLSearchParamsMethods for URLSearchParams {
}).next() }).next()
} }
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall
fn GetAll(&self, name: USVString) -> Vec<USVString> {
let list = self.list.borrow();
list.iter().filter_map(|&(ref k, ref v)| {
if k == &name.0 {
Some(USVString(v.clone()))
} else {
None
}
}).collect()
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-has // https://url.spec.whatwg.org/#dom-urlsearchparams-has
fn Has(&self, name: USVString) -> bool { fn Has(&self, name: USVString) -> bool {
let list = self.list.borrow(); let list = self.list.borrow();

View file

@ -12,7 +12,7 @@ interface URLSearchParams {
void append(USVString name, USVString value); void append(USVString name, USVString value);
void delete(USVString name); void delete(USVString name);
USVString? get(USVString name); USVString? get(USVString name);
// sequence<USVString> getAll(USVString name); sequence<USVString> getAll(USVString name);
boolean has(USVString name); boolean has(USVString name);
void set(USVString name, USVString value); void set(USVString name, USVString value);
// iterable<USVString, USVString>; // iterable<USVString, USVString>;

View file

@ -15,12 +15,5 @@
[URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12)] [URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12)]
expected: FAIL expected: FAIL
[URLSearchParams interface: operation getAll(ScalarValueString)]
expected: FAIL
[URL interface: operation domainToUnicode(USVString)] [URL interface: operation domainToUnicode(USVString)]
expected: FAIL expected: FAIL
[URLSearchParams interface: operation getAll(USVString)]
expected: FAIL

View file

@ -1,8 +0,0 @@
[urlsearchparams-getall.html]
type: testharness
[getAll() basics]
expected: FAIL
[getAll() multiples]
expected: FAIL