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 upMake URLSearchParams iterable #13022 #13077
Conversation
highfive
commented
Aug 27, 2016
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @connorgbrewster (or someone else) soon. |
highfive
commented
Aug 27, 2016
|
Heads up! This PR modifies the following files:
|
|
Use |
| <script> | ||
| test(function() { | ||
| var params = new URLSearchParams('a=1&b=2&c=3'); | ||
| for(var URLSearchParam in params){ |
This comment has been minimized.
This comment has been minimized.
jdm
Aug 27, 2016
Member
This test doesn't actually verify that the keys are present. I don't think for in works on iterators this way, either, since Firefox didn't show me any of those keys when I tried it.
This comment has been minimized.
This comment has been minimized.
|
Review status: 0 of 4 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. components/script/dom/urlsearchparams.rs, line 172 [r2] (raw file):
nit: Use components/script/dom/urlsearchparams.rs, line 194 [r2] (raw file):
why are we sorting this each time we're accessed? I don't think that's necessary? Comments from Reviewable |
|
@emilio |
| type Value = USVString; | ||
|
|
||
| fn get_iterable_length(&self) -> u32 { | ||
| self.list.borrow().iter().count() as u32 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
emilio
Aug 27, 2016
Member
Yes, it should, r=me with that. A test with something like what is described in #10351 would be great too :)
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" ]
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors-servo: try |
Make URLSearchParams iterable #13022 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13022 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13077) <!-- Reviewable:end -->
|
The test is incorrect, it could pass if the URLSearchParams is thought to be empty. |
|
@nox |
|
|
||
| test(function() { | ||
| var params = new URLSearchParams('a=1&b=2&c=3'); | ||
| params.forEach(function(value,index){ |
This comment has been minimized.
This comment has been minimized.
Ms2ger
Aug 31, 2016
•
Contributor
I think the suggestion was to make this test more like
var found = [];
params.forEach(function(value, index) {
found.push(value);
});
assert_array_equals(['1', '2', '3']);
This comment has been minimized.
This comment has been minimized.
|
@yoyo930021 hey, do you know if you'll have time to finish this PR? |
|
I dont know! |
|
r? @emilio |
|
Sorry for the huge delay in reviewing this! There are only formatting nits to fix. If for some reason you're busy and have the PR marked as editable for the Servo members, I can make the fixes myself and get this landed. Thank you so much for your contribution, and sorry for the delay again, it has totally been my fault! |
| let b = a.searchParams; | ||
| var c = []; | ||
| for (i of b) { | ||
| a.search="x=1&y=2&z=3"; |
This comment has been minimized.
This comment has been minimized.
| }, "For-of Check"); | ||
|
|
||
| test(function(){ | ||
| let a=new URL("http://a.b/c"); |
This comment has been minimized.
This comment has been minimized.
| for (i of b) { | ||
| c.push(i); | ||
| } | ||
| assert_equals(c.length,0); |
This comment has been minimized.
This comment has been minimized.
|
|
Make URLSearchParams iterable. Fixes #13022. Fixes #13077. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13637) <!-- Reviewable:end -->
yoyo930021 commentedAug 27, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is