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

Commit 2024e06

Browse files
alok pepakayalajoshwiens
alok pepakayala
authored andcommitted
fix: multiple classes in class string fix
- Multiple classses in class attribute not prefixed when using classPrefix
1 parent a8d21ac commit 2024e06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/transformer.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,17 @@ function createClassPrefix(classPrefix) {
8383
else {
8484
var classIdx = getAttributeIndex(tag,'class');
8585
if(classIdx >= 0) {
86-
tag.attributes[classIdx][1] = classPrefix + tag.attributes[classIdx][1];
86+
//Prefix classes when multiple classes are present
87+
var classes = tag.attributes[classIdx][1];
88+
var prefixedClassString = "";
89+
90+
classes = classes.replace(/[ ]+/,' ');
91+
classes = classes.split(' ');
92+
classes.forEach(function(classI){
93+
prefixedClassString += classPrefix + classI + ' ';
94+
});
95+
96+
tag.attributes[classIdx][1] = prefixedClassString;
8797
}
8898
}
8999
return tag;

0 commit comments

Comments
 (0)