Skip to content

Commit

Permalink
do not add existing className
Browse files Browse the repository at this point in the history
  • Loading branch information
Maizify committed Aug 22, 2016
1 parent 79ecdd5 commit 1354d96
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ $.addClass = function($el, className) {
$el = [$el];
}
for (let i=0; i<$el.length; i++) {
$el[i].className += ' ' + className;
let name = $el[i].className || '',
arr = name.split(' ');
if (arr.indexOf(className) > -1) {
continue;
}
arr.push(className);
$el[i].className = arr.join(' ');
}
}

Expand Down

0 comments on commit 1354d96

Please sign in to comment.