Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b70254c
feat: add rrweb web-extension package
YunFeng0817 Oct 16, 2022
be295bd
refactor: make the extension suitable for manifest v3
YunFeng0817 Oct 17, 2022
6d7ae5d
update tsconfig.json
YunFeng0817 Oct 31, 2022
c99b049
use version_name rather than recorder_version in manifest.json
YunFeng0817 Oct 31, 2022
e87d539
update manifest.json
YunFeng0817 Nov 1, 2022
579d5b8
enable to keep recording after changing tabs
YunFeng0817 Nov 1, 2022
8739a6f
enable to record between tabs and urls
YunFeng0817 Nov 2, 2022
6fd4f2a
fix CI error
YunFeng0817 Nov 2, 2022
7fbc406
Merge branch 'master' into extension
YunFeng0817 Nov 2, 2022
3209471
try to fix CI error
YunFeng0817 Nov 2, 2022
f134ddc
feat: add pause and resume buttons
YunFeng0817 Nov 3, 2022
ab0b588
feat: add a link to new session after recording
YunFeng0817 Nov 3, 2022
0d633e5
improve session list
YunFeng0817 Nov 5, 2022
8246457
refactor: migrate session storage from chrome local storage to indexedDB
YunFeng0817 Nov 5, 2022
5fe51f1
feat: add pagination to session list
YunFeng0817 Nov 5, 2022
1266dae
fix: multiple recorders are started after pausing and resuming process
YunFeng0817 Nov 5, 2022
6186f6a
fix: can't stop recording on firefox browser
YunFeng0817 Nov 5, 2022
0c7e5ef
Merge remote-tracking branch 'origin/master' into extension
YunFeng0817 Nov 5, 2022
5340919
update type import of 'eventWithTime'
YunFeng0817 Nov 5, 2022
9670fd3
fix CI error
YunFeng0817 Nov 5, 2022
196082b
doc: add readme
YunFeng0817 Nov 5, 2022
558ec5d
Merge branch 'master' into extension
YunFeng0817 Nov 7, 2022
c0126c9
Apply suggestions from Justin's code review
YunFeng0817 Nov 12, 2022
2d35e10
refactor: make use of webNavigation API to implement recording consis…
YunFeng0817 Nov 12, 2022
2fbd399
fix firefox compatibility issue and add title to pages
YunFeng0817 Nov 12, 2022
4a56727
add mouseleave listener to enhance the recording liability
YunFeng0817 Nov 13, 2022
6abfb40
fix firefox compatibility issue and improve the experience of recordi…
YunFeng0817 Nov 13, 2022
c931c51
Merge branch 'master' into extension
YunFeng0817 Nov 13, 2022
da99bc2
update tsconfig
YunFeng0817 Nov 13, 2022
d65135c
upgrade vite-plugin-web-extension config to fix some bugs on facebook…
YunFeng0817 Nov 17, 2022
f08f334
update import links
YunFeng0817 Nov 17, 2022
46140be
refactor: cross tab recording mechanism
YunFeng0817 Nov 17, 2022
6665ca4
Merge branch 'master' into extension
YunFeng0817 Nov 18, 2022
36248e2
refactor: slipt util/index.ts into multiple files
YunFeng0817 Dec 1, 2022
d978ab6
implement cross-origin iframe recording
YunFeng0817 Dec 2, 2022
70e6155
fix: regression of issue: ShadowHost can't be a string (issue 941)
YunFeng0817 Jan 13, 2023
407a48a
refactor shadow dom recording to make tests cover key code
YunFeng0817 Jan 13, 2023
719ca76
Merge branch 'master' into extension
YunFeng0817 Jan 13, 2023
2409f76
Merge branch 'fix-shadow-dom-bug' into extension
YunFeng0817 Jan 17, 2023
1174194
Merge branch 'master' into extension
YunFeng0817 Feb 11, 2023
4e779f9
Apply formatting changes
Feb 11, 2023
36a8c00
increase the node memory limitation to avoid CI failure
YunFeng0817 Feb 11, 2023
6101714
Merge remote-tracking branch 'origin/master' into extension
YunFeng0817 Feb 12, 2023
1041fac
Create lovely-pears-cross.md
Juice10 Feb 13, 2023
1e4c582
Apply formatting changes
Juice10 Feb 13, 2023
86a88e0
Update packages/web-extension/package.json
Juice10 Feb 13, 2023
1f8a29a
Update .changeset/lovely-pears-cross.md
Juice10 Feb 13, 2023
3e5ab6f
Merge branch 'master' into extension
YunFeng0817 Feb 13, 2023
802b9b2
update change logs
YunFeng0817 Feb 13, 2023
832d7eb
delete duplicated property
YunFeng0817 Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: regression of issue: ShadowHost can't be a string (issue 941)
  • Loading branch information
