Session replay and Shadow DOM

Web components keep their markup in shadow roots, out of reach of the usual DOM APIs. A recorder that does not look inside them replays an empty box where your date picker or checkout widget was. Here is how recording shadow DOM works, what we measured, and what each vendor documents.

What makes Shadow DOM hard to record

A recorder works by walking the page’s DOM tree, copying it, and then watching for changes with a MutationObserver. Shadow DOM breaks all three steps:

  • Walking. childNodes of a custom element does not include its shadow tree. The recorder has to check element.shadowRoot on every element and walk that tree separately.
  • Watching. A MutationObserver on the document does not see changes inside a shadow root. Each shadow root needs its own observer, attached when the root appears.
  • Styling. Components often style themselves with constructed stylesheets assigned to shadowRoot.adoptedStyleSheets. These have no <style> element in the DOM, so a recorder that only copies style elements replays an unstyled component.
  • Events. Events from inside a shadow root are retargeted to the host when they cross the boundary. Input values, scroll positions and focus inside the component have to be read inside it.

Open and closed shadow roots

attachShadow({ mode: "open" }) creates a root that any script can reach through element.shadowRoot. mode: "closed" returns the root only to the code that created it; element.shadowRoot is null. A recorder can therefore record an open root at any time, but a closed root only if it intercepted attachShadow before the component was created, which means loading before every component script. Most design systems (Lit, Stencil, Shoelace and friends) use open roots by default.

What we measured

We built a test page with one marker string in each kind of content, recorded it with rrweb and Replayowl in headless Chromium, and searched the recording for each marker. Method and raw result are linked below the table.

Content on the test page rrweb 2.2.2 Replayowl 0.1
Text in the regular DOM (control) Recorded Recorded
Text in an open shadow root Recorded Recorded
Text in a closed shadow root Not recorded Not recorded
Text in an open shadow root nested inside another Recorded Recorded
Text added to an open shadow root after recording started Recorded Recorded
A rule from a shadow root’s adoptedStyleSheets Recorded Recorded
Typing into an input inside an open shadow root Recorded in plain text Recorded, masked
Text in a same-origin iframe Recorded Not recorded

Both recorders were loaded after the components had been created, which is how most sites load a replay script. The input result is a difference in defaults, not in shadow DOM support: rrweb records input values unless maskAllInputs is on, and Replayowl masks them unless a field is marked data-ro-unmask. The test ran on November 22, 2026 in headless Chromium 156; the page, script and result are published with the benchmark data (test script).

What each vendor documents

From each vendor’s own documentation, checked on November 22, 2026. “Not documented” means the docs say nothing either way, not that it fails.

Tool Open shadow roots Closed shadow roots Source
FullStory Yes No FullStory help
LogRocket Yes No LogRocket docs
Mouseflow Yes No Mouseflow help
Datadog Session Replay Yes, Browser SDK 4.31.0 and later No Datadog docs
Contentsquare Yes Yes, since tag 15.250.1 Compatibility, changelog
Highlight.io Yes, “out of the box” Not distinguished Highlight docs on GitHub
Hotjar Not for Ionic, Polymer and Lit Not documented Hotjar help
Lucky Orange No (Lit and Polymer listed as unsupported) No Lucky Orange help
Microsoft Clarity Not documented Not documented Clarity docs
PostHog Not documented Not documented PostHog docs
Sentry Session Replay Not documented Not documented Sentry docs
Smartlook Not documented Not documented Smartlook docs
rrweb Yes (our test above) No (our test above) rrweb guide
Replayowl Yes (code and our test) No (code and our test) Known limitations

PostHog’s recorder is built on rrweb, so the rrweb result is a reasonable first guess for it, but PostHog may configure or patch rrweb differently; test your own components.

How Replayowl records shadow DOM

  • Every element with an open shadowRoot gets its shadow tree serialized next to its children, and the recorder attaches a separate MutationObserver to the root, so later changes are recorded too.
  • Shadow roots created after recording started are picked up too: the recorder wraps attachShadow, so an open root attached to an element it already knows is observed at once, and a root on a newly added element is serialized with it.
  • Constructed stylesheets in adoptedStyleSheets, on the document and on each shadow root, are copied, and changes to them (assignments and rule edits) are recorded.
  • Scroll, input and change events are listened for inside each shadow root, since they do not cross the boundary usefully.
  • Privacy attributes are looked up with a closest() that walks out through shadow hosts, so data-ro-mask on a page section also masks the components inside it.
  • Closed shadow roots are not recorded. Iframes and canvas content are not recorded either; see known limitations.

You can see it in the live demo: the star rating on the product page is a custom element with an open shadow root and its own adopted stylesheet.

How to test your own components

  1. Put the recorder on a staging page that uses your components, ideally loaded before the component scripts.
  2. Record a short session that opens, types into and scrolls each component.
  3. Watch the replay. Empty boxes or unstyled components mean the shadow tree or its adopted styles were not captured.
  4. Check masking: type into an input inside a component and search the upload in DevTools for what you typed. Paste the component’s rendered HTML into the PII masking tester to check the rules on its markup.

For how the same tools mask content, see masking attributes by vendor. For recorder size and overhead, see the rrweb vs Replayowl benchmark.

Questions and answers

Can session replay record closed shadow roots?

Usually not. A closed shadow root is not reachable through element.shadowRoot, so a recorder can only capture it if it hooks attachShadow before the component is created. Among the vendors we checked, only Contentsquare documents closed shadow root support; FullStory, LogRocket, Mouseflow and Datadog document that they do not record them. In our test neither rrweb nor Replayowl recorded a closed root.

Why does my web component show up empty in the replay?

Either the recorder does not read shadow roots, the root is closed, or the component's styles live in adoptedStyleSheets that the recorder does not copy. Check the vendor's documentation, then test with a page like the one in the method section.

Do masking attributes work inside a shadow root?

In Replayowl, yes: data-ro-mask, data-ro-block and data-ro-unmask are looked up across the shadow boundary, so an attribute on the host or on an element outside the component applies inside it. Hotjar documents that data-hj-allow does not work for text in a closed shadow root.

Try Replayowl on your own site

Hosted

Free for 1,000 sessions a month

Then $29 a month for 10,000. Paste one script tag and watch your first session a minute later.

Start free

Self-hosted

Free, no session caps

One Cloudflare Worker with your own R2 bucket and D1 database. Nothing is sent to us.

Self-host on Cloudflare

Or watch it record you first in the live demo, no sign-up.