enforce eslint space-in-parens
authoralexlamsl <alexlamsl@gmail.com>
Thu, 31 Mar 2016 11:01:57 +0000 (19:01 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Thu, 31 Mar 2016 17:24:39 +0000 (01:24 +0800)
.eslintrc.json
assets/master.js
dist/htmlminifier.js
src/htmlminifier.js
src/htmlparser.js
tests/minifier.js

index 7d9e691..9445cb5 100644 (file)
@@ -80,6 +80,7 @@
     "semi-spacing": "error",
     "space-before-blocks": "error",
     "space-unary-ops": "error",
+    "space-in-parens": "error",
     "spaced-comment": [
       "error",
       "always",
index 6114b7f..50afd4e 100644 (file)
@@ -78,7 +78,7 @@
 
   function setCheckedAttrOnCheckboxes(attrValue) {
     var checkboxes = byId('options').getElementsByTagName('input');
-    for (var i = checkboxes.length; i--; ) {
+    for (var i = checkboxes.length; i--;) {
       checkboxes[i].checked = attrValue;
     }
   }
index 827e751..0029afa 100644 (file)
@@ -31323,7 +31323,7 @@ function attrForHandler(handler) {
     + '\\s*(?:' + singleAttrValues.join('|') + '))?';
   if (handler.customAttrSurround) {
     var attrClauses = [];
-    for ( var i = handler.customAttrSurround.length - 1; i >= 0; i-- ) {
+    for (var i = handler.customAttrSurround.length - 1; i >= 0; i--) {
       attrClauses[i] = '(?:'
         + '(' + handler.customAttrSurround[i][0].source + ')\\s*'
         + pattern
@@ -31336,7 +31336,7 @@ function attrForHandler(handler) {
   return new RegExp('^\\s*' + pattern);
 }
 
-function joinSingleAttrAssigns( handler ) {
+function joinSingleAttrAssigns(handler) {
   return singleAttrAssigns.concat(
     handler.customAttrAssign || []
   ).map(function (assign) {
@@ -31344,67 +31344,67 @@ function joinSingleAttrAssigns( handler ) {
   }).join('|');
 }
 
-function HTMLParser( html, handler ) {
+function HTMLParser(html, handler) {
   var stack = [], lastTag;
   var attribute = attrForHandler(handler);
   var last, prevTag, nextTag;
-  while ( html ) {
+  while (html) {
     last = html;
     // Make sure we're not in a script or style element
-    if ( !lastTag || !special(lastTag) ) {
+    if (!lastTag || !special(lastTag)) {
       var textEnd = html.indexOf('<');
       if (textEnd === 0) {
         // Comment:
-        if ( /^<!--/.test( html ) ) {
+        if (/^<!--/.test(html)) {
           var commentEnd = html.indexOf('-->');
 
-          if ( commentEnd >= 0 ) {
-            if ( handler.comment ) {
-              handler.comment( html.substring( 4, commentEnd ) );
+          if (commentEnd >= 0) {
+            if (handler.comment) {
+              handler.comment(html.substring(4, commentEnd));
             }
-            html = html.substring( commentEnd + 3 );
+            html = html.substring(commentEnd + 3);
             prevTag = '';
             continue;
           }
         }
 
         // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
-        if ( /^<!\[/.test( html ) ) {
+        if (/^<!\[/.test(html)) {
           var conditionalEnd = html.indexOf(']>');
 
           if (conditionalEnd >= 0) {
-            if ( handler.comment ) {
-              handler.comment( html.substring(2, conditionalEnd + 1 ), true /* non-standard */ );
+            if (handler.comment) {
+              handler.comment(html.substring(2, conditionalEnd + 1), true /* non-standard */);
             }
-            html = html.substring( conditionalEnd + 2 );
+            html = html.substring(conditionalEnd + 2);
             prevTag = '';
             continue;
           }
         }
 
         // Doctype:
-        var doctypeMatch = html.match( doctype );
-        if ( doctypeMatch ) {
-          if ( handler.doctype ) {
-            handler.doctype( doctypeMatch[0] );
+        var doctypeMatch = html.match(doctype);
+        if (doctypeMatch) {
+          if (handler.doctype) {
+            handler.doctype(doctypeMatch[0]);
           }
-          html = html.substring( doctypeMatch[0].length );
+          html = html.substring(doctypeMatch[0].length);
           prevTag = '';
           continue;
         }
 
         // End tag:
-        var endTagMatch = html.match( endTag );
-        if ( endTagMatch ) {
-          html = html.substring( endTagMatch[0].length );
-          endTagMatch[0].replace( endTag, parseEndTag );
+        var endTagMatch = html.match(endTag);
+        if (endTagMatch) {
+          html = html.substring(endTagMatch[0].length);
+          endTagMatch[0].replace(endTag, parseEndTag);
           prevTag = '/' + endTagMatch[1].toLowerCase();
           continue;
         }
 
         // Start tag:
         var startTagMatch = parseStartTag(html);
-        if ( startTagMatch ) {
+        if (startTagMatch) {
           html = startTagMatch.rest;
           handleStartTag(startTagMatch);
           prevTag = startTagMatch.tagName.toLowerCase();
@@ -31414,8 +31414,8 @@ function HTMLParser( html, handler ) {
 
       var text;
       if (textEnd >= 0) {
-        text = html.substring( 0, textEnd );
-        html = html.substring( textEnd );
+        text = html.substring(0, textEnd);
+        html = html.substring(textEnd);
       }
       else {
         text = html;
@@ -31428,7 +31428,7 @@ function HTMLParser( html, handler ) {
         nextTag = nextTagMatch.tagName;
       }
       else {
-        nextTagMatch = html.match( endTag );
+        nextTagMatch = html.match(endTag);
         if (nextTagMatch) {
           nextTag = '/' + nextTagMatch[1];
         }
@@ -31437,7 +31437,7 @@ function HTMLParser( html, handler ) {
         }
       }
 
-      if ( handler.chars ) {
+      if (handler.chars) {
         handler.chars(text, prevTag, nextTag);
       }
       prevTag = '';
@@ -31454,17 +31454,17 @@ function HTMLParser( html, handler ) {
             .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
         }
 
-        if ( handler.chars ) {
-          handler.chars( text );
+        if (handler.chars) {
+          handler.chars(text);
         }
 
         return '';
       });
 
-      parseEndTag( '</' + stackedTag + '>', stackedTag );
+      parseEndTag('</' + stackedTag + '>', stackedTag);
     }
 
-    if ( html === last ) {
+    if (html === last) {
       throw new Error('Parse Error: ' + html);
     }
   }
@@ -31500,17 +31500,17 @@ function HTMLParser( html, handler ) {
     var unarySlash = match.unarySlash;
 
     if (handler.html5 && lastTag === 'p' && nonPhrasing(tagName)) {
-      parseEndTag( '', lastTag );
+      parseEndTag('', lastTag);
     }
 
     if (!handler.html5) {
       while (lastTag && inline(lastTag)) {
-        parseEndTag( '', lastTag );
+        parseEndTag('', lastTag);
       }
     }
 
-    if ( closeSelf(tagName) && lastTag === tagName ) {
-      parseEndTag( '', tagName );
+    if (closeSelf(tagName) && lastTag === tagName) {
+      parseEndTag('', tagName);
     }
 
     var unary = empty(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
@@ -31563,39 +31563,39 @@ function HTMLParser( html, handler ) {
       };
     });
 
-    if ( !unary ) {
-      stack.push( { tag: tagName, attrs: attrs } );
+    if (!unary) {
+      stack.push({ tag: tagName, attrs: attrs });
       lastTag = tagName;
       unarySlash = '';
     }
 
-    if ( handler.start ) {
-      handler.start( tagName, attrs, unary, unarySlash );
+    if (handler.start) {
+      handler.start(tagName, attrs, unary, unarySlash);
     }
   }
 
-  function parseEndTag( tag, tagName ) {
+  function parseEndTag(tag, tagName) {
     var pos;
 
     // If no tag name is provided, clean shop
-    if ( !tagName ) {
+    if (!tagName) {
       pos = 0;
     }
     else {
       // Find the closest opened tag of the same type
       var needle = tagName.toLowerCase();
-      for ( pos = stack.length - 1; pos >= 0; pos-- ) {
-        if ( stack[ pos ].tag.toLowerCase() === needle ) {
+      for (pos = stack.length - 1; pos >= 0; pos--) {
+        if (stack[pos].tag.toLowerCase() === needle) {
           break;
         }
       }
     }
 
-    if ( pos >= 0 ) {
+    if (pos >= 0) {
       // Close all the open elements, up the stack
-      for ( var i = stack.length - 1; i >= pos; i-- ) {
-        if ( handler.end ) {
-          handler.end( stack[ i ].tag, stack[ i ].attrs, i > pos || !tag );
+      for (var i = stack.length - 1; i >= pos; i--) {
+        if (handler.end) {
+          handler.end(stack[ i ].tag, stack[ i ].attrs, i > pos || !tag);
         }
       }
 
@@ -31620,26 +31620,26 @@ function HTMLParser( html, handler ) {
 }
 
 exports.HTMLParser = HTMLParser;
-exports.HTMLtoXML = function( html ) {
+exports.HTMLtoXML = function(html) {
   var results = '';
 
   new HTMLParser(html, {
-    start: function( tag, attrs, unary ) {
+    start: function(tag, attrs, unary) {
       results += '<' + tag;
 
-      for ( var i = 0; i < attrs.length; i++ ) {
+      for (var i = 0; i < attrs.length; i++) {
         results += ' ' + attrs[i].name + '="' + (attrs[i].value || '').replace(/"/g, '&#34;') + '"';
       }
 
       results += (unary ? '/' : '') + '>';
     },
-    end: function( tag ) {
+    end: function(tag) {
       results += '</' + tag + '>';
     },
-    chars: function( text ) {
+    chars: function(text) {
       results += text;
     },
-    comment: function( text ) {
+    comment: function(text) {
       results += '<!--' + text + '-->';
     },
     ignore: function(text) {
@@ -31650,7 +31650,7 @@ exports.HTMLtoXML = function( html ) {
   return results;
 };
 
-exports.HTMLtoDOM = function( html, doc ) {
+exports.HTMLtoDOM = function(html, doc) {
   // There can be only one of these elements
   var one = {
     html: true,
@@ -31665,14 +31665,14 @@ exports.HTMLtoDOM = function( html, doc ) {
     base: 'head'
   };
 
-  if ( !doc ) {
-    if ( typeof DOMDocument !== 'undefined' ) {
+  if (!doc) {
+    if (typeof DOMDocument !== 'undefined') {
       doc = new DOMDocument();
     }
-    else if ( typeof document !== 'undefined' && document.implementation && document.implementation.createDocument ) {
+    else if (typeof document !== 'undefined' && document.implementation && document.implementation.createDocument) {
       doc = document.implementation.createDocument('', '', null);
     }
-    else if ( typeof ActiveX !== 'undefined' ) {
+    else if (typeof ActiveX !== 'undefined') {
       doc = new ActiveXObject('Msxml.DOMDocument');
     }
 
@@ -31689,21 +31689,21 @@ exports.HTMLtoDOM = function( html, doc ) {
 
   // If we're dealing with an empty document then we
   // need to pre-populate it with the HTML document structure
-  if ( !documentElement && doc.createElement ) {
+  if (!documentElement && doc.createElement) {
     (function() {
       var html = doc.createElement('html');
       var head = doc.createElement('head');
-      head.appendChild( doc.createElement('title') );
-      html.appendChild( head );
-      html.appendChild( doc.createElement('body') );
-      doc.appendChild( html );
+      head.appendChild(doc.createElement('title'));
+      html.appendChild(head);
+      html.appendChild(doc.createElement('body'));
+      doc.appendChild(html);
     })();
   }
 
   // Find all the unique elements
-  if ( doc.getElementsByTagName ) {
-    for ( var i in one ) {
-      one[ i ] = doc.getElementsByTagName( i )[0];
+  if (doc.getElementsByTagName) {
+    for (var i in one) {
+      one[i] = doc.getElementsByTagName(i)[0];
     }
   }
 
@@ -31711,46 +31711,46 @@ exports.HTMLtoDOM = function( html, doc ) {
   // the body element
   var curParentNode = one.body;
 
-  new HTMLParser( html, {
-    start: function( tagName, attrs, unary ) {
+  new HTMLParser(html, {
+    start: function(tagName, attrs, unary) {
       // If it's a pre-built element, then we can ignore
       // its construction
-      if ( one[ tagName ] ) {
-        curParentNode = one[ tagName ];
+      if (one[tagName]) {
+        curParentNode = one[tagName];
         return;
       }
 
-      var elem = doc.createElement( tagName );
+      var elem = doc.createElement(tagName);
 
-      for ( var attr in attrs ) {
-        elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
+      for (var attr in attrs) {
+        elem.setAttribute(attrs[attr].name, attrs[attr].value);
       }
 
-      if ( structure[ tagName ] && typeof one[ structure[ tagName ] ] !== 'boolean' ) {
-        one[ structure[ tagName ] ].appendChild( elem );
+      if (structure[tagName] && typeof one[structure[tagName]] !== 'boolean') {
+        one[structure[tagName]].appendChild(elem);
       }
-      else if ( curParentNode && curParentNode.appendChild ) {
-        curParentNode.appendChild( elem );
+      else if (curParentNode && curParentNode.appendChild) {
+        curParentNode.appendChild(elem);
       }
 
-      if ( !unary ) {
-        elems.push( elem );
+      if (!unary) {
+        elems.push(elem);
         curParentNode = elem;
       }
     },
-    end: function( /* tag */ ) {
+    end: function(/* tag */) {
       elems.length -= 1;
 
       // Init the new parentNode
       curParentNode = elems[ elems.length - 1 ];
     },
-    chars: function( text ) {
-      curParentNode.appendChild( doc.createTextNode( text ) );
+    chars: function(text) {
+      curParentNode.appendChild(doc.createTextNode(text));
     },
-    comment: function( /* text */ ) {
+    comment: function(/* text */) {
       // create comment node
     },
-    ignore: function( /* text */ ) {
+    ignore: function(/* text */) {
       // What to do here?
     }
   });
@@ -32595,7 +32595,7 @@ function minify(value, options, partialMarkup) {
 
       var parts = [ ];
       var token, isLast = true;
-      for (var i = attrs.length; --i >= 0; ) {
+      for (var i = attrs.length; --i >= 0;) {
         if (lint) {
           lint.testAttribute(tag, attrs[i].name.toLowerCase(), attrs[i].value);
         }
index fcc2036..43dbaed 100644 (file)
@@ -834,7 +834,7 @@ function minify(value, options, partialMarkup) {
 
       var parts = [ ];
       var token, isLast = true;
-      for (var i = attrs.length; --i >= 0; ) {
+      for (var i = attrs.length; --i >= 0;) {
         if (lint) {
           lint.testAttribute(tag, attrs[i].name.toLowerCase(), attrs[i].value);
         }
index f02e790..defb205 100644 (file)
@@ -91,7 +91,7 @@ function attrForHandler(handler) {
     + '\\s*(?:' + singleAttrValues.join('|') + '))?';
   if (handler.customAttrSurround) {
     var attrClauses = [];
-    for ( var i = handler.customAttrSurround.length - 1; i >= 0; i-- ) {
+    for (var i = handler.customAttrSurround.length - 1; i >= 0; i--) {
       attrClauses[i] = '(?:'
         + '(' + handler.customAttrSurround[i][0].source + ')\\s*'
         + pattern
@@ -104,7 +104,7 @@ function attrForHandler(handler) {
   return new RegExp('^\\s*' + pattern);
 }
 
-function joinSingleAttrAssigns( handler ) {
+function joinSingleAttrAssigns(handler) {
   return singleAttrAssigns.concat(
     handler.customAttrAssign || []
   ).map(function (assign) {
@@ -112,67 +112,67 @@ function joinSingleAttrAssigns( handler ) {
   }).join('|');
 }
 
-function HTMLParser( html, handler ) {
+function HTMLParser(html, handler) {
   var stack = [], lastTag;
   var attribute = attrForHandler(handler);
   var last, prevTag, nextTag;
-  while ( html ) {
+  while (html) {
     last = html;
     // Make sure we're not in a script or style element
-    if ( !lastTag || !special(lastTag) ) {
+    if (!lastTag || !special(lastTag)) {
       var textEnd = html.indexOf('<');
       if (textEnd === 0) {
         // Comment:
-        if ( /^<!--/.test( html ) ) {
+        if (/^<!--/.test(html)) {
           var commentEnd = html.indexOf('-->');
 
-          if ( commentEnd >= 0 ) {
-            if ( handler.comment ) {
-              handler.comment( html.substring( 4, commentEnd ) );
+          if (commentEnd >= 0) {
+            if (handler.comment) {
+              handler.comment(html.substring(4, commentEnd));
             }
-            html = html.substring( commentEnd + 3 );
+            html = html.substring(commentEnd + 3);
             prevTag = '';
             continue;
           }
         }
 
         // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
-        if ( /^<!\[/.test( html ) ) {
+        if (/^<!\[/.test(html)) {
           var conditionalEnd = html.indexOf(']>');
 
           if (conditionalEnd >= 0) {
-            if ( handler.comment ) {
-              handler.comment( html.substring(2, conditionalEnd + 1 ), true /* non-standard */ );
+            if (handler.comment) {
+              handler.comment(html.substring(2, conditionalEnd + 1), true /* non-standard */);
             }
-            html = html.substring( conditionalEnd + 2 );
+            html = html.substring(conditionalEnd + 2);
             prevTag = '';
             continue;
           }
         }
 
         // Doctype:
-        var doctypeMatch = html.match( doctype );
-        if ( doctypeMatch ) {
-          if ( handler.doctype ) {
-            handler.doctype( doctypeMatch[0] );
+        var doctypeMatch = html.match(doctype);
+        if (doctypeMatch) {
+          if (handler.doctype) {
+            handler.doctype(doctypeMatch[0]);
           }
-          html = html.substring( doctypeMatch[0].length );
+          html = html.substring(doctypeMatch[0].length);
           prevTag = '';
           continue;
         }
 
         // End tag:
-        var endTagMatch = html.match( endTag );
-        if ( endTagMatch ) {
-          html = html.substring( endTagMatch[0].length );
-          endTagMatch[0].replace( endTag, parseEndTag );
+        var endTagMatch = html.match(endTag);
+        if (endTagMatch) {
+          html = html.substring(endTagMatch[0].length);
+          endTagMatch[0].replace(endTag, parseEndTag);
           prevTag = '/' + endTagMatch[1].toLowerCase();
           continue;
         }
 
         // Start tag:
         var startTagMatch = parseStartTag(html);
-        if ( startTagMatch ) {
+        if (startTagMatch) {
           html = startTagMatch.rest;
           handleStartTag(startTagMatch);
           prevTag = startTagMatch.tagName.toLowerCase();
@@ -182,8 +182,8 @@ function HTMLParser( html, handler ) {
 
       var text;
       if (textEnd >= 0) {
-        text = html.substring( 0, textEnd );
-        html = html.substring( textEnd );
+        text = html.substring(0, textEnd);
+        html = html.substring(textEnd);
       }
       else {
         text = html;
@@ -196,7 +196,7 @@ function HTMLParser( html, handler ) {
         nextTag = nextTagMatch.tagName;
       }
       else {
-        nextTagMatch = html.match( endTag );
+        nextTagMatch = html.match(endTag);
         if (nextTagMatch) {
           nextTag = '/' + nextTagMatch[1];
         }
@@ -205,7 +205,7 @@ function HTMLParser( html, handler ) {
         }
       }
 
-      if ( handler.chars ) {
+      if (handler.chars) {
         handler.chars(text, prevTag, nextTag);
       }
       prevTag = '';
@@ -222,17 +222,17 @@ function HTMLParser( html, handler ) {
             .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
         }
 
-        if ( handler.chars ) {
-          handler.chars( text );
+        if (handler.chars) {
+          handler.chars(text);
         }
 
         return '';
       });
 
-      parseEndTag( '</' + stackedTag + '>', stackedTag );
+      parseEndTag('</' + stackedTag + '>', stackedTag);
     }
 
-    if ( html === last ) {
+    if (html === last) {
       throw new Error('Parse Error: ' + html);
     }
   }
@@ -268,17 +268,17 @@ function HTMLParser( html, handler ) {
     var unarySlash = match.unarySlash;
 
     if (handler.html5 && lastTag === 'p' && nonPhrasing(tagName)) {
-      parseEndTag( '', lastTag );
+      parseEndTag('', lastTag);
     }
 
     if (!handler.html5) {
       while (lastTag && inline(lastTag)) {
-        parseEndTag( '', lastTag );
+        parseEndTag('', lastTag);
       }
     }
 
-    if ( closeSelf(tagName) && lastTag === tagName ) {
-      parseEndTag( '', tagName );
+    if (closeSelf(tagName) && lastTag === tagName) {
+      parseEndTag('', tagName);
     }
 
     var unary = empty(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
@@ -331,39 +331,39 @@ function HTMLParser( html, handler ) {
       };
     });
 
-    if ( !unary ) {
-      stack.push( { tag: tagName, attrs: attrs } );
+    if (!unary) {
+      stack.push({ tag: tagName, attrs: attrs });
       lastTag = tagName;
       unarySlash = '';
     }
 
-    if ( handler.start ) {
-      handler.start( tagName, attrs, unary, unarySlash );
+    if (handler.start) {
+      handler.start(tagName, attrs, unary, unarySlash);
     }
   }
 
-  function parseEndTag( tag, tagName ) {
+  function parseEndTag(tag, tagName) {
     var pos;
 
     // If no tag name is provided, clean shop
-    if ( !tagName ) {
+    if (!tagName) {
       pos = 0;
     }
     else {
       // Find the closest opened tag of the same type
       var needle = tagName.toLowerCase();
-      for ( pos = stack.length - 1; pos >= 0; pos-- ) {
-        if ( stack[ pos ].tag.toLowerCase() === needle ) {
+      for (pos = stack.length - 1; pos >= 0; pos--) {
+        if (stack[pos].tag.toLowerCase() === needle) {
           break;
         }
       }
     }
 
-    if ( pos >= 0 ) {
+    if (pos >= 0) {
       // Close all the open elements, up the stack
-      for ( var i = stack.length - 1; i >= pos; i-- ) {
-        if ( handler.end ) {
-          handler.end( stack[ i ].tag, stack[ i ].attrs, i > pos || !tag );
+      for (var i = stack.length - 1; i >= pos; i--) {
+        if (handler.end) {
+          handler.end(stack[ i ].tag, stack[ i ].attrs, i > pos || !tag);
         }
       }
 
@@ -388,26 +388,26 @@ function HTMLParser( html, handler ) {
 }
 
 exports.HTMLParser = HTMLParser;
-exports.HTMLtoXML = function( html ) {
+exports.HTMLtoXML = function(html) {
   var results = '';
 
   new HTMLParser(html, {
-    start: function( tag, attrs, unary ) {
+    start: function(tag, attrs, unary) {
       results += '<' + tag;
 
-      for ( var i = 0; i < attrs.length; i++ ) {
+      for (var i = 0; i < attrs.length; i++) {
         results += ' ' + attrs[i].name + '="' + (attrs[i].value || '').replace(/"/g, '&#34;') + '"';
       }
 
       results += (unary ? '/' : '') + '>';
     },
-    end: function( tag ) {
+    end: function(tag) {
       results += '</' + tag + '>';
     },
-    chars: function( text ) {
+    chars: function(text) {
       results += text;
     },
-    comment: function( text ) {
+    comment: function(text) {
       results += '<!--' + text + '-->';
     },
     ignore: function(text) {
@@ -418,7 +418,7 @@ exports.HTMLtoXML = function( html ) {
   return results;
 };
 
-exports.HTMLtoDOM = function( html, doc ) {
+exports.HTMLtoDOM = function(html, doc) {
   // There can be only one of these elements
   var one = {
     html: true,
@@ -433,14 +433,14 @@ exports.HTMLtoDOM = function( html, doc ) {
     base: 'head'
   };
 
-  if ( !doc ) {
-    if ( typeof DOMDocument !== 'undefined' ) {
+  if (!doc) {
+    if (typeof DOMDocument !== 'undefined') {
       doc = new DOMDocument();
     }
-    else if ( typeof document !== 'undefined' && document.implementation && document.implementation.createDocument ) {
+    else if (typeof document !== 'undefined' && document.implementation && document.implementation.createDocument) {
       doc = document.implementation.createDocument('', '', null);
     }
-    else if ( typeof ActiveX !== 'undefined' ) {
+    else if (typeof ActiveX !== 'undefined') {
       doc = new ActiveXObject('Msxml.DOMDocument');
     }
 
@@ -457,21 +457,21 @@ exports.HTMLtoDOM = function( html, doc ) {
 
   // If we're dealing with an empty document then we
   // need to pre-populate it with the HTML document structure
-  if ( !documentElement && doc.createElement ) {
+  if (!documentElement && doc.createElement) {
     (function() {
       var html = doc.createElement('html');
       var head = doc.createElement('head');
-      head.appendChild( doc.createElement('title') );
-      html.appendChild( head );
-      html.appendChild( doc.createElement('body') );
-      doc.appendChild( html );
+      head.appendChild(doc.createElement('title'));
+      html.appendChild(head);
+      html.appendChild(doc.createElement('body'));
+      doc.appendChild(html);
     })();
   }
 
   // Find all the unique elements
-  if ( doc.getElementsByTagName ) {
-    for ( var i in one ) {
-      one[ i ] = doc.getElementsByTagName( i )[0];
+  if (doc.getElementsByTagName) {
+    for (var i in one) {
+      one[i] = doc.getElementsByTagName(i)[0];
     }
   }
 
@@ -479,46 +479,46 @@ exports.HTMLtoDOM = function( html, doc ) {
   // the body element
   var curParentNode = one.body;
 
-  new HTMLParser( html, {
-    start: function( tagName, attrs, unary ) {
+  new HTMLParser(html, {
+    start: function(tagName, attrs, unary) {
       // If it's a pre-built element, then we can ignore
       // its construction
-      if ( one[ tagName ] ) {
-        curParentNode = one[ tagName ];
+      if (one[tagName]) {
+        curParentNode = one[tagName];
         return;
       }
 
-      var elem = doc.createElement( tagName );
+      var elem = doc.createElement(tagName);
 
-      for ( var attr in attrs ) {
-        elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
+      for (var attr in attrs) {
+        elem.setAttribute(attrs[attr].name, attrs[attr].value);
       }
 
-      if ( structure[ tagName ] && typeof one[ structure[ tagName ] ] !== 'boolean' ) {
-        one[ structure[ tagName ] ].appendChild( elem );
+      if (structure[tagName] && typeof one[structure[tagName]] !== 'boolean') {
+        one[structure[tagName]].appendChild(elem);
       }
-      else if ( curParentNode && curParentNode.appendChild ) {
-        curParentNode.appendChild( elem );
+      else if (curParentNode && curParentNode.appendChild) {
+        curParentNode.appendChild(elem);
       }
 
-      if ( !unary ) {
-        elems.push( elem );
+      if (!unary) {
+        elems.push(elem);
         curParentNode = elem;
       }
     },
-    end: function( /* tag */ ) {
+    end: function(/* tag */) {
       elems.length -= 1;
 
       // Init the new parentNode
       curParentNode = elems[ elems.length - 1 ];
     },
-    chars: function( text ) {
-      curParentNode.appendChild( doc.createTextNode( text ) );
+    chars: function(text) {
+      curParentNode.appendChild(doc.createTextNode(text));
     },
-    comment: function( /* text */ ) {
+    comment: function(/* text */) {
       // create comment node
     },
-    ignore: function( /* text */ ) {
+    ignore: function(/* text */) {
       // What to do here?
     }
   });
index 2be8d08..882b2cf 100644 (file)
@@ -2104,7 +2104,7 @@ test('custom attribute collapse with empty attribute value', function() {
   input = '<div ng-some\n\n></div>';
   output = '<div ng-some></div>';
 
-  equal(minify( input, { customAttrCollapse: /.+/ }), output);
+  equal(minify(input, { customAttrCollapse: /.+/ }), output);
 });
 
 test('custom attribute collapse with newlines, whitespace, and carriage returns', function() {