Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Modernizr/Modernizr
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 1, 2011
2 parents 8807f79 + 99f9e40 commit 34b4d96
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -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
`<html>` 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/)
Expand Down
5 changes: 3 additions & 2 deletions modernizr.js
Expand Up @@ -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
Expand Down Expand Up @@ -1122,7 +1123,7 @@ window.Modernizr = (function( window, document, undefined ) {


// Remove "no-js" class from <html> 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 <html> element.
+ (enableClasses ? ' js ' + classes.join(' ') : '');
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html class="no-js">
<html class="+no-js no-js- no-js i-has-no-js">
<head>
<meta charset="UTF-8">
<title>Modernizr Test Suite</title>
Expand Down
32 changes: 23 additions & 9 deletions test/js/unit.js
Expand Up @@ -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.");
Expand Down Expand Up @@ -109,7 +118,8 @@ test('html classes are looking good',function(){
for (var i = 0, len = classes.length, aclass; i <len; i++){
aclass = classes[i];

if (aclass === 'js') continue;
// Skip js related classes.
if (/^(?:js|\+no-js|no-js-|i-has-no-js)$/.test(aclass)) continue;

if (aclass.indexOf('no-') === 0){
aclass = aclass.replace('no-','');
Expand All @@ -128,9 +138,13 @@ test('html classes are looking good',function(){
equals(classes[i],classes[i].toLowerCase(),'all classes are lowerCase.');
}

equals(/[^\s]no-/.test(document.documentElement.className),false,
'whitespace between all classes.');

// Remove fake no-js classes before test.
var docElClass = document.documentElement.className;
$.each(['\\+no-js', 'no-js-', 'i-has-no-js'], function(i, fakeClass) {
docElClass = docElClass.replace(new RegExp('(^|\\s)' + fakeClass + '(\\s|$)', 'g'), '$1$2');
});
equals(/[^\s]no-/.test(docElClass), false, 'whitespace between all classes.');


})

Expand Down

0 comments on commit 34b4d96

Please sign in to comment.