From: alexlamsl Date: Thu, 4 Feb 2016 20:05:30 +0000 (+0800) Subject: clarify minification logic X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fce3d5e2faeb71ceaf922693aa78bedcfaabff85;p=html-minifier.git clarify minification logic --- diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 4f89c25..8ee18fa 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -857,8 +857,11 @@ return attrValue; } else if (isMetaViewport(tag, attrs) && attrName === 'content') { - attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(num) { - return (+num).toString(); + attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(numString) { + // "0.90000" -> "0.9" + // "1.0" -> "1" + // "1.0001" -> "1.0001" (unchanged) + return (+numString).toString(); }); } else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) { diff --git a/src/htmlminifier.js b/src/htmlminifier.js index cd0b304..b117859 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -292,8 +292,11 @@ return attrValue; } else if (isMetaViewport(tag, attrs) && attrName === 'content') { - attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(num) { - return (+num).toString(); + attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(numString) { + // "0.90000" -> "0.9" + // "1.0" -> "1" + // "1.0001" -> "1.0001" (unchanged) + return (+numString).toString(); }); } else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) {