- From: James M Snell <notifications@github.com>
- Date: Wed, 28 Dec 2016 11:39:55 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 28 December 2016 19:40:27 UTC
The appears to be a slight ambiguity in the API for `URLSearchParams` as reported in Node.js issue https://github.com/nodejs/node/issues/10481.
Specifically, given the following test case:
```js
const url = new URL("http://domain.com/?var1=value&var2=");
const params = Array.from(url.searchParams);
// There is no `.clear()`
for (let param of url.searchParams) {
  console.log( param[0] );
  url.searchParams.delete( param[0] );
}
```
In Node.js, the iterator that is created is live... meaning that the call to `url.searchParams.delete()` modifies the iterator itself and the only key that is output to the console is `var1`. This behavior *matches* the behavior implemented in Firefox.
Chrome, on the other hand, appears to copy the data on creation of the iterator, causing both `var1` and `var2` to be output to the console (which, I believe, is what users would most often expect to happen).
Unless I'm simply not seeing something in the URL spec, it does not appear to be clear which is the correct behavior.
-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/188
Received on Wednesday, 28 December 2016 19:40:27 UTC