enforce eslint no-extra-parens
authoralexlamsl <alexlamsl@gmail.com>
Thu, 31 Mar 2016 10:43:41 +0000 (18:43 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Thu, 31 Mar 2016 17:24:38 +0000 (01:24 +0800)
.eslintrc.json
assets/master.js
dist/htmlminifier.js
src/htmllint.js
src/htmlminifier.js
tests/minifier.js

index 640854f..38469d3 100644 (file)
@@ -40,6 +40,7 @@
     "new-parens": "error",
     "no-array-constructor": "error",
     "no-console": "off",
+    "no-extra-parens": "error",
     "no-floating-decimal": "error",
     "no-lone-blocks": "error",
     "no-lonely-if": "error",
index 4316ade..6114b7f 100644 (file)
@@ -52,7 +52,7 @@
           originalValue = byId('input').value,
           minifiedValue = minify(originalValue, options),
           diff = originalValue.length - minifiedValue.length,
-          savings = originalValue.length ? ((100 * diff) / originalValue.length).toFixed(2) : 0;
+          savings = originalValue.length ? (100 * diff / originalValue.length).toFixed(2) : 0;
 
       byId('output').value = minifiedValue;
 
index 003973c..827e751 100644 (file)
@@ -31077,58 +31077,55 @@ exports.createMapFromString = function(values, ignoreCase) {
 'use strict';
 
 function isPresentationalElement(tag) {
-  return (/^(?:big|small|hr|blink|marquee)$/).test(tag);
+  return /^(?:big|small|hr|blink|marquee)$/.test(tag);
 }
 function isDeprecatedElement(tag) {
-  return (/^(?:applet|basefont|center|dir|font|isindex|strike)$/).test(tag);
+  return /^(?:applet|basefont|center|dir|font|isindex|strike)$/.test(tag);
 }
 function isEventAttribute(attrName) {
-  return (/^on[a-z]+/).test(attrName);
+  return /^on[a-z]+/.test(attrName);
 }
 function isStyleAttribute(attrName) {
-  return (attrName.toLowerCase() === 'style');
+  return attrName.toLowerCase() === 'style';
 }
 function isDeprecatedAttribute(tag, attrName) {
   return (
-    (attrName === 'align' &&
-    (/^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/).test(tag)) ||
-    (attrName === 'alink' && tag === 'body') ||
-    (attrName === 'alt' && tag === 'applet') ||
-    (attrName === 'archive' && tag === 'applet') ||
-    (attrName === 'background' && tag === 'body') ||
-    (attrName === 'bgcolor' && (/^(?:table|t[rdh]|body)$/).test(tag)) ||
-    (attrName === 'border' && (/^(?:img|object)$/).test(tag)) ||
-    (attrName === 'clear' && tag === 'br') ||
-    (attrName === 'code' && tag === 'applet') ||
-    (attrName === 'codebase' && tag === 'applet') ||
-    (attrName === 'color' && (/^(?:base(?:font)?)$/).test(tag)) ||
-    (attrName === 'compact' && (/^(?:dir|[dou]l|menu)$/).test(tag)) ||
-    (attrName === 'face' && (/^base(?:font)?$/).test(tag)) ||
-    (attrName === 'height' && (/^(?:t[dh]|applet)$/).test(tag)) ||
-    (attrName === 'hspace' && (/^(?:applet|img|object)$/).test(tag)) ||
-    (attrName === 'language' && tag === 'script') ||
-    (attrName === 'link' && tag === 'body') ||
-    (attrName === 'name' && tag === 'applet') ||
-    (attrName === 'noshade' && tag === 'hr') ||
-    (attrName === 'nowrap' && (/^t[dh]$/).test(tag)) ||
-    (attrName === 'object' && tag === 'applet') ||
-    (attrName === 'prompt' && tag === 'isindex') ||
-    (attrName === 'size' && (/^(?:hr|font|basefont)$/).test(tag)) ||
-    (attrName === 'start' && tag === 'ol') ||
-    (attrName === 'text' && tag === 'body') ||
-    (attrName === 'type' && (/^(?:li|ol|ul)$/).test(tag)) ||
-    (attrName === 'value' && tag === 'li') ||
-    (attrName === 'version' && tag === 'html') ||
-    (attrName === 'vlink' && tag === 'body') ||
-    (attrName === 'vspace' && (/^(?:applet|img|object)$/).test(tag)) ||
-    (attrName === 'width' && (/^(?:hr|td|th|applet|pre)$/).test(tag))
+    attrName === 'align' &&
+    /^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/.test(tag) ||
+    attrName === 'alink' && tag === 'body' ||
+    attrName === 'alt' && tag === 'applet' ||
+    attrName === 'archive' && tag === 'applet' ||
+    attrName === 'background' && tag === 'body' ||
+    attrName === 'bgcolor' && /^(?:table|t[rdh]|body)$/.test(tag) ||
+    attrName === 'border' && /^(?:img|object)$/.test(tag) ||
+    attrName === 'clear' && tag === 'br' ||
+    attrName === 'code' && tag === 'applet' ||
+    attrName === 'codebase' && tag === 'applet' ||
+    attrName === 'color' && /^(?:base(?:font)?)$/.test(tag) ||
+    attrName === 'compact' && /^(?:dir|[dou]l|menu)$/.test(tag) ||
+    attrName === 'face' && /^base(?:font)?$/.test(tag) ||
+    attrName === 'height' && /^(?:t[dh]|applet)$/.test(tag) ||
+    attrName === 'hspace' && /^(?:applet|img|object)$/.test(tag) ||
+    attrName === 'language' && tag === 'script' ||
+    attrName === 'link' && tag === 'body' ||
+    attrName === 'name' && tag === 'applet' ||
+    attrName === 'noshade' && tag === 'hr' ||
+    attrName === 'nowrap' && /^t[dh]$/.test(tag) ||
+    attrName === 'object' && tag === 'applet' ||
+    attrName === 'prompt' && tag === 'isindex' ||
+    attrName === 'size' && /^(?:hr|font|basefont)$/.test(tag) ||
+    attrName === 'start' && tag === 'ol' ||
+    attrName === 'text' && tag === 'body' ||
+    attrName === 'type' && /^(?:li|ol|ul)$/.test(tag) ||
+    attrName === 'value' && tag === 'li' ||
+    attrName === 'version' && tag === 'html' ||
+    attrName === 'vlink' && tag === 'body' ||
+    attrName === 'vspace' && /^(?:applet|img|object)$/.test(tag) ||
+    attrName === 'width' && /^(?:hr|td|th|applet|pre)$/.test(tag)
   );
 }
 function isInaccessibleAttribute(attrName, attrValue) {
-  return (
-    attrName === 'href' &&
-    (/^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i).test(attrValue)
-  );
+  return attrName === 'href' && /^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i.test(attrValue);
 }
 
 function Lint() {
@@ -31884,13 +31881,13 @@ function isEventAttribute(attrName, options) {
     return false;
   }
   else {
-    return (/^on[a-z]{3,}$/).test(attrName);
+    return /^on[a-z]{3,}$/.test(attrName);
   }
 }
 
 function canRemoveAttributeQuotes(value) {
   // http://mathiasbynens.be/notes/unquoted-attribute-values
-  return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value);
+  return /^[^\x20\t\n\f\r"'`=<>]+$/.test(value);
 }
 
 function attributesInclude(attributes, attribute) {
@@ -31906,29 +31903,29 @@ function isAttributeRedundant(tag, attrName, attrValue, attrs) {
   attrValue = attrValue ? trimWhitespace(attrValue.toLowerCase()) : '';
 
   return (
-      (tag === 'script' &&
+      tag === 'script' &&
       attrName === 'language' &&
-      attrValue === 'javascript') ||
+      attrValue === 'javascript' ||
 
-      (tag === 'form' &&
+      tag === 'form' &&
       attrName === 'method' &&
-      attrValue === 'get') ||
+      attrValue === 'get' ||
 
-      (tag === 'input' &&
+      tag === 'input' &&
       attrName === 'type' &&
-      attrValue === 'text') ||
+      attrValue === 'text' ||
 
-      (tag === 'script' &&
+      tag === 'script' &&
       attrName === 'charset' &&
-      !attributesInclude(attrs, 'src')) ||
+      !attributesInclude(attrs, 'src') ||
 
-      (tag === 'a' &&
+      tag === 'a' &&
       attrName === 'name' &&
-      attributesInclude(attrs, 'id')) ||
+      attributesInclude(attrs, 'id') ||
 
-      (tag === 'area' &&
+      tag === 'area' &&
       attrName === 'shape' &&
-      attrValue === 'rect')
+      attrValue === 'rect'
   );
 }
 
@@ -31996,28 +31993,28 @@ function isBooleanAttribute(attrName, attrValue) {
 
 function isUriTypeAttribute(attrName, tag) {
   return (
-    ((/^(?:a|area|link|base)$/).test(tag) && attrName === 'href') ||
-    (tag === 'img' && (/^(?:src|longdesc|usemap)$/).test(attrName)) ||
-    (tag === 'object' && (/^(?:classid|codebase|data|usemap)$/).test(attrName)) ||
-    (tag === 'q' && attrName === 'cite') ||
-    (tag === 'blockquote' && attrName === 'cite') ||
-    ((tag === 'ins' || tag === 'del') && attrName === 'cite') ||
-    (tag === 'form' && attrName === 'action') ||
-    (tag === 'input' && (attrName === 'src' || attrName === 'usemap')) ||
-    (tag === 'head' && attrName === 'profile') ||
-    (tag === 'script' && (attrName === 'src' || attrName === 'for'))
+    /^(?:a|area|link|base)$/.test(tag) && attrName === 'href' ||
+    tag === 'img' && /^(?:src|longdesc|usemap)$/.test(attrName) ||
+    tag === 'object' && /^(?:classid|codebase|data|usemap)$/.test(attrName) ||
+    tag === 'q' && attrName === 'cite' ||
+    tag === 'blockquote' && attrName === 'cite' ||
+    (tag === 'ins' || tag === 'del') && attrName === 'cite' ||
+    tag === 'form' && attrName === 'action' ||
+    tag === 'input' && (attrName === 'src' || attrName === 'usemap') ||
+    tag === 'head' && attrName === 'profile' ||
+    tag === 'script' && (attrName === 'src' || attrName === 'for')
   );
 }
 
 function isNumberTypeAttribute(attrName, tag) {
   return (
-    ((/^(?:a|area|object|button)$/).test(tag) && attrName === 'tabindex') ||
-    (tag === 'input' && (attrName === 'maxlength' || attrName === 'tabindex')) ||
-    (tag === 'select' && (attrName === 'size' || attrName === 'tabindex')) ||
-    (tag === 'textarea' && (/^(?:rows|cols|tabindex)$/).test(attrName)) ||
-    (tag === 'colgroup' && attrName === 'span') ||
-    (tag === 'col' && attrName === 'span') ||
-    ((tag === 'th' || tag === 'td') && (attrName === 'rowspan' || attrName === 'colspan'))
+    /^(?:a|area|object|button)$/.test(tag) && attrName === 'tabindex' ||
+    tag === 'input' && (attrName === 'maxlength' || attrName === 'tabindex') ||
+    tag === 'select' && (attrName === 'size' || attrName === 'tabindex') ||
+    tag === 'textarea' && /^(?:rows|cols|tabindex)$/.test(attrName) ||
+    tag === 'colgroup' && attrName === 'span' ||
+    tag === 'col' && attrName === 'span' ||
+    (tag === 'th' || tag === 'td') && (attrName === 'rowspan' || attrName === 'colspan')
   );
 }
 
@@ -32217,11 +32214,9 @@ var reEmptyAttribute = new RegExp(
     '?:down|up|over|move|out)|key(?:press|down|up)))$');
 
 function canDeleteEmptyAttribute(tag, attrName, attrValue) {
-  var isValueEmpty = !attrValue || (/^\s*$/).test(attrValue);
+  var isValueEmpty = !attrValue || /^\s*$/.test(attrValue);
   if (isValueEmpty) {
-    return (
-      (tag === 'input' && attrName === 'value') ||
-      reEmptyAttribute.test(attrName));
+    return tag === 'input' && attrName === 'value' || reEmptyAttribute.test(attrName);
   }
   return false;
 }
@@ -32266,11 +32261,11 @@ function canRemoveElement(tag, attrs) {
 }
 
 function canCollapseWhitespace(tag) {
-  return !(/^(?:script|style|pre|textarea)$/.test(tag));
+  return !/^(?:script|style|pre|textarea)$/.test(tag);
 }
 
 function canTrimWhitespace(tag) {
-  return !(/^(?:pre|textarea)$/.test(tag));
+  return !/^(?:pre|textarea)$/.test(tag);
 }
 
 function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isLast) {
@@ -32281,14 +32276,14 @@ function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isL
       attrFragment,
       emittedAttrValue;
 
-  if ((options.removeRedundantAttributes &&
-    isAttributeRedundant(tag, attrName, attrValue, attrs))
+  if (options.removeRedundantAttributes &&
+    isAttributeRedundant(tag, attrName, attrValue, attrs)
     ||
-    (options.removeScriptTypeAttributes &&
-    isScriptTypeAttribute(tag, attrName, attrValue))
+    options.removeScriptTypeAttributes &&
+    isScriptTypeAttribute(tag, attrName, attrValue)
     ||
-    (options.removeStyleLinkTypeAttributes &&
-    isStyleLinkTypeAttribute(tag, attrName, attrValue))) {
+    options.removeStyleLinkTypeAttributes &&
+    isStyleLinkTypeAttribute(tag, attrName, attrValue)) {
     return '';
   }
 
@@ -32330,8 +32325,8 @@ function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isL
     emittedAttrValue = attrValue + ' ';
   }
 
-  if (attrValue === undefined || (options.collapseBooleanAttributes &&
-      isBooleanAttribute(attrName.toLowerCase(), attrValue.toLowerCase()))) {
+  if (attrValue === undefined || options.collapseBooleanAttributes &&
+      isBooleanAttribute(attrName.toLowerCase(), attrValue.toLowerCase())) {
     attrFragment = attrName;
     if (!isLast) {
       attrFragment += ' ';
index 9787d18..dd500ca 100644 (file)
@@ -9,58 +9,55 @@
 'use strict';
 
 function isPresentationalElement(tag) {
-  return (/^(?:big|small|hr|blink|marquee)$/).test(tag);
+  return /^(?:big|small|hr|blink|marquee)$/.test(tag);
 }
 function isDeprecatedElement(tag) {
-  return (/^(?:applet|basefont|center|dir|font|isindex|strike)$/).test(tag);
+  return /^(?:applet|basefont|center|dir|font|isindex|strike)$/.test(tag);
 }
 function isEventAttribute(attrName) {
-  return (/^on[a-z]+/).test(attrName);
+  return /^on[a-z]+/.test(attrName);
 }
 function isStyleAttribute(attrName) {
-  return (attrName.toLowerCase() === 'style');
+  return attrName.toLowerCase() === 'style';
 }
 function isDeprecatedAttribute(tag, attrName) {
   return (
-    (attrName === 'align' &&
-    (/^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/).test(tag)) ||
-    (attrName === 'alink' && tag === 'body') ||
-    (attrName === 'alt' && tag === 'applet') ||
-    (attrName === 'archive' && tag === 'applet') ||
-    (attrName === 'background' && tag === 'body') ||
-    (attrName === 'bgcolor' && (/^(?:table|t[rdh]|body)$/).test(tag)) ||
-    (attrName === 'border' && (/^(?:img|object)$/).test(tag)) ||
-    (attrName === 'clear' && tag === 'br') ||
-    (attrName === 'code' && tag === 'applet') ||
-    (attrName === 'codebase' && tag === 'applet') ||
-    (attrName === 'color' && (/^(?:base(?:font)?)$/).test(tag)) ||
-    (attrName === 'compact' && (/^(?:dir|[dou]l|menu)$/).test(tag)) ||
-    (attrName === 'face' && (/^base(?:font)?$/).test(tag)) ||
-    (attrName === 'height' && (/^(?:t[dh]|applet)$/).test(tag)) ||
-    (attrName === 'hspace' && (/^(?:applet|img|object)$/).test(tag)) ||
-    (attrName === 'language' && tag === 'script') ||
-    (attrName === 'link' && tag === 'body') ||
-    (attrName === 'name' && tag === 'applet') ||
-    (attrName === 'noshade' && tag === 'hr') ||
-    (attrName === 'nowrap' && (/^t[dh]$/).test(tag)) ||
-    (attrName === 'object' && tag === 'applet') ||
-    (attrName === 'prompt' && tag === 'isindex') ||
-    (attrName === 'size' && (/^(?:hr|font|basefont)$/).test(tag)) ||
-    (attrName === 'start' && tag === 'ol') ||
-    (attrName === 'text' && tag === 'body') ||
-    (attrName === 'type' && (/^(?:li|ol|ul)$/).test(tag)) ||
-    (attrName === 'value' && tag === 'li') ||
-    (attrName === 'version' && tag === 'html') ||
-    (attrName === 'vlink' && tag === 'body') ||
-    (attrName === 'vspace' && (/^(?:applet|img|object)$/).test(tag)) ||
-    (attrName === 'width' && (/^(?:hr|td|th|applet|pre)$/).test(tag))
+    attrName === 'align' &&
+    /^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/.test(tag) ||
+    attrName === 'alink' && tag === 'body' ||
+    attrName === 'alt' && tag === 'applet' ||
+    attrName === 'archive' && tag === 'applet' ||
+    attrName === 'background' && tag === 'body' ||
+    attrName === 'bgcolor' && /^(?:table|t[rdh]|body)$/.test(tag) ||
+    attrName === 'border' && /^(?:img|object)$/.test(tag) ||
+    attrName === 'clear' && tag === 'br' ||
+    attrName === 'code' && tag === 'applet' ||
+    attrName === 'codebase' && tag === 'applet' ||
+    attrName === 'color' && /^(?:base(?:font)?)$/.test(tag) ||
+    attrName === 'compact' && /^(?:dir|[dou]l|menu)$/.test(tag) ||
+    attrName === 'face' && /^base(?:font)?$/.test(tag) ||
+    attrName === 'height' && /^(?:t[dh]|applet)$/.test(tag) ||
+    attrName === 'hspace' && /^(?:applet|img|object)$/.test(tag) ||
+    attrName === 'language' && tag === 'script' ||
+    attrName === 'link' && tag === 'body' ||
+    attrName === 'name' && tag === 'applet' ||
+    attrName === 'noshade' && tag === 'hr' ||
+    attrName === 'nowrap' && /^t[dh]$/.test(tag) ||
+    attrName === 'object' && tag === 'applet' ||
+    attrName === 'prompt' && tag === 'isindex' ||
+    attrName === 'size' && /^(?:hr|font|basefont)$/.test(tag) ||
+    attrName === 'start' && tag === 'ol' ||
+    attrName === 'text' && tag === 'body' ||
+    attrName === 'type' && /^(?:li|ol|ul)$/.test(tag) ||
+    attrName === 'value' && tag === 'li' ||
+    attrName === 'version' && tag === 'html' ||
+    attrName === 'vlink' && tag === 'body' ||
+    attrName === 'vspace' && /^(?:applet|img|object)$/.test(tag) ||
+    attrName === 'width' && /^(?:hr|td|th|applet|pre)$/.test(tag)
   );
 }
 function isInaccessibleAttribute(attrName, attrValue) {
-  return (
-    attrName === 'href' &&
-    (/^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i).test(attrValue)
-  );
+  return attrName === 'href' && /^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i.test(attrValue);
 }
 
 function Lint() {
index cf71790..fcc2036 100644 (file)
@@ -120,13 +120,13 @@ function isEventAttribute(attrName, options) {
     return false;
   }
   else {
-    return (/^on[a-z]{3,}$/).test(attrName);
+    return /^on[a-z]{3,}$/.test(attrName);
   }
 }
 
 function canRemoveAttributeQuotes(value) {
   // http://mathiasbynens.be/notes/unquoted-attribute-values
-  return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value);
+  return /^[^\x20\t\n\f\r"'`=<>]+$/.test(value);
 }
 
 function attributesInclude(attributes, attribute) {
@@ -142,29 +142,29 @@ function isAttributeRedundant(tag, attrName, attrValue, attrs) {
   attrValue = attrValue ? trimWhitespace(attrValue.toLowerCase()) : '';
 
   return (
-      (tag === 'script' &&
+      tag === 'script' &&
       attrName === 'language' &&
-      attrValue === 'javascript') ||
+      attrValue === 'javascript' ||
 
-      (tag === 'form' &&
+      tag === 'form' &&
       attrName === 'method' &&
-      attrValue === 'get') ||
+      attrValue === 'get' ||
 
-      (tag === 'input' &&
+      tag === 'input' &&
       attrName === 'type' &&
-      attrValue === 'text') ||
+      attrValue === 'text' ||
 
-      (tag === 'script' &&
+      tag === 'script' &&
       attrName === 'charset' &&
-      !attributesInclude(attrs, 'src')) ||
+      !attributesInclude(attrs, 'src') ||
 
-      (tag === 'a' &&
+      tag === 'a' &&
       attrName === 'name' &&
-      attributesInclude(attrs, 'id')) ||
+      attributesInclude(attrs, 'id') ||
 
-      (tag === 'area' &&
+      tag === 'area' &&
       attrName === 'shape' &&
-      attrValue === 'rect')
+      attrValue === 'rect'
   );
 }
 
@@ -232,28 +232,28 @@ function isBooleanAttribute(attrName, attrValue) {
 
 function isUriTypeAttribute(attrName, tag) {
   return (
-    ((/^(?:a|area|link|base)$/).test(tag) && attrName === 'href') ||
-    (tag === 'img' && (/^(?:src|longdesc|usemap)$/).test(attrName)) ||
-    (tag === 'object' && (/^(?:classid|codebase|data|usemap)$/).test(attrName)) ||
-    (tag === 'q' && attrName === 'cite') ||
-    (tag === 'blockquote' && attrName === 'cite') ||
-    ((tag === 'ins' || tag === 'del') && attrName === 'cite') ||
-    (tag === 'form' && attrName === 'action') ||
-    (tag === 'input' && (attrName === 'src' || attrName === 'usemap')) ||
-    (tag === 'head' && attrName === 'profile') ||
-    (tag === 'script' && (attrName === 'src' || attrName === 'for'))
+    /^(?:a|area|link|base)$/.test(tag) && attrName === 'href' ||
+    tag === 'img' && /^(?:src|longdesc|usemap)$/.test(attrName) ||
+    tag === 'object' && /^(?:classid|codebase|data|usemap)$/.test(attrName) ||
+    tag === 'q' && attrName === 'cite' ||
+    tag === 'blockquote' && attrName === 'cite' ||
+    (tag === 'ins' || tag === 'del') && attrName === 'cite' ||
+    tag === 'form' && attrName === 'action' ||
+    tag === 'input' && (attrName === 'src' || attrName === 'usemap') ||
+    tag === 'head' && attrName === 'profile' ||
+    tag === 'script' && (attrName === 'src' || attrName === 'for')
   );
 }
 
 function isNumberTypeAttribute(attrName, tag) {
   return (
-    ((/^(?:a|area|object|button)$/).test(tag) && attrName === 'tabindex') ||
-    (tag === 'input' && (attrName === 'maxlength' || attrName === 'tabindex')) ||
-    (tag === 'select' && (attrName === 'size' || attrName === 'tabindex')) ||
-    (tag === 'textarea' && (/^(?:rows|cols|tabindex)$/).test(attrName)) ||
-    (tag === 'colgroup' && attrName === 'span') ||
-    (tag === 'col' && attrName === 'span') ||
-    ((tag === 'th' || tag === 'td') && (attrName === 'rowspan' || attrName === 'colspan'))
+    /^(?:a|area|object|button)$/.test(tag) && attrName === 'tabindex' ||
+    tag === 'input' && (attrName === 'maxlength' || attrName === 'tabindex') ||
+    tag === 'select' && (attrName === 'size' || attrName === 'tabindex') ||
+    tag === 'textarea' && /^(?:rows|cols|tabindex)$/.test(attrName) ||
+    tag === 'colgroup' && attrName === 'span' ||
+    tag === 'col' && attrName === 'span' ||
+    (tag === 'th' || tag === 'td') && (attrName === 'rowspan' || attrName === 'colspan')
   );
 }
 
@@ -453,11 +453,9 @@ var reEmptyAttribute = new RegExp(
     '?:down|up|over|move|out)|key(?:press|down|up)))$');
 
 function canDeleteEmptyAttribute(tag, attrName, attrValue) {
-  var isValueEmpty = !attrValue || (/^\s*$/).test(attrValue);
+  var isValueEmpty = !attrValue || /^\s*$/.test(attrValue);
   if (isValueEmpty) {
-    return (
-      (tag === 'input' && attrName === 'value') ||
-      reEmptyAttribute.test(attrName));
+    return tag === 'input' && attrName === 'value' || reEmptyAttribute.test(attrName);
   }
   return false;
 }
@@ -502,11 +500,11 @@ function canRemoveElement(tag, attrs) {
 }
 
 function canCollapseWhitespace(tag) {
-  return !(/^(?:script|style|pre|textarea)$/.test(tag));
+  return !/^(?:script|style|pre|textarea)$/.test(tag);
 }
 
 function canTrimWhitespace(tag) {
-  return !(/^(?:pre|textarea)$/.test(tag));
+  return !/^(?:pre|textarea)$/.test(tag);
 }
 
 function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isLast) {
@@ -517,14 +515,14 @@ function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isL
       attrFragment,
       emittedAttrValue;
 
-  if ((options.removeRedundantAttributes &&
-    isAttributeRedundant(tag, attrName, attrValue, attrs))
+  if (options.removeRedundantAttributes &&
+    isAttributeRedundant(tag, attrName, attrValue, attrs)
     ||
-    (options.removeScriptTypeAttributes &&
-    isScriptTypeAttribute(tag, attrName, attrValue))
+    options.removeScriptTypeAttributes &&
+    isScriptTypeAttribute(tag, attrName, attrValue)
     ||
-    (options.removeStyleLinkTypeAttributes &&
-    isStyleLinkTypeAttribute(tag, attrName, attrValue))) {
+    options.removeStyleLinkTypeAttributes &&
+    isStyleLinkTypeAttribute(tag, attrName, attrValue)) {
     return '';
   }
 
@@ -566,8 +564,8 @@ function normalizeAttribute(attr, attrs, tag, hasUnarySlash, index, options, isL
     emittedAttrValue = attrValue + ' ';
   }
 
-  if (attrValue === undefined || (options.collapseBooleanAttributes &&
-      isBooleanAttribute(attrName.toLowerCase(), attrValue.toLowerCase()))) {
+  if (attrValue === undefined || options.collapseBooleanAttributes &&
+      isBooleanAttribute(attrName.toLowerCase(), attrValue.toLowerCase())) {
     attrFragment = attrName;
     if (!isLast) {
       attrFragment += ' ';
index baa1379..2be8d08 100644 (file)
@@ -1429,7 +1429,7 @@ test('Ignore custom fragments', function() {
   input = '<img src="{% static "images/logo.png" %}">';
   output = '<img src="{% static "images/logo.png" %}">';
 
-  equal(minify(input, { ignoreCustomFragments: [ (/\{\%[^\%]*?\%\}/g) ] }), output);
+  equal(minify(input, { ignoreCustomFragments: [ /\{\%[^\%]*?\%\}/g ] }), output);
 
   input = '<p{% if form.name.errors %}class=\'error\'{% endif %}>' +
             '{{ form.name.label_tag }}' +