avoid unnecessary work
authoralexlamsl <alexlamsl@gmail.com>
Tue, 19 Jan 2016 15:19:39 +0000 (23:19 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Tue, 19 Jan 2016 15:19:39 +0000 (23:19 +0800)
src/htmlminifier.js

index e91b37e..e529632 100644 (file)
 
     attrValue = cleanAttributeValue(tag, attrName, attrValue, options, attrs);
 
+    if (options.removeEmptyAttributes &&
+        canDeleteEmptyAttribute(tag, attrName, attrValue)) {
+      return '';
+    }
+
     if (attrValue !== undefined && !options.removeAttributeQuotes ||
         !canRemoveAttributeQuotes(attrValue)) {
       emittedAttrValue = attrQuote + attrValue + attrQuote;
       emittedAttrValue = attrValue;
     }
 
-    if (options.removeEmptyAttributes &&
-        canDeleteEmptyAttribute(tag, attrName, attrValue)) {
-      return '';
-    }
-
     if (attrValue === undefined || (options.collapseBooleanAttributes &&
         isBooleanAttribute(attrName, attrValue))) {
       attrFragment = attrName;