- From: Felix Becker <notifications@github.com>
- Date: Mon, 18 May 2020 11:48:17 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 18 May 2020 18:48:29 UTC
I tried to answer this by looking at the spec, which just says `URLSearchParams` itself is iterable: https://url.spec.whatwg.org/#interface-urlsearchparams
I then looked at [the definition `iterable` in the IDL spec](https://heycam.github.io/webidl/#idl-iterable), but it's still not clear to me whether the return value of `keys()` itself is iterable.
I also checked the [webplatform tests](https://github.com/web-platform-tests/wpt/tree/master/url) and couldn't find any test for this.
I noticed that Chrome and Safari return an iterable, meaning you can do this:
```ts
const params = new URLSearchParams('?foo=bar')
for (const param of params.keys()) {
console.log(param)
}
```
The same code in Firefox (77.0b6) throws a `TypeError: searchParams.keys() is not iterable`, so this is a web compat issue, but I don't know who is behaving correctly here.
As a consumer I have a use case for iterating `keys()` with `for of` so I'd prefer it to be iterable, and `Map`, `Set`, `Array` etc all behave this way.
--
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/521
Received on Monday, 18 May 2020 18:48:29 UTC