From d11c6e89d94ac8df0d6661c869573037a31015e4 Mon Sep 17 00:00:00 2001 From: sndrs Date: Thu, 13 Jun 2013 17:49:33 +0100 Subject: [PATCH] images are a special case --- dist/all.js | 8 +++----- src/htmlminifier.js | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dist/all.js b/dist/all.js index b4dbd44..30c5d22 100644 --- a/dist/all.js +++ b/dist/all.js @@ -384,15 +384,13 @@ function collapseWhitespaceSmart(str, prevTag, nextTag) { // array of tags that will maintain a single space outside of them - var tags = ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'img', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u']; + var tags = ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u']; - if (prevTag && (prevTag.substr(0,1) !== '/' - || ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) { + if (prevTag && prevTag !== 'img' && (prevTag.substr(0,1) !== '/' || tags.indexOf(prevTag.substr(1)) === -1)) { str = str.replace(/^\s+/, ''); } - if (nextTag && (nextTag.substr(0,1) === '/' - || ( nextTag.substr(0,1) !== '/' && tags.indexOf(nextTag) === -1))) { + if (nextTag && nextTag !== 'img' && (nextTag.substr(0,1) === '/' || tags.indexOf(nextTag) === -1)) { str = str.replace(/\s+$/, ''); } diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 352e5e5..e48c321 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -42,15 +42,13 @@ function collapseWhitespaceSmart(str, prevTag, nextTag) { // array of tags that will maintain a single space outside of them - var tags = ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'img', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u']; + var tags = ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u']; - if (prevTag && (prevTag.substr(0,1) !== '/' - || ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) { + if (prevTag && prevTag !== 'img' && (prevTag.substr(0,1) !== '/' || tags.indexOf(prevTag.substr(1)) === -1)) { str = str.replace(/^\s+/, ''); } - if (nextTag && (nextTag.substr(0,1) === '/' - || ( nextTag.substr(0,1) !== '/' && tags.indexOf(nextTag) === -1))) { + if (nextTag && nextTag !== 'img' && (nextTag.substr(0,1) === '/' || tags.indexOf(nextTag) === -1)) { str = str.replace(/\s+$/, ''); } -- 2.34.1