Re: [whatwg/url] URLSearchParams delete all vs delete one (#335)

> You can have multiple entries with the same key and all will be deleted.

Right, because you're calling .delete(key), which it inherits from masquerading as a Map; under the model that those methods act under, each key is unique among the k/v pairs, so deleting the key needs to ensure that afterwards the key is not present in the map. Essentially it just pretends that all subsequent k/v pairs with a repeated key don't exist, and ensures that the results after calling the methods accord with that - returning only the first from .get(), replacing all of them with .set(), deleting all of them with .delete().

But for the methods that aren't borrowed from Map (append, getAll), they use the mental model of a list of arbitrary k/v pairs, where none of the keys, values, or k/v pairs are necessarily unique. It would be odd if the 2-arg delete method operated under a *third* model, where the keys and values aren't unique but the k/v pairs are.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/335#issuecomment-1334569708
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/335/1334569708@github.com>

Received on Thursday, 1 December 2022 23:18:37 UTC