1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

Fix: IE9 throws an error when using document.activeElement in a frame

* See thread 21536 for more information
This commit is contained in:
Allan Jardine 2014-06-05 15:29:44 +01:00
parent 429feaad86
commit 6423ab7d67
2 changed files with 15 additions and 9 deletions

View File

@ -1 +1 @@
9ba4130c47db42b98a39a3d8cc8c8a40f0828529
d804658ef2e29f8647d8aba91955bdd8c3f34a8a

View File

@ -13774,17 +13774,23 @@
}
};
// Because this approach is destroying and recreating the paging
// elements, focus is lost on the select button which is bad for
// accessibility. So we want to restore focus once the draw has
// completed
var activeEl = $(document.activeElement).data('dt-idx');
// IE9 throws an 'unknown error' if document.activeElement is used
// inside an iframe or frame. Try / catch the error. Not good for
// accessibility, but neither are frames.
try {
// Because this approach is destroying and recreating the paging
// elements, focus is lost on the select button which is bad for
// accessibility. So we want to restore focus once the draw has
// completed
var activeEl = $(document.activeElement).data('dt-idx');
attach( $(host).empty(), buttons );
attach( $(host).empty(), buttons );
if ( activeEl !== null ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
if ( activeEl !== null ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
}
}
catch (e) {}
}
}
} );