* @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#create-an-entry * @param {string} name * @param {string|Blob} value * @param {?string} filename * @returns
(name, value, filename)
| 240 | * @returns |
| 241 | */ |
| 242 | function makeEntry (name, value, filename) { |
| 243 | // 1. Set name to the result of converting name into a scalar value string. |
| 244 | // Note: This operation was done by the webidl converter USVString. |
| 245 | |
| 246 | // 2. If value is a string, then set value to the result of converting |
| 247 | // value into a scalar value string. |
| 248 | if (typeof value === 'string') { |
| 249 | // Note: This operation was done by the webidl converter USVString. |
| 250 | } else { |
| 251 | // 3. Otherwise: |
| 252 | |
| 253 | // 1. If value is not a File object, then set value to a new File object, |
| 254 | // representing the same bytes, whose name attribute value is "blob" |
| 255 | if (!webidl.is.File(value)) { |
| 256 | value = new File([value], 'blob', { type: value.type }) |
| 257 | } |
| 258 | |
| 259 | // 2. If filename is given, then set value to a new File object, |
| 260 | // representing the same bytes, whose name attribute is filename. |
| 261 | if (filename !== undefined) { |
| 262 | /** @type {FilePropertyBag} */ |
| 263 | const options = { |
| 264 | type: value.type, |
| 265 | lastModified: value.lastModified |
| 266 | } |
| 267 | |
| 268 | value = new File([value], filename, options) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // 4. Return an entry whose name is name and whose value is value. |
| 273 | return { name, value } |
| 274 | } |
| 275 | |
| 276 | webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData) |
| 277 |
no outgoing calls
no test coverage detected