Skip to content

Commit

Permalink
Merge pull request Modernizr#1086 from zhorvath/master
Browse files Browse the repository at this point in the history
Modify the Shapes test to use shape-outside rather than shape-inside
  • Loading branch information
patrickkettner committed Oct 29, 2013
2 parents 2beb522 + 8e15804 commit fab0613
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions feature-detects/css/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
}]
}
!*/
define(['Modernizr', 'createElement', 'docElement', 'prefixed', 'testStyles'], function( Modernizr, createElement, docElement, prefixed, testStyles ) {
// Separate test for CSS shapes as WebKit has just implemented this alone
define(['Modernizr', 'createElement', 'docElement', 'prefixed', 'testStyles'], function(Modernizr, createElement, docElement, prefixed, testStyles ) {
Modernizr.addTest('shapes', function () {
var prefixedProperty = prefixed('shapeInside');
var prefixedProperty = prefixed('shapeOutside');

if (!prefixedProperty)
return false;

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

return testStyles('#modernizr { ' + shapeInsideProperty + ':rectangle(0,0,0,0,0,0) }', function (elem) {
return testStyles('#modernizr { float: left; ' + shapeOutsideProperty + ':rectangle(0,0,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, 0px, 0px)';
return styleObj[prefixed('shapeOutside', docElement.style, false)] == 'rectangle(0px, 0px, 0px, 0px, 0px, 0px)';
});
});
});

0 comments on commit fab0613

Please sign in to comment.