Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement URL.searchParams #10351
Implement URL.searchParams #10351
Conversation
highfive
commented
Apr 1, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Apr 1, 2016
|
r? @Manishearth |
| @@ -24,19 +26,24 @@ pub struct URL { | |||
|
|
|||
| // https://url.spec.whatwg.org/#concept-urlutils-get-the-base | |||
| base: Option<Url>, | |||
|
|
|||
| // https://url.spec.whatwg.org/#dom-url-searchparams | |||
| query: JS<URLSearchParams>, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 2, 2016
Member
Technically we can't; a quick test in Firefox shows that mutating the object returned on url.searchParams will be reflected when accessed again. The spec does mention that a URL object has an associated URLSearchParams object, so this is correct I guess.
cc @Ms2ger does this particularly matter?
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 2, 2016
Member
Chrome doesn't seem to support searchParams at all? It autocompletes in the console but is undefined.
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 2, 2016
Member
Actually, this is a bit hairier if URLSearchParams is mutable through URL. It's also an iterator.
What happens if I mutate the original URL whilst iterating it?
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 2, 2016
Member
Firefox iterates index-wise, if you change the query string it will continue to iterate from that index in the new query string if that index exists.
let a=new URL("http://a.b/c?a=1&b=2&c=3&d=4");
let b = a.searchParams;
for (i of b) {
a.search="x=1&y=2&z=3";
console.log(i);
}
// outputs
Array [ "a", "1" ]
Array [ "y", "2" ]
Array [ "z", "3" ]| @@ -191,6 +202,11 @@ impl URLMethods for URL { | |||
| UrlHelper::SetSearch(&mut self.url.borrow_mut(), value); | |||
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 2, 2016
Member
All the setters should update the stored query object if we're going to store it as a field.
This comment has been minimized.
This comment has been minimized.
stjepang
Apr 2, 2016
Author
Contributor
Instead of calculating query pairs on-demand, I'd rather stick to the spec and store them immediately.
Regarding iteration, this is something we currently don't handle - it's commented in URLSearchParams.webidl:
// iterable<USVString, USVString>;
Please correct me if I'm wrong.
Firefox's approach looks reasonable to me. We'll just have to be careful when implementing the iterable interface.
|
Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/url.rs, line 31 [r1] (raw file): Also, please leave a comment about the iterable stuff somewhere. I think that bit is simply unspecced, so ultimately it might not matter much. Comments from Reviewable |
|
Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/url.rs, line 31 [r1] (raw file): I'll write a comment about the iterable stuff. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/url.rs, line 31 [r1] (raw file): I just remembered I had started to implement this, if you need some inspiration. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/url.rs, line 31 [r1] (raw file): Comments from Reviewable |
|
@bors-servo r+ Thanks! Reviewed 1 of 2 files at r1, 1 of 3 files at r2, 2 of 2 files at r3. Comments from Reviewable |
|
|
|
|
Implement URL.searchParams Spec: https://url.spec.whatwg.org/#dom-url-searchparams Closes #10335. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10351) <!-- Reviewable:end -->
|
|
|
|
r=me once you squash these commits |
|
@bors-servo r+ |
|
|
|
|
|
@bors-servo retry
|
Implement URL.searchParams Spec: https://url.spec.whatwg.org/#dom-url-searchparams Closes #10335. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10351) <!-- Reviewable:end -->
|
|
|
@bors-servo retry
|
Implement URL.searchParams Spec: https://url.spec.whatwg.org/#dom-url-searchparams Closes #10335. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10351) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry
|
|
@bors-servo p=1 |
Implement URL.searchParams Spec: https://url.spec.whatwg.org/#dom-url-searchparams Closes #10335. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10351) <!-- Reviewable:end -->
|
|
stjepang commentedApr 1, 2016
Spec: https://url.spec.whatwg.org/#dom-url-searchparams
Closes #10335.
This change is