diff --git a/README.md b/README.md index 4c95a8fd8c..f29916027f 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ Modernizr Modernizr tests which native CSS3 and HTML5 features are available in the current UA and makes the results available to you in two ways: -as properties on a global Modernizr object, and as classes on the +as properties on a global `Modernizr` object, and as classes on the `` element. This information allows you to progressively enhance your pages with a granular level of control over the experience. Modernizr has an optional (*not included*) conditional resource loader -called Modernizr.load(), based on Yepnope.js ([yepnopejs.com](http://yepnopejs.com/)). -To get a build that includes Modernizr.load(), as well as choosing +called `Modernizr.load()`, based on Yepnope.js ([yepnopejs.com](http://yepnopejs.com/)). +To get a build that includes `Modernizr.load()`, as well as choosing which tests to include, go to [www.modernizr.com/download/](http://www.modernizr.com/download/) [Full documentation on modernizr.com/docs/](http://www.modernizr.com/docs/) diff --git a/modernizr.js b/modernizr.js index b198b20b7f..b320c9678d 100644 --- a/modernizr.js +++ b/modernizr.js @@ -457,7 +457,8 @@ window.Modernizr = (function( window, document, undefined ) { }; tests['draganddrop'] = function() { - return isEventSupported('dragstart') && isEventSupported('drop'); + var div = document.createElement('div'); + return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div); }; // Mozilla is targeting to land MozWebSocket for FF6 @@ -1122,7 +1123,7 @@ window.Modernizr = (function( window, document, undefined ) { // Remove "no-js" class from element, if it exists: - docElement.className = docElement.className.replace(/\bno-js\b/, '') + docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') // Add the new classes to the element. + (enableClasses ? ' js ' + classes.join(' ') : ''); diff --git a/test/index.html b/test/index.html index 0dd08fce57..4e0241e74c 100644 --- a/test/index.html +++ b/test/index.html @@ -1,5 +1,5 @@ - + Modernizr Test Suite diff --git a/test/js/unit.js b/test/js/unit.js index 472e33ee16..c5de02b73a 100644 --- a/test/js/unit.js +++ b/test/js/unit.js @@ -37,12 +37,21 @@ test("document.documentElement is valid and correct",1, function() { test("no-js class is gone.", function() { - equals(document.documentElement.className.indexOf('no-js') , -1, - 'no-js is gone.'); + ok(!/(?:^|\s)no-js(?:^|\s)/.test(document.documentElement.className), + 'no-js class is gone'); - ok(/\bjs /.test(document.documentElement.className), - 'html.js class is present') - + ok(/(?:^|\s)js(?:^|\s)/.test(document.documentElement.className), + 'html.js class is present'); + + ok(/(?:^|\s)\+no-js(?:\s|$)/.test(document.documentElement.className), + 'html.+no-js class is still present'); + + ok(/(?:^|\s)no-js-(?:\s|$)/.test(document.documentElement.className), + 'html.no-js- class is still present'); + + ok(/(?:^|\s)i-has-no-js(?:\s|$)/.test(document.documentElement.className), + 'html.i-has-no-js class is still present'); + if (document.querySelector){ ok(document.querySelector('html.js') == document.documentElement, "document.querySelector('html.js') matches."); @@ -109,7 +118,8 @@ test('html classes are looking good',function(){ for (var i = 0, len = classes.length, aclass; i