fix(StyleInliner): add support for url(url) format
This commit is contained in:
parent
e3f4c60f46
commit
4d8d17ce3d
@ -118,11 +118,11 @@ export class StyleInliner {
|
|||||||
|
|
||||||
// Extracts the url from an import rule, supported formats:
|
// Extracts the url from an import rule, supported formats:
|
||||||
// - 'url' / "url",
|
// - 'url' / "url",
|
||||||
// - url('url') / url("url")
|
// - url(url) / url('url') / url("url")
|
||||||
function _extractUrl(importRule: string): string {
|
function _extractUrl(importRule: string): string {
|
||||||
var match = RegExpWrapper.firstMatch(_urlRe, importRule);
|
var match = RegExpWrapper.firstMatch(_urlRe, importRule);
|
||||||
if (isBlank(match)) return null;
|
if (isBlank(match)) return null;
|
||||||
return match[1];
|
return isPresent(match[1]) ? match[1] : match[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extracts the media query from an import rule.
|
// Extracts the media query from an import rule.
|
||||||
@ -140,5 +140,8 @@ function _wrapInMediaRule(css: string, query: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _importRe = RegExpWrapper.create('@import\\s+([^;]+);');
|
var _importRe = RegExpWrapper.create('@import\\s+([^;]+);');
|
||||||
var _urlRe = RegExpWrapper.create('(?:url\\(\\s*)?[\'"]([^\'"]+)[\'"]');
|
var _urlRe = RegExpWrapper.create(
|
||||||
|
'url\\(\\s*?[\'"]?([^\'")]+)[\'"]?|' + // url(url) or url('url') or url("url")
|
||||||
|
'[\'"]([^\'")]+)[\'"]' // "url" or 'url'
|
||||||
|
);
|
||||||
var _mediaQueryRe = RegExpWrapper.create('[\'"][^\'"]+[\'"]\\s*\\)?\\s*(.*)');
|
var _mediaQueryRe = RegExpWrapper.create('[\'"][^\'"]+[\'"]\\s*\\)?\\s*(.*)');
|
||||||
|
@ -46,7 +46,7 @@ export function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO(vicb): fix the StyleInliner
|
// TODO(vicb): fix the StyleInliner
|
||||||
xit('should support url([unquoted url]) in @import rules', (done) => {
|
it('should support url([unquoted url]) in @import rules', (done) => {
|
||||||
xhr.reply('http://base/one.css', '.one {}');
|
xhr.reply('http://base/one.css', '.one {}');
|
||||||
var css = '@import url(one.css);.main {}';
|
var css = '@import url(one.css);.main {}';
|
||||||
var loadedCss = inliner.inlineImports(css, 'http://base');
|
var loadedCss = inliner.inlineImports(css, 'http://base');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user