A small snippet (106 characters) to detect if the browser supports the flex-wrap attribute (a lack of support could lead to an inability to render certain layouts)
-
-
Save atk/c191d9b2e0c37d032182 to your computer and use it in GitHub Desktop.
FlexWrap Support Detection
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
function a(b){ // b is undefined on inital call, on regex call it will contain the prefix + f/F | |
return !b ? | |
'f0OF0MozF0WebkitF0msF'.replace(/[^0]+/g, a) > 0 : // on undefined b, run a regex through the function | |
// matching attributes will yield 1, unmatching will result in 0; we compare the result '0000' or '0100' to 0 | |
+(b+'lexWrap' in document.body.style) // test if the flexwrap (or its browser-specific notation) is present, | |
// coerce the result to number: true => 1, false => 0 | |
} |
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
function a(b){return!b?'f0OF0MozF0WebkitF0msF'.replace(/[^0]+/g,a)>0:+(b+'lexWrap'in document.body.style)} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2015 Alex Lohr (formerly Kloss) alexthkloss@web.de | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "SupportsFlexWrap", | |
"description": "Detect FlexWrap support", | |
"keywords": [ | |
"CSS3", | |
"flexbox", | |
"flexwrap", | |
"flex", | |
"wrap" | |
] | |
} |
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
<!DOCTYPE html> | |
<title>Foo</title> | |
<div>Expected value: <b>true/false</b></div> | |
<div>Actual value: <b id="ret"></b></div> | |
<script> | |
// write a small example that shows off the API for your example | |
// and tests it in one fell swoop. | |
var myFunction = function a(b){return!b?'f0OF0MozF0WebkitF0msF'.replace(/[^0]+/g,a)>0:+(b+'lexWrap'in document.body.style)} | |
document.getElementById( "ret" ).innerHTML = myFunction() | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment