[Feature Request]: Record only a specific DOM subtree (e.g. a single div) instead of the full document
Preflight Checklist
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
What package is this feature request for?
rrweb
Problem Description
Problem
I need to record only a specific section of the page — a div with class .screens — rather than the entire document. The rest of the page contains unrelated UI chrome that should not be captured.
What I've tried
1. root option — does not exist in recordOptions, TypeScript rejects it.
2. doc option — only accepts a Document, not an Element. Passing document.querySelector('.screens') fails at the type level.
3. blockSelector — blocks elements from being recorded but still serialises the full document structure. The recording still includes everything outside .screens, just blanked out.
4. Wrapping in an iframe — moves .screens content into a sandboxed iframe and passes iframe.contentDocument to doc. Works architecturally but requires significant restructuring of our component tree and breaks existing CSS/JS that depends on .screens living in the main document.
What I'm looking for
Is there a supported way to scope recording to a specific Element subtree — essentially treating that element as the recording root — without moving it into a separate Document?
If not, is this something on the roadmap? A root: Element option that serialises only that subtree and its descendants would cover this use case cleanly.
Proposed Solution
To add the root back?
Alternatives Considered
NA
Additional Information
NA
Source: rrweb-io/rrweb