diff --git a/package.json b/package.json index 7a291e01..fe5ab892 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@highlight-run/rrweb", - "version": "1.1.16", + "version": "1.1.17", "description": "record and replay the web", "scripts": { "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**.test.ts", diff --git a/src/snapshot/snapshot.ts b/src/snapshot/snapshot.ts index fa1bf673..bd7accfc 100644 --- a/src/snapshot/snapshot.ts +++ b/src/snapshot/snapshot.ts @@ -585,7 +585,12 @@ function serializeNode( if (isStyle && textContent) { try { // try to read style sheet - if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) { + if (n.nextSibling || n.previousSibling) { + // This is not the only child of the stylesheet. + // We can't read all of the sheet's .cssRules and expect them + // to _only_ include the current rule(s) added by the text node. + // So we'll be conservative and keep textContent as-is. + } else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) { textContent = stringifyStyleSheet( (n.parentNode as HTMLStyleElement).sheet!, );