Repository navigation
feat: a <template shadowrootmode> never made a shadow root - #119
Conversation
Syncs Netweir 0107514, bringing: - netweir/netweir#344: debug_assert!s on the parser's invariants for fuzzing to trip (links after every insert and removal, the stack of open elements against on_stack and its counts, the active formatting list, spans, the chunked parser's offsets), Document::check_tree() in debug builds, and the column-group whitespace bug they found. - netweir/netweir#345: declarative shadow DOM. The tree builder attaches shadow roots as the HTML Standard says, with slots, the flat tree, :host, :host(), :host-context(), ::slotted(), and getHTML-style serialization. WPT's declarative shadow DOM cases: 7,590 pass. The C API and both bindings handle the new Kind::ShadowRoot (a DocumentFragment, as the DOM has it), EditError::NotAShadowHost and Options::declarative_shadow_roots. .gitattributes keeps the shadow DOM test data byte for byte on Windows. The README's tokenizer count is 7,042: Parsec's html5lib-tests is newer than Netweir's and dropped three obsolete cases.
foothillsdigital
left a comment
There was a problem hiding this comment.
Reviewed 2b3d1f8.
It's a faithful sync. For tokenizer.rs, tree.rs, css.rs, dom.rs, edit.rs, serialize.rs and lib.rs, this PR's change is line for line Netweir's from 46ba93b to 0107514. shadow.rs differs only by the three-line Apache licence header every Parsec source file carries.
The Parsec-only parts (the bindings and XPath) map a shadow root to a DocumentFragment, node type 11, everywhere, as the DOM does. NotAShadowHost becomes PARSEC_ERR_INVALID in the C API, which attaches none yet. XPath leaving shadow trees out matches document.evaluate, and the module docs say so.
Checks. cargo clippy --workspace --all-targets -- -D warnings is clean, now that #117 is in. cargo test --workspace --release passes 309 tests in 37 groups. declarative shadow DOM: 7590 passed, 0 failed. The Python bindings built from this branch pass 34 tests (1 free-threaded skip).
About the failing CodeQL check. Its two high alerts, #16 and #17, are rust/cleartext-logging at dom.rs:503 and :521. Both are debug_assert! messages in insert that format node ids, plain u32 indexes ("node {child} is a document, fragment or shadow root, never a child", "node {before} isn't a child of {parent}"). CodeQL traced a value from the Python bindings' extract_pyclass_ref_trusted into the panic message and treated the panic as a log write. Nothing sensitive is in them, and debug_assert! is compiled out of release builds, so nothing can be written in what ships. I'd dismiss both as false positives; I've left that to you.
Approving.
Problem
<template shadowrootmode>was parsed as an ordinary template, so a page's declarative shadow roots never existed in Parsec's tree (Declarative shadow DOM: <template shadowrootmode> attaches a shadow root #110).Change
Syncs Netweir 0107514, feat(html): fuzzing had no assertions of the parser's own to trip netweir/netweir#344, the fuzzing assertions:
debug_assert!s on links after every insert and removal;on_stack, and its counts;Document::check_tree()in debug builds;Release builds are unchanged.
Syncs Netweir 0107514, feat(html): a <template shadowrootmode> never made a shadow root netweir/netweir#345, declarative shadow DOM:
Kind::ShadowRoot, attached by the HTML Standard's steps, behindOptions::declarative_shadow_roots;:host,:host(),:host-context()and::slotted();getHTML-style serialization.parsec-capi,bindings/python,bindings/wasm: a shadow root is aDocumentFragment(node type 11), as in the DOM.EditError::NotAShadowHostmaps toPARSEC_ERR_INVALID, since the C API attaches none.Optionsliterals use..Options::default()..gitattributes: keepscrates/parsec/tests/shadow-dom/*byte for byte on Windows.README: a shadow DOM bullet, and the tokenizer count corrected to 7,042. Parsec's html5lib-tests, c5495c5, is newer than Netweir's and dropped three obsolete cases.
ROADMAP: updated to match.
Closes #52
Closes #110
Tests
:hostparse cases now run and pass.cargo test --workspace: 309 test groups, 0 failed. Tokenizer 7,042 and tree construction 3,898 passed, 0 failed. Clippy-D warningsis clean on the workspace and both bindings (wasm32 for WASM).