FormData
has()
should include a second param for matching the value like URLSearchParams
#392
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: formdata
What problem are you trying to solve?
FormData
objects can have multiple entries with the same key. TheFormData
has()
method is useful checking a key exists in the object, however, when there are multiple keys with the same name it is less useful since in that case you don’t just care about the key, but also if a key and value are present.What solutions exist today?
Today, it’s not terribly difficult to achieve this, but it does require getting all of the values as an array and then using
Array
methods to check if the value exists.For example, where formData is a
FormData
object:How would you solve it?
The
URLSearchParams
has()
method supports a second parameter for matching the value of the named param. For example, where searchParams is aURLSearchParams
object:This would be useful for
FormData
as well. So, again where formData is aFormData
object and thehas()
method supports a second parameter for matching the name and value in the object:Additionally, this would help authors as there would be increased API parity between
FormData
andURLSearchParams
.Anything else?
No response
The text was updated successfully, but these errors were encountered: