Skip to content

Commit

Permalink
css 3d transforms false positive fixed. fixes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Dec 8, 2009
1 parent c2fc59f commit ca95ecf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modernizr-test.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" dir="ltr" id="modernizr-1.0" class="no-js">
<html lang="en" dir="ltr" id="modernizr-1.1" class="no-js">
<head>
<title>Modernizr 1.0 Test Suite</title>
<style media="screen">
Expand Down
24 changes: 23 additions & 1 deletion modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,29 @@ window.Modernizr = (function(window,doc){
tests[csstransforms3d] = function() {
// set_css_all( 'perspective:500' );

return !!test_props([ 'perspectiveProperty', 'webkitPerspective', 'MozPerspective', 'mozPerspective', 'oPerspective', 'msPerspective' ]);
var ret = !!test_props([ 'perspectiveProperty', 'webkitPerspective', 'MozPerspective', 'mozPerspective', 'oPerspective', 'msPerspective' ]);

// webkit has 3d transforms disabled for chrome and safari, though
// it works fine in webkit nightly on (snow) leopard.
// as a result, it 'regonizes' the syntax and throws a false positive
// thus we must do a more thorough check.
if (ret){
var st = document.createElement('style'),
div = doc.createElement('div');

// webkit allows this media query to succeed only if the feature is enabled.
// "@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-ms-transform-3d),(-webkit-transform-3d),(modernizr){#modernizr{height:3px}}"
st.textContent = '@media ('+setProperties.join('transform-3d),(')+'modernizr){#modernizr{height:3px}}';
doc.getElementsByTagName('head')[0].appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);

ret = div.offsetHeight === 3;

st.parentNode.removeChild(st);
div.parentNode.removeChild(div);
}
return ret;
};

tests[csstransitions] = function() {
Expand Down

0 comments on commit ca95ecf

Please sign in to comment.