Created
May 19, 2016 12:33
-
-
Save kerbyfc/367e13cad712f11e1f34985a20beffcf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function isOutdatedBrowser(lowerThan?: string): boolean { | |
let cssProp: string; | |
lowerThan = lowerThan || ""; | |
//assign css3 property to IE browser version | |
if (lowerThan === "IE8" || lowerThan === "borderSpacing") { | |
cssProp = "borderSpacing"; | |
} else if (lowerThan === "IE9" || lowerThan === "boxShadow") { | |
cssProp = "boxShadow"; | |
} else if (lowerThan === "IE10" | |
|| lowerThan === "transform" | |
|| lowerThan === "") { | |
cssProp = "transform"; | |
} else if (lowerThan === "IE11" || lowerThan === "borderImage") { | |
cssProp = "borderImage"; | |
} | |
var supports: Function = (function(): Function { | |
var div: HTMLElement = document.createElement("div"); | |
var vendors: string[] = "Khtml Ms O Moz Webkit".split(" "); | |
var len: number = vendors.length; | |
return function(prop: string): boolean { | |
if (prop in div.style) return true; | |
prop = prop.replace(/^[a-z]/, function(val: string): string { | |
return val.toUpperCase(); | |
}); | |
while (len--) { | |
if (vendors[len] + prop in div.style) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
})(); | |
return (!supports("" + cssProp)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment