Skip to content

Commit 5282324

Browse files
committed
fix(Importer): Account for older browsers properly
* Tests were broken in IE9 and Safari 5 because they didn't support the File API. Made tests conditional so that certain ones only run when the File API is available. If it isn't, a test will make sure the importer is disabled. * importer.js was using `this.grid.options` when it should have used `gridOptions`, in one case * `gridOptions.importerShowMenu !== false` evaluates to true when the property is undefined. Changed to use `!!` to coerce to boolean. * `if (window.File)` and other tests fail in Safari (and possibly other browsers) because the property is undefined. Changed to use $window.hasOwnProperty.
1 parent 35431b6 commit 5282324

File tree

2 files changed

+304
-286
lines changed

2 files changed

+304
-286
lines changed

src/features/importer/js/importer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@
130130
* Otherwise defaults to true.
131131
*
132132
*/
133-
if (gridOptions.enableImporter || gridOptions.enableImporter === undefined){
134-
if ( !(window.File && window.FileReader && window.FileList && window.Blob)) {
133+
if (gridOptions.enableImporter || gridOptions.enableImporter === undefined) {
134+
if ( !($window.hasOwnProperty('File') && $window.hasOwnProperty('FileReader') && $window.hasOwnProperty('FileList') && $window.hasOwnProperty('Blob')) ) {
135135
$log.error('The File APIs are not fully supported in this browser, grid importer cannot be used.');
136-
this.grid.options.enableImporter = false;
136+
gridOptions.enableImporter = false;
137137
} else {
138138
gridOptions.enableImporter = true;
139139
}
@@ -236,7 +236,7 @@
236236
if ( gridOptions.enableImporter && ( !gridOptions.importerInputElement || !gridOptions.importerInputElement.append ) ) {
237237
gridOptions.importerShowMenu = false;
238238
} else {
239-
gridOptions.importerShowMenu = gridOptions.importerShowMenu !== false;
239+
gridOptions.importerShowMenu = !!gridOptions.importerShowMenu;
240240
}
241241
},
242242

0 commit comments

Comments
 (0)