Skip to content

Commit

Permalink
testProp() and testAllProps() now accept kebab-case – updating te…
Browse files Browse the repository at this point in the history
…sts & comments to match
  • Loading branch information
stucox committed May 21, 2014
1 parent cc29132 commit 48b9c4c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/testAllProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define(['ModernizrProto', 'testPropsAll'], function( ModernizrProto, testPropsAl
* parameter to skip the value check when native detection isn't available,
* to improve performance when simply testing for support of a property.
*
* @param prop - String naming the property to test
* @param prop - String naming the property to test (either camelCase or
* kebab-case)
* @param value - [optional] String of the value to test
* @param skipValueTest - [optional] Whether to skip testing that the value
* is supported when using non-native detection
Expand Down
2 changes: 1 addition & 1 deletion src/testProp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(['ModernizrProto', 'testProps'], function( ModernizrProto, testProps ) {
// Modernizr.testProp() investigates whether a given style property is recognized
// Note that the property names must be provided in the camelCase variant.
// Property names can be provided in either camelCase or kebab-case.
// Modernizr.testProp('pointerEvents')
// Also accepts optional 2nd arg, of a value to use for native feature detection, e.g.:
// Modernizr.testProp('pointerEvents', 'none')
Expand Down
7 changes: 1 addition & 6 deletions src/testProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ define(['contains', 'mStyle', 'createElement', 'nativeTestProps', 'is', 'cssToDO
// 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.
// Property names can be provided in either camelCase or kebab-case.

function testProps( props, prefixed, value, skipValueTest ) {
skipValueTest = is(skipValueTest, 'undefined') ? false : skipValueTest;
Expand Down
4 changes: 2 additions & 2 deletions test/js/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ test('Modernizr.testProp()',function(){

equal(false, Modernizr.testProp('happiness'), 'Nobody supports the happiness style. :(');
equal(true, Modernizr.testProp('fontSize'), 'Everyone supports fontSize');
equal(false, Modernizr.testProp('font-size'), 'Nobody supports font-size');
equal(true, Modernizr.testProp('font-size'), 'kebab-case should work too');

equal('pointerEvents' in document.createElement('div').style,
Modernizr.testProp('pointerEvents'),
Expand All @@ -437,7 +437,7 @@ test('Modernizr.testAllProps()',function(){

equal(false, Modernizr.testAllProps('happiness'), 'Nobody supports the happiness style. :(');
equal(true, Modernizr.testAllProps('fontSize'), 'Everyone supports fontSize');
equal(false, Modernizr.testAllProps('font-size'), 'Nobody supports font-size');
equal(true, Modernizr.testAllProps('font-size'), 'kebab-case should work too');

equal(Modernizr.csstransitions, Modernizr.testAllProps('transition'), 'Modernizr result matches API result: csstransitions');

Expand Down

0 comments on commit 48b9c4c

Please sign in to comment.