Navigation Menu

Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
Use DOM APIs for matching classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremia Kimelman committed Apr 28, 2016
1 parent 4acfc8d commit 8fe4f7b
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions js/main.js
@@ -1,17 +1,8 @@
(function(window) {
function hasClass(el, c) {
var classes = el.className.split(' ');
var match;
if (classes.length === 0) return false;
match = classes.find(function(i) { return i === c; });
if (!match) return false;
return true;
}

document.body.addEventListener('click', function(e) {
if (e.target.matches('aside h3 span')) {
var downloadEl = document.querySelector('#downloads');
if (hasClass(downloadEl, 'open')) {
if (downloadEl.matches('.open')) {
return downloadEl.classList.remove('open');
}
return downloadEl.classList.add('open');
Expand Down

0 comments on commit 8fe4f7b

Please sign in to comment.