Strip trailing ";" from style attributes (this allows to strip quotes from values...
authorJuriy Zaytsev <kangax@gmail.com>
Mon, 15 Mar 2010 17:46:39 +0000 (13:46 -0400)
committerJuriy Zaytsev <kangax@gmail.com>
Mon, 15 Mar 2010 17:46:39 +0000 (13:46 -0400)
src/htmlminifier.js
tests/index.html

index fd7d940..e42e2db 100644 (file)
     else if (attrName === 'class') {
       return collapseWhitespace(trimWhitespace(attrValue));
     }
-    else if (isUriTypeAttribute(attrName, tag)
-          || isNumberTypeAttribute(attrName, tag) 
-          || attrName === 'style') {
+    else if (isUriTypeAttribute(attrName, tag) || isNumberTypeAttribute(attrName, tag)) {
       return trimWhitespace(attrValue);
     }
+    else if (attrName === 'style') {
+      return trimWhitespace(attrValue).replace(/\s*;\s*$/, '');
+    }
     return attrValue;
   }
   
index fab005b..bec13dc 100644 (file)
           equals(minify(input, { cleanAttributes: true }), output);
           
           input = '<p style="    color: red; background-color: rgb(100, 75, 200);  "></p>';
-          output = '<p style="color: red; background-color: rgb(100, 75, 200);"></p>';
+          output = '<p style="color: red; background-color: rgb(100, 75, 200)"></p>';
+          equals(minify(input, { cleanAttributes: true }), output);
+          
+          input = '<p style="font-weight: bold  ; "></p>';
+          output = '<p style="font-weight: bold"></p>';
           equals(minify(input, { cleanAttributes: true }), output);
         });