Skip to content

Commit

Permalink
fix: CORS proxy plugin style element handling (#19396)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Dec 18, 2023
1 parent 35cd465 commit 5ed1520
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion frontend/src/scenes/session-recordings/player/rrweb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ export const CorsPlugin: ReplayPlugin & {
onBuild: (node) => {
if (node.nodeName === 'STYLE') {
const styleElement = node as HTMLStyleElement
styleElement.textContent = CorsPlugin._replaceFontCssUrls(styleElement.textContent)
const childNodes = styleElement.childNodes
for (let i = 0; i < childNodes.length; i++) {
// not every node in a style element is text
// e.g. formatted text might cause some <br/> elements to be present
// separating lines of text
if (childNodes[i].nodeType == 3) {
// then this is a text node
// TODO what about CSS import URLs we could replace those too?
const updatedContent = CorsPlugin._replaceFontCssUrls(childNodes[i].textContent)
if (updatedContent !== childNodes[i].textContent) {
childNodes[i].textContent = updatedContent
}
}
}
}

if (node.nodeName === 'LINK') {
Expand Down

0 comments on commit 5ed1520

Please sign in to comment.