From 779f77ec915f1218cce636cfa8d62ed58abbf317 Mon Sep 17 00:00:00 2001 From: alok pepakayala Date: Tue, 18 Oct 2016 18:19:13 +0530 Subject: [PATCH 1/2] multiple classes in class string fix Multiple classses in class attribute not prefixed when using classPrefix --- lib/transformer.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 989df92..99bbae8 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -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; From 851316af0af90c546cdd9ff37ec74cd88e606cfc Mon Sep 17 00:00:00 2001 From: alok pepakayala Date: Sat, 22 Oct 2016 03:36:26 +0530 Subject: [PATCH 2/2] Fix #41 corrupted css properties in style tag For CSS properties that contain '.' in the value. --- lib/transformer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 99bbae8..2326c95 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -58,7 +58,8 @@ function getAttributeIndex (tag, attr) { } function createClassPrefix(classPrefix) { - var re = /\.[\w\-]+/g; + //http://stackoverflow.com/questions/12391760/regex-match-css-class-name-from-single-string-containing-multiple-classes + var re = /\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)(?![^\{]*\})/g; var inStyleTag = false; return function prefixClasses(tag) {