Last active
February 7, 2019 08:55
-
-
Save benjaminrau/09f86f5f77d688cb415bba872d42083c to your computer and use it in GitHub Desktop.
Outdated Browser - minified to return just boolean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Outdated Browser | |
* Version: 1.1.2 - 2015 | |
* author: Burocratik | |
* website: http://www.burocratik.com | |
*/ | |
var isOutdatedBrowser = function(lowerThan) { | |
//assign css3 property or js property to IE browser version | |
if (lowerThan == 'IE8' || lowerThan == 'borderSpacing') { | |
lowerThan = 'borderSpacing'; | |
} else if (lowerThan == 'IE9' || lowerThan == 'boxShadow') { | |
lowerThan = 'boxShadow'; | |
} else if (lowerThan == 'IE10' || lowerThan == 'transform' || lowerThan == '' || typeof lowerThan === "undefined") { | |
lowerThan = 'transform'; | |
} else if (lowerThan == 'IE11' || lowerThan == 'borderImage') { | |
lowerThan = 'borderImage'; | |
} else if (lowerThan == 'Edge' || lowerThan == 'js:Promise') { | |
lowerThan = 'js:Promise'; | |
} | |
if (!lowerThan) { | |
lowerThan = 'transform'; | |
} | |
cssProp = lowerThan; | |
var supports = ( function() { | |
var div = document.createElement('div'); | |
var vendors = 'Khtml Ms O Moz Webkit'.split(' '); | |
var len = vendors.length; | |
return function(prop) { | |
if (prop in div.style) return true; | |
prop = prop.replace(/^[a-z]/, function(val) { | |
return val.toUpperCase(); | |
}); | |
while (len--) { | |
if (vendors[len] + prop in div.style) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
} )(); | |
var validBrowser = false; | |
// browser check by js props | |
if(/^js:+/g.test(cssProp)) { | |
var jsProp = cssProp.split(':')[1]; | |
if(!jsProp) | |
return; | |
switch (jsProp) { | |
case 'Promise': | |
validBrowser = window.Promise !== undefined && window.Promise !== null && Object.prototype.toString.call(window.Promise.resolve()) === '[object Promise]'; | |
break; | |
default: | |
validBrowser = false; | |
} | |
} else { | |
// check by css3 property (transform=default) | |
validBrowser = supports('' + cssProp + ''); | |
} | |
return !validBrowser; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment