Support links in style= attributes

This commit is contained in:
Emi Simpson 2019-12-06 15:28:08 -05:00
parent a4743ca92f
commit 45335d7507
No known key found for this signature in database
GPG key ID: 68FAB2E2E6DFC98B

View file

@ -413,6 +413,7 @@ pub fn walk_and_embed_assets(
_ => {} _ => {}
} }
// Process style attributes
if opt_no_css { if opt_no_css {
// Get rid of style attributes // Get rid of style attributes
let mut style_attr_indexes = Vec::new(); let mut style_attr_indexes = Vec::new();
@ -425,6 +426,28 @@ pub fn walk_and_embed_assets(
for attr_index in style_attr_indexes { for attr_index in style_attr_indexes {
attrs_mut.remove(attr_index); attrs_mut.remove(attr_index);
} }
} else {
// Otherwise, parse any links found in the attributes
for attribute in attrs_mut
.iter_mut()
.filter(|a| a.name.local.as_ref().eq_ignore_ascii_case("style"))
{
let replacement = resolve_css_imports(
cache,
attribute.value.as_ref(),
false,
&url,
opt_no_images,
opt_user_agent,
opt_silent,
opt_insecure,
);
attribute.value.clear();
attribute
.value
.write_str(&replacement)
.expect("Failed to update DOM");
}
} }
if opt_no_js { if opt_no_js {