YunFeng0817 committed Jan 13, 2023
commit 70e6155be99c4b3c6127b48714d1d359f3f743d1
11 changes: 5 additions & 6 deletions packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,12 @@ export class StyleSheetMirror {
}
}

export function getRootShadowHost(n: Node): Node | null {
const shadowHost = (n.getRootNode() as ShadowRoot).host;
// If n is in a nested shadow dom.
let rootShadowHost = shadowHost;
export function getRootShadowHost(n: Node): Node {
let rootShadowHost: Node = n;

// If n is in a nested shadow dom.
while (
rootShadowHost?.getRootNode?.()?.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
rootShadowHost.getRootNode?.()?.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
(rootShadowHost.getRootNode() as ShadowRoot).host
)
rootShadowHost = (rootShadowHost.getRootNode() as ShadowRoot).host;
Expand All @@ -537,7 +536,7 @@ export function shadowHostInDom(n: Node): boolean {
const doc = n.ownerDocument;
if (!doc) return false;
const shadowHost = getRootShadowHost(n);
return Boolean(shadowHost && doc.contains(shadowHost));
return doc.contains(shadowHost);
}

export function inDom(n: Node): boolean {
Expand Down
63 changes: 62 additions & 1 deletion packages/rrweb/test/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* @jest-environment jsdom
*/
import { StyleSheetMirror } from '../src/utils';
import {
getRootShadowHost,
StyleSheetMirror,
inDom,
shadowHostInDom,
} from '../src/utils';

describe('Utilities for other modules', () => {
describe('StyleSheetMirror', () => {
Expand Down Expand Up @@ -75,4 +80,60 @@ describe('Utilities for other modules', () => {
expect(mirror.add(new CSSStyleSheet())).toBe(1);
});
});

describe('inDom()', () => {
it('should get correct result given nested shadow doms', () => {
const shadowHost = document.createElement('div');
const shadowRoot = shadowHost.attachShadow({ mode: 'open' });
const shadowHost2 = document.createElement('div');
const shadowRoot2 = shadowHost2.attachShadow({ mode: 'open' });
const div = document.createElement('div');
shadowRoot.appendChild(shadowHost2);
shadowRoot2.appendChild(div);
// Not in Dom yet.
expect(getRootShadowHost(div)).toBe(shadowHost);
expect(shadowHostInDom(div)).toBeFalsy();
expect(inDom(div)).toBeFalsy();

// Added to the Dom.
document.body.appendChild(shadowHost);
expect(getRootShadowHost(div)).toBe(shadowHost);
expect(shadowHostInDom(div)).toBeTruthy();
expect(inDom(div)).toBeTruthy();
});

it('should get correct result given a normal node', () => {
const div = document.createElement('div');
// Not in Dom yet.
expect(getRootShadowHost(div)).toBe(div);
expect(shadowHostInDom(div)).toBeFalsy();
expect(inDom(div)).toBeFalsy();

// Added to the Dom.
document.body.appendChild(div);
expect(getRootShadowHost(div)).toBe(div);
expect(shadowHostInDom(div)).toBeTruthy();
expect(inDom(div)).toBeTruthy();
});

/**
* Given the textNode of a detached HTMLAnchorElement, getRootNode() will return the anchor element itself and its host property is a string.
* This corner case may cause an error in getRootShadowHost().
*/
it('should get correct result given the textNode of a detached HTMLAnchorElement', () => {
const a = document.createElement('a');
a.href = 'example.com';
a.textContent = 'something';
// Not in Dom yet.
expect(getRootShadowHost(a.childNodes[0])).toBe(a.childNodes[0]);
expect(shadowHostInDom(a.childNodes[0])).toBeFalsy();
expect(inDom(a.childNodes[0])).toBeFalsy();

// Added to the Dom.
document.body.appendChild(a);
expect(getRootShadowHost(a.childNodes[0])).toBe(a.childNodes[0]);
expect(shadowHostInDom(a.childNodes[0])).toBeTruthy();
expect(inDom(a.childNodes[0])).toBeTruthy();
});
});
});