Skip to content

Commit d0a72b1

Browse files
committed
Modernizr-like no-js -> js <html> class replace
Minified Modernizr had a side-effect of replacing class of root <html> element from no-js to js, which was used in the CSS. Removing Modernizr broke the CSS, used for collapsing navigation menu. I have copied the small code snipped from Modernizr.
1 parent 4a545c8 commit d0a72b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

_includes/js/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
/*! Responsive Menu */
22
// http://tympanus.net/codrops/2013/05/08/responsive-retina-ready-menu/
33
// The function to change the class
4+
5+
// change root element class from no-js to js
6+
// copied from https://github.com/Modernizr/Modernizr/blob/5eea7e2a213edc9e83a47b6414d0250468d83471/src/setClasses.js
7+
function addJs() {
8+
var docElement = document.documentElement;
9+
var className = docElement.className;
10+
11+
var reJS = new RegExp('(^|\\s)no-js(\\s|$)');
12+
className = className.replace(reJS, '$1js$2');
13+
docElement.className = className;
14+
}
15+
16+
addJs();
17+
418
var changeClass = function (r,className1,className2) {
519
var regex = new RegExp("(?:^|\\s+)" + className1 + "(?:\\s+|$)");
620
if( regex.test(r.className) ) {

0 commit comments

Comments
 (0)