Fix: update shadow root attribute in HTMLSerializer to use 'shadowroot' instead of 'shadowrootmode', enhancing compatibility with declarative shadow DOM syntax.

This commit is contained in:
Magnus Müller
2025-10-13 20:50:27 -07:00
parent d7d0b787cf
commit cb4cfb1130

View File

@@ -45,12 +45,11 @@ class HTMLSerializer:
elif node.node_type == NodeType.DOCUMENT_FRAGMENT_NODE:
# Shadow DOM root - wrap in template with shadowrootmode attribute
# This is the declarative shadow DOM syntax that html2text can process
parts = []
# Add shadow root opening
shadow_type = node.shadow_root_type or 'open'
parts.append(f'<template shadowrootmode="{shadow_type.lower()}">')
parts.append(f'<template shadowroot="{shadow_type.lower()}">')
# Serialize shadow children
for child in node.children: