mirror of
https://github.com/remy/inliner.git
synced 2024-08-16 20:00:35 +03:00
fix: spaceless @import cause infinite loop (#136)
This commit is contained in:
parent
bacf080d09
commit
3fa5f7ea67
@ -56,7 +56,7 @@ function getImports(root, css) {
|
||||
|
||||
if (position !== -1) {
|
||||
inliner.jobs.add('link', 1);
|
||||
var match = (css.match(/@import\s*(.*?);/) || [null, ''])[1];
|
||||
var match = (css.match(/@import(\s*.*?);/) || [null, ''])[1];
|
||||
var url = match.replace(/url/, '')
|
||||
.replace(/['}"()]/g, '')
|
||||
.replace(/;/, '')
|
||||
@ -74,7 +74,7 @@ function getImports(root, css) {
|
||||
importedCSS = '@media ' + url.join(' ') + '{' + importedCSS + '}';
|
||||
}
|
||||
|
||||
css = css.replace('@import ' + match, importedCSS);
|
||||
css = css.replace('@import' + match, importedCSS);
|
||||
return getImports.call(inliner, root, css);
|
||||
});
|
||||
}
|
||||
|
2
test/fixtures/css-import.result.html
vendored
2
test/fixtures/css-import.result.html
vendored
@ -1 +1 @@
|
||||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline style</title> <style> p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; @media screen and orientation:landscape{p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}};</style> </head> <body> </body> </html>
|
||||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline style</title> <style> p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}; @media screen and orientation:landscape{p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;}}; p{ font-size:10px;background:url("data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=") repeat;}p:before{ content:'<';color:blue;};</style> </head> <body> </body> </html>
|
||||
|
2
test/fixtures/css-import.src.html
vendored
2
test/fixtures/css-import.src.html
vendored
@ -12,6 +12,8 @@
|
||||
@import 'import.css';
|
||||
/* four */
|
||||
@import url('import.css') screen and (orientation:landscape);
|
||||
/* five */
|
||||
@import"import.css";
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user