From c5e380ed57ec1030cfd4c9e01c9486abae6706cf Mon Sep 17 00:00:00 2001 From: Duncan Beevers Date: Thu, 10 Jul 2014 16:02:10 -0500 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20choke=20on=20valueless=20event?= =?utf8?q?=20attributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/htmlminifier.js | 2 +- tests/minifier.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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() { -- 2.34.1