Skip to content

Commit

Permalink
Add CSS Shapes feature detection. http://www.w3.org/TR/css3-exclusion…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhorvath committed Mar 20, 2013
1 parent daf5bcf commit d7e5756
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions feature-detects/css/shapes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define(['Modernizr', 'createElement', 'docElement'], function( Modernizr, createElement, docElement ) {
// http://www.w3.org/TR/css3-exclusions
// http://www.w3.org/TR/css3-exclusions/#shapes
// Examples: http://html.adobe.com/webstandards/cssexclusions
Modernizr.addTest('shapes', function () {
var prefixedProperty = Modernizr.prefixed('shapeInside');

if (!prefixedProperty)
return false;

var shapeInsideProperty = prefixedProperty.replace(/([A-Z])/g, function (str, m1) { return '-' + m1.toLowerCase(); }).replace(/^ms-/, '-ms-');

return Modernizr.testStyles('#modernizr { ' + shapeInsideProperty + ':rectangle(0,0,0,0) }', function (elem) {
// Check against computed value
var styleObj = window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle;
return styleObj[prefixed('shapeInside', docElement.style, false)] == 'rectangle(0px, 0px, 0px, 0px)';
});
});
});
1 change: 1 addition & 0 deletions lib/config-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"test/css/resize",
"test/css/rgba",
"test/css/scrollbars",
"test/css/shapes",
"test/css/subpixelfont",
"test/css/supports",
"test/css/textshadow",
Expand Down

0 comments on commit d7e5756

Please sign in to comment.