@@ -114,11 +114,11 @@ export class UUIFileDropzoneElement extends LabelMixin('', LitElement) {
114
114
queue . push ( dataTransferItemList [ i ] . webkitGetAsEntry ( ) ) ;
115
115
}
116
116
117
+ const acceptList : string [ ] = [ ] ;
118
+ const wildcards : string [ ] = [ ] ;
119
+
117
120
// if the accept filer is set
118
121
if ( this . accept ) {
119
- const acceptList : string [ ] = [ ] ;
120
- const wildcards : string [ ] = [ ] ;
121
-
122
122
// Create the arrays defined above
123
123
this . accept . split ( ',' ) . forEach ( item => {
124
124
if ( item . includes ( '*' ) ) {
@@ -127,6 +127,7 @@ export class UUIFileDropzoneElement extends LabelMixin('', LitElement) {
127
127
acceptList . push ( item . trim ( ) . toLowerCase ( ) ) ;
128
128
}
129
129
} ) ;
130
+ }
130
131
131
132
while ( queue . length > 0 ) {
132
133
const entry : FileSystemFileEntry = queue . shift ( ) ! ;
@@ -189,27 +190,22 @@ export class UUIFileDropzoneElement extends LabelMixin('', LitElement) {
189
190
}
190
191
}
191
192
192
- private async _getFile ( fileEntry : FileSystemFileEntry ) : Promise < File > {
193
- return await new Promise < File > ( ( resolve , reject ) =>
194
- fileEntry . file ( resolve , reject )
195
- ) ;
196
- }
193
+ private _isAccepted ( acceptList : string[ ] , wildcards : string[ ] , file : File ) {
194
+ if ( acceptList . length === 0 && wildcards . length === 0 ) {
195
+ return true ;
196
+ }
197
197
198
- private async _isAccepted (
199
- acceptList : string [ ] ,
200
- wildcards : string [ ] ,
201
- entry : FileSystemFileEntry
202
- ) {
203
- const file = await this . _getFile ( entry ) ;
204
198
const fileType = file . type . toLowerCase ( ) ;
205
199
const fileExtension = '.' + file . name . split ( '.' ) [ 1 ] . toLowerCase ( ) ;
206
200
207
201
if ( acceptList . includes ( fileExtension ) ) {
208
202
return true ;
209
203
}
204
+
210
205
if ( acceptList . includes ( fileType ) ) {
211
206
return true ;
212
207
}
208
+
213
209
if ( wildcards . some ( wildcard => fileType . startsWith ( wildcard ) ) ) {
214
210
return true ;
215
211
}
0 commit comments