Re: [whatwg/url] searchParams.set("param", undefined) should not stringify as param=undefined (#427)

@domenic 

> The OP advocates for some kind of clearing, but in the poll only a very slight minority (57%) seem to expect that

I'm not sure how 57% is "a very slight minority". It's a majority by definition. 🤔

> Whereas the folks that expect the status quo are 43%.

How is 43% favoring the status quo? I see 26%. Are you adding it with the 17% which knows what the answer is? That doesn't make the answer intuitive to them, it just means they're exposed to it already, so their vote would not be useful. Ideally, the percentages should be calculated with that 17% ignored (i.e. 26/83, 30/83, 27/83).

> So it seems like any clearing change we make would be moving from expected-by-43% to either expected-by-30% or expected-by-27%. If anything, the poll points toward keeping the status quo!

You are assuming that for those who expect clearing, all other options are equivalently against their expectations. I'd argue that all clearing options are much closer to their expectations than the current behavior. I'd also argue that all clearing options would trigger fewer bugs in their code, since `""` or `null` are all expected values for a query parameter, whereas `"undefined"` is pretty much always the result of a bug.

> As for my personal take, I think "undefined" makes the most sense because that's how normal Maps work.

Regarding internal consistency, `JSON.stringify()` is just as relevant as `Map`, if not more:
```js
> JSON.stringify({a: 1, a: undefined})
< "{}"
```

>  The OP seems to be asking for some special-casing of key/value pairs where the value is undefined, which to me seems more complex.

Javascript *in general* special-cases `undefined` in a number of places. It's not that unheard of. But I like the way Anne put it better: it's not special casing `undefined`, it's making the value argument optional. Then, special-casing `undefined` just naturally follows.

-- 
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/427#issuecomment-458721589

Received on Tuesday, 29 January 2019 21:52:43 UTC