Merge pull request #54 from hsablonniere/etago

fix: inline scripts containing ETAGO properly
This commit is contained in:
Remy Sharp 2015-07-29 06:41:48 +01:00
commit f4fc886b5e
3 changed files with 11 additions and 3 deletions

View File

@ -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);
});
});

View File

@ -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 '<script>' + code + '</script>';
}

View File

@ -1 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>min script</title> </head> <body> <script>for(var array=[4,8,15,16,23,42],i=0;i<array.length;i++)console.log(array[i]);</script> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>min script</title> </head> <body> <script>function surroundWithScriptTag(r){return"<script>"+r+"<\/script>"}for(var array=[4,8,15,16,23,42],i=0;i<array.length;i++)console.log(array[i]);</script> </body> </html>