rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

fix: wujie shadow root

Open wfk007 opened this issue 3 months ago • 2 comments

fix:https://github.com/rrweb-io/rrweb/issues/1682

reproduce step: https://github.com/wfk007/rrweb-wujie

wfk007 avatar Nov 21 '25 11:11 wfk007

🦋 Changeset detected

Latest commit: 4ec827335e64891ce3e0a523bcb2e21864649472

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb Patch
@rrweb/utils Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Nov 21 '25 11:11 changeset-bot[bot]

Wujie framework proxiesiframe.contentDocument.contains to the contains which this bind to shadow-root(document-fragment)

image

This explained the log output below:

const iframe = window.document.querySelector('IFRAME');
const head = iframe.contentDocument.querySelector('head');

// updated code simulate output
iframe.contentDocument.contains(head); // true

// Previous code simulate output
window.Node.prototype.contains.call(iframe.contentDocument, head); // false
iframe.contentWindow.Node.prototype.contains.bind(iframe.contentDocument)(head); // false
image

wfk007 avatar Nov 21 '25 11:11 wfk007

Is there anyone follow up this pr?

JiuRanYa avatar Dec 30 '25 04:12 JiuRanYa

Looks like this is the correct fix: https://github.com/wfk007/rrweb-wujie/pull/1 wujie monkeypatches .ownerDocument and we where still accessing using the un-monkey accessor method which lead to the recording breaking

Juice10 avatar Jan 02 '26 09:01 Juice10

Looks like this is the correct fix: wfk007/rrweb-wujie#1 wujie monkeypatches .ownerDocument and we where still accessing using the un-monkey accessor method which lead to the recording breaking

This pr is working for me! 👍

wfk007 avatar Jan 02 '26 10:01 wfk007

Looks like this is the correct fix: wfk007/rrweb-wujie#1 wujie monkeypatches .ownerDocument and we where still accessing using the un-monkey accessor method which lead to the recording breaking

@Juice10 This is how I understand:

  1. wujie: monkeypatches ownerDocument, making shadowRootNode.ownerDocument to iframe doc(created by wujie). https://github.com/Tencent/wujie/blob/ddfc5ccd730a2a87dfbfb455dbcac4618f5cee4b/packages/wujie-core/src/iframe.ts#L748

  2. rrweb record: In inDom function, ownerDocument(tainted by wijie) with contains(unTainted with rrweb) give the false return, breaking the node serialized.

so, we need to keep ownerDocument and contains all unTainted.

wfk007 avatar Jan 04 '26 07:01 wfk007