mirror of
https://github.com/m1ngsama/TUT.git
synced 2026-02-08 00:54:05 +00:00
fix: Filter out script/style tags during DOM tree build
Previously, script and style tags were only filtered during render, but their text content (JavaScript code) was still in the DOM tree. Now we skip these tags entirely during DOM tree construction, resulting in much cleaner output for modern websites.
This commit is contained in:
parent
8d56a7b67b
commit
7ac0fc1c91
1 changed files with 6 additions and 0 deletions
|
|
@ -178,6 +178,12 @@ std::unique_ptr<DomNode> DomTreeBuilder::convert_node(
|
|||
node->tag_name = gumbo_normalized_tagname(element.tag);
|
||||
node->element_type = map_gumbo_tag_to_element_type(element.tag);
|
||||
|
||||
// 跳过 script、style 等不需要渲染的标签(包括其所有子节点)
|
||||
if (element.tag == GUMBO_TAG_SCRIPT || element.tag == GUMBO_TAG_STYLE ||
|
||||
element.tag == GUMBO_TAG_NOSCRIPT || element.tag == GUMBO_TAG_TEMPLATE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Assign current form ID to children
|
||||
node->form_id = g_current_form_id;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue