1
1
'use strict'
2
2
3
- const { isBlobLike , iteratorMixin } = require ( './util' )
3
+ const { iteratorMixin } = require ( './util' )
4
4
const { kState } = require ( './symbols' )
5
5
const { kEnumerableProperty } = require ( '../../core/util' )
6
- const { FileLike, isFileLike } = require ( './file' )
7
6
const { webidl } = require ( './webidl' )
8
7
const { File : NativeFile } = require ( 'node:buffer' )
9
8
const nodeUtil = require ( 'node:util' )
@@ -31,7 +30,7 @@ class FormData {
31
30
const prefix = 'FormData.append'
32
31
webidl . argumentLengthCheck ( arguments , 2 , prefix )
33
32
34
- if ( arguments . length === 3 && ! isBlobLike ( value ) ) {
33
+ if ( arguments . length === 3 && ! ( value instanceof Blob ) ) {
35
34
throw new TypeError (
36
35
"Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'"
37
36
)
@@ -40,8 +39,8 @@ class FormData {
40
39
// 1. Let value be value if given; otherwise blobValue.
41
40
42
41
name = webidl . converters . USVString ( name )
43
- value = isBlobLike ( value )
44
- ? webidl . converters . Blob ( value , prefix , 'value' , { strict : false } )
42
+ value = value instanceof Blob
43
+ ? webidl . converters . Blob ( value , prefix , 'value' )
45
44
: webidl . converters . USVString ( value )
46
45
filename = arguments . length === 3
47
46
? webidl . converters . USVString ( filename )
@@ -124,7 +123,7 @@ class FormData {
124
123
const prefix = 'FormData.set'
125
124
webidl . argumentLengthCheck ( arguments , 2 , prefix )
126
125
127
- if ( arguments . length === 3 && ! isBlobLike ( value ) ) {
126
+ if ( arguments . length === 3 && ! ( value instanceof Blob ) ) {
128
127
throw new TypeError (
129
128
"Failed to execute 'set' on 'FormData': parameter 2 is not of type 'Blob'"
130
129
)
@@ -136,8 +135,8 @@ class FormData {
136
135
// 1. Let value be value if given; otherwise blobValue.
137
136
138
137
name = webidl . converters . USVString ( name )
139
- value = isBlobLike ( value )
140
- ? webidl . converters . Blob ( value , prefix , 'name' , { strict : false } )
138
+ value = value instanceof Blob
139
+ ? webidl . converters . Blob ( value , prefix , 'name' )
141
140
: webidl . converters . USVString ( value )
142
141
filename = arguments . length === 3
143
142
? webidl . converters . USVString ( filename )
@@ -222,10 +221,8 @@ function makeEntry (name, value, filename) {
222
221
223
222
// 1. If value is not a File object, then set value to a new File object,
224
223
// representing the same bytes, whose name attribute value is "blob"
225
- if ( ! isFileLike ( value ) ) {
226
- value = value instanceof Blob
227
- ? new File ( [ value ] , 'blob' , { type : value . type } )
228
- : new FileLike ( value , 'blob' , { type : value . type } )
224
+ if ( ! ( value instanceof File ) ) {
225
+ value = new File ( [ value ] , 'blob' , { type : value . type } )
229
226
}
230
227
231
228
// 2. If filename is given, then set value to a new File object,
@@ -237,9 +234,7 @@ function makeEntry (name, value, filename) {
237
234
lastModified : value . lastModified
238
235
}
239
236
240
- value = value instanceof NativeFile
241
- ? new File ( [ value ] , filename , options )
242
- : new FileLike ( value , filename , options )
237
+ value = new File ( [ value ] , filename , options )
243
238
}
244
239
}
245
240
0 commit comments