mirror of
https://github.com/remy/inliner.git
synced 2024-09-11 17:25:30 +03:00
Merge pull request #54 from hsablonniere/etago
fix: inline scripts containing ETAGO properly
This commit is contained in:
commit
f4fc886b5e
@ -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);
|
||||
});
|
||||
});
|
||||
|
4
test/fixtures/script-local.js
vendored
4
test/fixtures/script-local.js
vendored
@ -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>';
|
||||
}
|
2
test/fixtures/script-local.result.html
vendored
2
test/fixtures/script-local.result.html
vendored
@ -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>
|
Loading…
Reference in New Issue
Block a user