Skip to content

Commit 60f2e98

Browse files
authored
Merge pull request #1 from scala-js/js-dom/formData
Add MDN documentation strings for FormData
2 parents 3fc37fe + 8989d97 commit 60f2e98

File tree

1 file changed

+67
-9
lines changed

1 file changed

+67
-9
lines changed

dom/src/main/scala/org/scalajs/dom/FormData.scala

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,101 @@ import scala.scalajs.js.|
1818
@JSGlobal
1919
class FormData(form: HTMLFormElement = js.native) extends js.Iterable[js.Tuple2[String, String]] {
2020

21-
/** Appends a key/value pair to the FormData object. */
21+
/** The `append()` method of the `FormData` interface appends a new value onto an existing key inside a `FormData`
22+
* object, or adds the key if it does not already exist.
23+
*
24+
* @param name
25+
* The name of the field whose data is contained in value.
26+
* @param value
27+
* The field's value. This can be a string or `Blob` (including subclasses such as File). If none of these are
28+
* specified the value is converted to a string.
29+
*/
2230
def append(name: js.Any, value: String): Unit = js.native
2331

32+
/** The `append()` method of the `FormData` interface appends a new value onto an existing key inside a `FormData`
33+
* object, or adds the key if it does not already exist.
34+
*
35+
* @param name
36+
* The name of the field whose data is contained in value.
37+
* @param value
38+
* The field's value. This can be a string or `Blob` (including subclasses such as File). If none of these are
39+
* specified the value is converted to a string.
40+
* @param blobName
41+
* The filename reported to the server (a string), when a `Blob` or `File` is passed as the second parameter. The
42+
* default filename for `Blob` objects is "blob". The default filename for `File` objects is the file's filename.
43+
*/
2444
def append(name: js.Any, value: Blob, blobName: String): Unit = js.native
2545

26-
/** Deletes a key/value pair from the FormData object. */
46+
/** The `delete()` method of the `FormData` interface deletes a key and its value(s) from a `FormData` object.
47+
* @param name
48+
* The name of the key you want to delete.
49+
*/
2750
def delete(name: String): Unit = js.native
2851

29-
/** Returns the first value associated with a given key from within a FormData object. */
52+
/** The `get()` method of the `FormData` interface returns the first value associated with a given key from within a
53+
* `FormData` object. If you expect multiple values and want all of them, use the `getAll()` method instead.
54+
*
55+
* @param name
56+
* A string representing the name of the key you want to retrieve.
57+
* @return
58+
* A value whose key matches the specified name. Otherwise, `null`.
59+
*/
3060
def get(name: String): String | Blob = js.native
3161

32-
/** Returns whether a FormData object contains a certain key. */
62+
/** The `has()` method of the `FormData` interface returns whether a `FormData` object contains a certain key.
63+
*
64+
* @param name
65+
* A string representing the name of the key you want to test for.
66+
* @return
67+
* `true` if a key of `FormData` matches the specified name. Otherwise, `false`.
68+
*/
3369
def has(name: String): Boolean = js.native
3470

35-
/** Sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
71+
/** The `set()` method of the `FormData` interface sets a new value for an existing key inside a `FormData` object, or
72+
* adds the key/value if it does not already exist.
73+
*
74+
* @param name
75+
* The name of the field whose data is contained in value.
76+
* @param value
77+
* The field's value.
3678
*/
3779
def set(
3880
name: String, value: String
3981
): Unit = js.native
4082

83+
/** The `set()` method of the `FormData` interface sets a new value for an existing key inside a `FormData` object, or
84+
* adds the key/value if it does not already exist.
85+
*
86+
* @param name
87+
* The name of the field whose data is contained in value.
88+
* @param value
89+
* The field's value.
90+
*/
4191
def set(
4292
name: String, value: Blob, blobName: String
4393
): Unit = js.native
4494

4595
@JSName(js.Symbol.iterator)
4696
override def jsIterator(): js.Iterator[js.Tuple2[String, String]] = js.native
4797

48-
/** Returns an iterator that iterates through all key/value pairs contained in the FormData. */
98+
/** The `FormData.entries()` method returns an iterator which iterates through all key/value pairs contained in the
99+
* `FormData`. The key of each pair is a string object, and the value is either a string or a `Blob`.
100+
*/
49101
def entries(): js.Iterator[js.Tuple2[String, String | Blob]] = js.native
50102

51-
/** Returns an array of all the values associated with a given key from within a FormData. */
103+
/** The `getAll()` method of the `FormData` interface returns all the values associated with a given key from within a
104+
* `FormData` object.
105+
*/
52106
def getAll(name: String): js.Array[String | Blob] = js.native
53107

54-
/** Returns an iterator iterates through all keys of the key/value pairs contained in the FormData. */
108+
/** The `FormData.keys()` method returns an iterator which iterates through all keys contained in the `FormData`. The
109+
* keys are strings.
110+
*/
55111
def keys(): js.Iterator[String] = js.native
56112

57-
/** Returns an iterator that iterates through all values contained in the FormData. */
113+
/** The `FormData.values()` method returns an iterator which iterates through all values contained in the `FormData`.
114+
* The values are strings or `Blob` objects.
115+
*/
58116
def values(): js.Iterator[String | Blob] = js.native
59117
}
60118

0 commit comments

Comments
 (0)