Better support for boolean attributes. Closes #63. Version 0.5.3
authorkangax <kangax@gmail.com>
Wed, 19 Jun 2013 11:09:48 +0000 (13:09 +0200)
committerkangax <kangax@gmail.com>
Wed, 19 Jun 2013 11:09:48 +0000 (13:09 +0200)
dist/all.js
package.json
src/htmlminifier.js
tests/minifier.js

index 2b4b676..619bf12 100644 (file)
   }
 })(typeof exports === 'undefined' ? this : exports);
 /*!
- * HTMLMinifier v0.5.2
+ * HTMLMinifier v0.5.3
  * http://kangax.github.com/html-minifier/
  *
  * Copyright (c) 2010-2013 Juriy "kangax" Zaytsev
   }
 
   function isBooleanAttribute(attrName) {
-    return (/^(?:checked|disabled|selected|readonly)$/).test(attrName);
+    return (/^(?:allowfullscreen|async|autofocus|checked|compact|declare|default|defer|disabled|formnovalidate|hidden|inert|ismap|itemscope|multiple|muted|nohref|noresize|noshade|novalidate|nowrap|open|readonly|required|reversed|seamless|selected|sortable|truespeed|typemustmatch)$/).test(attrName);
   }
 
   function isUriTypeAttribute(attrName, tag) {
index 1358125..af3081d 100644 (file)
@@ -1,7 +1,7 @@
 {
   "name": "html-minifier",
   "description": "HTML minifier with lint-like capabilities.",
-  "version": "0.5.2",
+  "version": "0.5.3",
   "keywords": ["html", "minifier", "lint"],
   "url" : "http://github.com/kangax/html-minifier",
   "maintainers": [{
index ce064ca..e7e6405 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * HTMLMinifier v0.5.2
+ * HTMLMinifier v0.5.3
  * http://kangax.github.com/html-minifier/
  *
  * Copyright (c) 2010-2013 Juriy "kangax" Zaytsev
   }
 
   function isBooleanAttribute(attrName) {
-    return (/^(?:checked|disabled|selected|readonly)$/).test(attrName);
+    return (/^(?:allowfullscreen|async|autofocus|checked|compact|declare|default|defer|disabled|formnovalidate|hidden|inert|ismap|itemscope|multiple|muted|nohref|noresize|noshade|novalidate|nowrap|open|readonly|required|reversed|seamless|selected|sortable|truespeed|typemustmatch)$/).test(attrName);
   }
 
   function isUriTypeAttribute(attrName, tag) {
index b49b62d..9b3da95 100644 (file)
@@ -86,7 +86,7 @@
       equal(minify('<p>foo<'+el+'> baz </'+el+'>bar</p>', {collapseWhitespace: true}), '<p>foo<'+el+'>baz</'+el+'>bar</p>');
       equal(minify('<p>foo <'+el+'> baz </'+el+'>bar</p>', {collapseWhitespace: true}), '<p>foo <'+el+'>baz</'+el+'>bar</p>');
       equal(minify('<p>foo<'+el+'> baz </'+el+'> bar</p>', {collapseWhitespace: true}), '<p>foo<'+el+'>baz</'+el+'> bar</p>');
-    })   
+    })
     equal(minify('<p>foo <img> bar</p>', {collapseWhitespace: true}), '<p>foo <img> bar</p>');
     equal(minify('<p>foo<img>bar</p>', {collapseWhitespace: true}), '<p>foo<img>bar</p>');
     equal(minify('<p>foo <img>bar</p>', {collapseWhitespace: true}), '<p>foo <img>bar</p>');
 
     input = '<option name="blah" selected="selected">moo</option>';
     equal(minify(input, { collapseBooleanAttributes: true }), '<option name="blah" selected>moo</option>');
+
+    input = '<input autofocus="autofocus">';
+    equal(minify(input, { collapseBooleanAttributes: true }), '<input autofocus>');
+
+    input = '<input required="required">';
+    equal(minify(input, { collapseBooleanAttributes: true }), '<input required>');
+
+    input = '<input multiple="multiple">';
+    equal(minify(input, { collapseBooleanAttributes: true }), '<input multiple>');
   });
 
   test('removing optional tags', function(){