From 49c1ba0a1fee88d6ba0ab2ff2748736fb980fa81 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Fri, 23 Nov 2018 22:47:19 +0800 Subject: [PATCH] absolute relative path in inline stylesheet --- src/snapshot.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/snapshot.ts b/src/snapshot.ts index a0623055..fb772813 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -154,13 +154,17 @@ function serializeNode(n: Node, doc: Document): serializedNode | false { const parentTagName = n.parentNode && (n.parentNode as HTMLElement).tagName; let textContent = (n as Text).textContent; + const isStyle = parentTagName === 'STYLE' ? true : undefined; + if (isStyle && textContent) { + textContent = absoluteToStylesheet(textContent, location.href); + } if (parentTagName === 'SCRIPT') { textContent = 'SCRIPT_PLACEHOLDER'; } return { type: NodeType.Text, textContent: textContent || '', - isStyle: parentTagName === 'STYLE' ? true : undefined, + isStyle, }; case n.CDATA_SECTION_NODE: return {