2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

Added IE version check helper function

This commit is contained in:
Anth Winter
2015-12-24 12:03:51 +00:00
parent 9a5dec2dc5
commit ff4b5edcbf
+23
View File
@@ -0,0 +1,23 @@
'use strict';
/**
* https://gist.github.com/padolsey/527683
*
* A short snippet for detecting versions of IE in JavaScript
* without resorting to user-agent sniffing
*
* @returns {Number|undefined} Number of IE version (5-9), otherwise undefined
*/
module.exports = function ieVersion() {
var undef;
var v = 3;
var div = document.createElement('div');
var all = div.getElementsByTagName('i');
while ((
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
));
return v > 4 ? v : undef;
};