Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
fix: multiple classes in class string fix
Browse files Browse the repository at this point in the history
  - Multiple classses in class attribute not prefixed when using classPrefix
  • Loading branch information
alok pepakayala authored and joshwiens committed Jul 16, 2017
1 parent a8d21ac commit 2024e06
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ function createClassPrefix(classPrefix) {
else {
var classIdx = getAttributeIndex(tag,'class');
if(classIdx >= 0) {
tag.attributes[classIdx][1] = classPrefix + tag.attributes[classIdx][1];
//Prefix classes when multiple classes are present
var classes = tag.attributes[classIdx][1];
var prefixedClassString = "";

classes = classes.replace(/[ ]+/,' ');
classes = classes.split(' ');
classes.forEach(function(classI){
prefixedClassString += classPrefix + classI + ' ';
});

tag.attributes[classIdx][1] = prefixedClassString;
}
}
return tag;
Expand Down

0 comments on commit 2024e06

Please sign in to comment.