Skip to content

Commit

Permalink
fix(Importer): Account for older browsers properly
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
c0bra committed Oct 14, 2014
1 parent 35431b6 commit 5282324
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 286 deletions.
8 changes: 4 additions & 4 deletions src/features/importer/js/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
* Otherwise defaults to true.
*
*/
if (gridOptions.enableImporter || gridOptions.enableImporter === undefined){
if ( !(window.File && window.FileReader && window.FileList && window.Blob)) {
if (gridOptions.enableImporter || gridOptions.enableImporter === undefined) {
if ( !($window.hasOwnProperty('File') && $window.hasOwnProperty('FileReader') && $window.hasOwnProperty('FileList') && $window.hasOwnProperty('Blob')) ) {
$log.error('The File APIs are not fully supported in this browser, grid importer cannot be used.');
this.grid.options.enableImporter = false;
gridOptions.enableImporter = false;
} else {
gridOptions.enableImporter = true;
}
Expand Down Expand Up @@ -236,7 +236,7 @@
if ( gridOptions.enableImporter && ( !gridOptions.importerInputElement || !gridOptions.importerInputElement.append ) ) {
gridOptions.importerShowMenu = false;
} else {
gridOptions.importerShowMenu = gridOptions.importerShowMenu !== false;
gridOptions.importerShowMenu = !!gridOptions.importerShowMenu;
}
},

Expand Down
Loading

0 comments on commit 5282324

Please sign in to comment.