diff --git a/lib/index.js b/lib/index.js index 3acb614..65fb536 100644 --- a/lib/index.js +++ b/lib/index.js @@ -187,7 +187,7 @@ function main() { if (todo.styles.length) { debug('start %s styles', todo.styles.length); var stylePromises = todo.styles.map(function links(i, style) { - var css = $(style).html(); + var css = $(style).text(); inliner.emit('progress', 'processing inline css'); return inliner.cssImports(url, css) .then(inliner.cssImages.bind(inliner, url)) @@ -204,7 +204,7 @@ function main() { var scriptPromises = todo.scripts.map(function links(i, script) { var $script = $(script); var src = $script.attr('src'); - var source = $(script).html(); + var source = $(script).text(); var promise; @@ -239,6 +239,10 @@ function main() { return promise.then(inliner.uglify.bind(inliner)) .then(function then(res) { debug('uglify: %s', res); + + // remove ETAGO (https://mathiasbynens.be/notes/etago) + res = res.replace(/<\/script/gi, '<\\/script'); + $script.text(res); }); }); diff --git a/test/fixtures/script-local.js b/test/fixtures/script-local.js index 279a642..7fc9d24 100644 --- a/test/fixtures/script-local.js +++ b/test/fixtures/script-local.js @@ -2,4 +2,8 @@ var array = [4, 8, 15, 16, 23, 42]; for (var i = 0; i < array.length; i++) { console.log(array[i]); +} + +function surroundWithScriptTag(code) { + return ''; } \ No newline at end of file diff --git a/test/fixtures/script-local.result.html b/test/fixtures/script-local.result.html index 87644ad..c9f3f8c 100644 --- a/test/fixtures/script-local.result.html +++ b/test/fixtures/script-local.result.html @@ -1 +1 @@ - min script \ No newline at end of file + min script \ No newline at end of file