Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #633 from dbaron/master

Explicitly reject tests of CSS properties that have dashes
  • Loading branch information...
commit eeb5ca4ed751ea531306a77e3a726d8127ae8b00 2 parents 88e76ee + c1cdb50
@paulirish paulirish authored
Showing with 14 additions and 2 deletions.
  1. +10 −2 modernizr.js
  2. +4 −0 test/js/unit.js
View
12 modernizr.js
@@ -315,10 +315,18 @@ window.Modernizr = (function( window, document, undefined ) {
// on our modernizr element, but instead just testing undefined vs
// empty string.
+ // Because the testing of the CSS property names (with "-", as
+ // opposed to the camelCase DOM properties) is non-portable and
+ // non-standard but works in WebKit and IE (but not Gecko or Opera),
+ // we explicitly reject properties with dashes so that authors
+ // developing in WebKit or IE first don't end up with
+ // browser-specific content by accident.
+
function testProps( props, prefixed ) {
for ( var i in props ) {
- if ( mStyle[ props[i] ] !== undefined ) {
- return prefixed == 'pfx' ? props[i] : true;
+ var prop = props[i];
+ if ( prop.indexOf("-") == -1 && mStyle[prop] !== undefined ) {
+ return prefixed == 'pfx' ? prop : true;
}
}
return false;
View
4 test/js/unit.js
@@ -482,6 +482,8 @@ test('Modernizr.testProp()',function(){
equals(true, Modernizr.testProp('margin'), 'Everyone supports margin');
equals(false, Modernizr.testProp('happiness'), 'Nobody supports the happiness style. :(');
+ equals(true, Modernizr.testProp('fontSize'), 'Everyone supports fontSize');
+ equals(false, Modernizr.testProp('font-size'), 'Nobody supports font-size');
equals('pointerEvents' in document.createElement('div').style,
Modernizr.testProp('pointerEvents'),
@@ -496,6 +498,8 @@ test('Modernizr.testAllProps()',function(){
equals(true, Modernizr.testAllProps('margin'), 'Everyone supports margin');
equals(false, Modernizr.testAllProps('happiness'), 'Nobody supports the happiness style. :(');
+ equals(true, Modernizr.testAllProps('fontSize'), 'Everyone supports fontSize');
+ equals(false, Modernizr.testAllProps('font-size'), 'Nobody supports font-size');
equals(Modernizr.csstransitions, Modernizr.testAllProps('transition'), 'Modernizr result matches API result: csstransitions');
Please sign in to comment.
Something went wrong with that request. Please try again.