Skip to content

Commit

Permalink
Avoid unnecessary indexOf from toggleClass
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdecker committed Jan 29, 2014
1 parent dfd0595 commit 9e0ebe7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/api/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ var toggleClass = exports.toggleClass = function(value, stateVal) {
// Check if class already exists
for (var j = 0; j < numClasses; j++) {
// Check if the class name is curently defined
index = elementClasses.indexOf(classNames[j]);
index = !isBool || !stateVal ? elementClasses.indexOf(classNames[j]) : -1;

// Add if stateValue === true or we are toggling and there is no value
if (isBool ? stateVal : index < 0) {
Expand Down

0 comments on commit 9e0ebe7

Please sign in to comment.