fix: recording bug in youtube and bitbucket (#1020)
when getting shadow host elements, the anchor element <a> also has a host property as a string. This unexpected value can crash recorder
This commit is contained in:
@@ -266,15 +266,20 @@ export default class MutationBuffer {
|
|||||||
return nextId;
|
return nextId;
|
||||||
};
|
};
|
||||||
const pushAdd = (n: Node) => {
|
const pushAdd = (n: Node) => {
|
||||||
const shadowHost: Element | null = n.getRootNode
|
let shadowHost: Element | null = null;
|
||||||
? (n.getRootNode() as ShadowRoot)?.host
|
if (
|
||||||
: null;
|
n.getRootNode?.()?.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
|
||||||
|
(n.getRootNode() as ShadowRoot).host
|
||||||
|
)
|
||||||
|
shadowHost = (n.getRootNode() as ShadowRoot).host;
|
||||||
// If n is in a nested shadow dom.
|
// If n is in a nested shadow dom.
|
||||||
let rootShadowHost = shadowHost;
|
let rootShadowHost = shadowHost;
|
||||||
while ((rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host)
|
while (
|
||||||
rootShadowHost =
|
rootShadowHost?.getRootNode?.()?.nodeType ===
|
||||||
(rootShadowHost?.getRootNode?.() as ShadowRoot | undefined)?.host ||
|
Node.DOCUMENT_FRAGMENT_NODE &&
|
||||||
null;
|
(rootShadowHost.getRootNode() as ShadowRoot).host
|
||||||
|
)
|
||||||
|
rootShadowHost = (rootShadowHost.getRootNode() as ShadowRoot).host;
|
||||||
// ensure contains is passed a Node, or it will throw an error
|
// ensure contains is passed a Node, or it will throw an error
|
||||||
const notInDoc =
|
const notInDoc =
|
||||||
!this.doc.contains(n) &&
|
!this.doc.contains(n) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user