diff --git a/src/html.rs b/src/html.rs
index 4c2b582..7e41841 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -1191,8 +1191,8 @@ pub fn walk_and_embed_assets(
// Empty inner content of STYLE tags
node.children.borrow_mut().clear();
} else {
- for node in node.children.borrow_mut().iter_mut() {
- if let NodeData::Text { ref contents } = node.data {
+ for child_node in node.children.borrow_mut().iter_mut() {
+ if let NodeData::Text { ref contents } = child_node.data {
let mut tendril = contents.borrow_mut();
let replacement = embed_css(
cache,
@@ -1428,6 +1428,42 @@ pub fn walk_and_embed_assets(
}
}
}
+ "noscript" => {
+ for child_node in node.children.borrow_mut().iter_mut() {
+ match child_node.data {
+ NodeData::Text { ref contents } => {
+ // Get contents of the NOSCRIPT node
+ let mut noscript_contents = contents.borrow_mut();
+ // Parse contents of the NOSCRIPT node
+ let noscript_contents_dom: RcDom = html_to_dom(&noscript_contents);
+ // Embed assets within the NOSCRIPT node
+ walk_and_embed_assets(
+ cache,
+ client,
+ &url,
+ &noscript_contents_dom.document,
+ &options,
+ depth,
+ );
+ // Get rid of original contents
+ noscript_contents.clear();
+ // Insert HTML containing embedded assets into the NOSCRIPT node
+ if let Some(html) =
+ get_child_node_by_name(&noscript_contents_dom.document, "html")
+ {
+ if let Some(body) = get_child_node_by_name(&html, "body") {
+ let mut buf: Vec = Vec::new();
+ serialize(&mut buf, &body, SerializeOpts::default())
+ .expect("Unable to serialize DOM into buffer");
+ let result = String::from_utf8(buf).unwrap();
+ noscript_contents.push_slice(&result);
+ }
+ }
+ }
+ _ => {}
+ }
+ }
+ }
_ => {}
}
diff --git a/src/tests/html/walk_and_embed_assets.rs b/src/tests/html/walk_and_embed_assets.rs
index 901574a..93026d1 100644
--- a/src/tests/html/walk_and_embed_assets.rs
+++ b/src/tests/html/walk_and_embed_assets.rs
@@ -326,4 +326,45 @@ mod passing {