fix: pierce new-reddit (shreddit) shadow DOM when collecting comment text (closes task/handle-shreddit-shadow-dom)
Source: task/handle-shreddit-shadow-dom (plan/steward-linker-design) — the TreeWalker only walked light DOM, so new-reddit comment bodies inside shadow roots were missed. - collectTextNodes now walks the comment-tree root's light DOM AND recursively descends into the open shadow roots of elements within that subtree, so comment text is reached whether reddit slots it (light DOM) or encapsulates it (shadow DOM). - Scoped to getRoot()'s comment tree (never the whole document's shadow roots); bounded by a depth cap; a no-op on old reddit (no shadow roots). - Slotted light-DOM nodes are not double-collected (a shadow walker sees the shadow tree's own nodes, not a <slot>'s assigned light nodes); a Set de-dupes by node identity belt-and-braces. - All existing guards preserved (inSkippable / rsl-link skip). README + AGENTS document the support. - Limitation: CLOSED shadow roots are unreachable from a content script and stay unlinked. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,17 @@ is tracked in the **towl** work-item store under project **`reddit-spotify-linke
|
||||
extractor (Title-Case runs + cue phrases for artists; quoted strings + album cue
|
||||
phrases for albums) — node-testable via `extract.test.cjs`. Album links render
|
||||
italicised (`.rsl-album`).
|
||||
- **shreddit shadow DOM:** `collectTextNodes` is shadow-piercing. A TreeWalker can't
|
||||
cross a shadow boundary, so it walks the comment-tree `root`'s light DOM AND
|
||||
recursively descends into the **open** shadow roots of elements within that subtree.
|
||||
New reddit's `shreddit-*` components may encapsulate comment bodies in a shadow root;
|
||||
this reaches them whether reddit slots (light DOM) or encapsulates (shadow DOM), with
|
||||
no need to know which. It is scoped to the comment-tree root (never the whole
|
||||
document's shadow roots, which would pull in reddit chrome) and is a no-op on old
|
||||
reddit (no shadow roots). Slotted light-DOM nodes are not double-collected (a shadow
|
||||
walker sees the shadow tree's own nodes, not a `<slot>`'s assigned light nodes; a
|
||||
Set de-dupes belt-and-braces). **Closed** shadow roots are unreachable from a content
|
||||
script — a documented limitation.
|
||||
- `scripts/check.sh` — the local check gate.
|
||||
|
||||
## How work lands (IMPORTANT — this is NOT the towl repo)
|
||||
|
||||
Reference in New Issue
Block a user