Skip to content

Commit

Permalink
[REPLAY] Add support for adoptedStylesheets in serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautGeriz committed Jan 4, 2023
1 parent f384c10 commit 59ff5c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/rum/src/domain/record/browser.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// TODO: remove this once typescript has been update to 4.8+
declare global {
interface ShadowRoot {
adoptedStyleSheets: CSSStyleSheet[] | undefined
}

interface Document {
adoptedStyleSheets: CSSStyleSheet[] | undefined
}
}

export {}
4 changes: 4 additions & 0 deletions packages/rum/src/domain/record/serialize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('serializeNodeWithId', () => {
jasmine.objectContaining({ type: NodeType.DocumentType, name: 'html', publicId: '', systemId: '' }),
jasmine.objectContaining({ type: NodeType.Element, tagName: 'html' }),
],
adoptedStyleSheets: undefined,
id: jasmine.any(Number) as unknown as number,
})
})
Expand Down Expand Up @@ -437,6 +438,7 @@ describe('serializeNodeWithId', () => {
isShadowRoot: true,
childNodes: [],
id: jasmine.any(Number) as unknown as number,
adoptedStyleSheets: undefined,
},
],
id: jasmine.any(Number) as unknown as number,
Expand Down Expand Up @@ -468,6 +470,7 @@ describe('serializeNodeWithId', () => {
{
type: NodeType.DocumentFragment,
isShadowRoot: true,
adoptedStyleSheets: undefined,
childNodes: [
{
type: NodeType.Element,
Expand Down Expand Up @@ -692,6 +695,7 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
expect(serializeDocumentNode(document, serializeOptionsMask)).toEqual({
type: NodeType.Document,
childNodes: serializeChildNodes(document, serializeOptionsMask),
adoptedStyleSheets: undefined,
})
})

Expand Down
3 changes: 2 additions & 1 deletion packages/rum/src/domain/record/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { forEach } from './utils'
import type { ElementsScrollPositions } from './elementsScrollPositions'
import type { ShadowRootsController } from './shadowRootsController'
import './browser.types'

// Those values are the only one that can be used when inheriting privacy levels from parent to
// children during serialization, since HIDDEN and IGNORE shouldn't serialize their children. This
Expand Down Expand Up @@ -126,7 +127,7 @@ export function serializeDocumentNode(document: Document, options: SerializeOpti
return {
type: NodeType.Document,
childNodes: serializeChildNodes(document, options),
// adoptedStyleSheets: getStyleSheets(document.adoptedStyleSheets),
adoptedStyleSheets: getStyleSheets(document.adoptedStyleSheets),
}
}

Expand Down

0 comments on commit 59ff5c7

Please sign in to comment.