From: Duncan Beevers Date: Thu, 10 Jul 2014 21:02:10 +0000 (-0500) Subject: Don’t choke on valueless event attributes X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=c5e380ed57ec1030cfd4c9e01c9486abae6706cf;p=html-minifier.git Don’t choke on valueless event attributes --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index abae81c..cb24628 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -186,7 +186,7 @@ } function cleanAttributeValue(tag, attrName, attrValue, options, attrs) { - if (isEventAttribute(attrName)) { + if (attrValue && isEventAttribute(attrName)) { attrValue = trimWhitespace(attrValue).replace(/^javascript:\s*/i, '').replace(/\s*;$/, ''); if (options.minifyJS) { var wrappedCode = '(function(){' + attrValue + '})()'; diff --git a/tests/minifier.js b/tests/minifier.js index c64b556..efb61ef 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -54,6 +54,8 @@ // https://github.com/kangax/html-minifier/issues/169 equal(minify('ok'), 'ok'); + + equal(minify(''), ''); }); test('`minifiy` exists', function() {