Changelog
Typed DOM rework: W3C node hierarchy ($dom_node/character_data/element/text/cdata/comment/pi/document/fragment/doctype), comments preserved, to_markdown, full DOM API
2026-05-30 21:59 UTC · claude (#13505)
Replaced the flat $xml_node element-tree with a real W3C-DOM-style typed node hierarchy. Abstract bases $dom_node (#10595) and $dom_character_data (#10598); concrete $xml_element (#10564, formerly $xml_node), $xml_text (#10600), $xml_cdata (#10614), $xml_raw_text (#10616, script/style unescaped), $xml_comment (#10601), $xml_pi (#10610), $xml_document (#10594), $xml_fragment (#10619), $xml_doctype (#10622). Every node has :nodeType/:nodeName and polymorphic :to_xml.
Parsers ($xml:parse, $html_parser:parse) now emit typed nodes; comments and CDATA are preserved as real nodes (previously discarded) and round-trip faithfully. $xml_element:new dispatches the "#document" tag to $xml_document. A document is now a polymorphic node (child of element) with :render/:html/:head/:body/:title/:document_element; $html_parser:new_document() builds a default doc (lang+charset+viewport). The old $html_document wrapper (a parallel hierarchy) was deleted.
Added :to_markdown on every node (CommonMark: headings, paragraphs, links, images, lists, bold/italic, code, pre, blockquote, br, hr). Added DOM completeness: :get_element_by_id, :get_elements_by_tag, :first_element_child, :last_element_child, :inner_html, :outer_html, :inner_text (excludes script/style) vs :text (textContent), :add_text. Navigation (:parent/:siblings/:next_sibling/:prev_sibling/:remove) moved to the base, root-relative and node-type-aware.
Per-layer case policy: element tag-lookups and CSS class/id/attr use equal() (case-sensitive, XML-correct); HTML lowercases on ingest; CSS type selectors fold to lowercase. MOO maps/==/index are inherently case-insensitive, so .attrs case-distinct keys collide (documented limitation).
17 $test_runner tests green across $xml (#1284), $xml_element (#10564), $html_parser (#10569), $dom_character_data (#10598). Spec in notes/dom-rework-spec.md.