Add workaround for Chrome/Edge css import escaping bug (#1287)
* Upgrade to typescript 4.9.5 * Apply formatting changes * Add workaround for chrome incorrect escaping bug More info: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259 * Apply formatting changes * Create itchy-dryers-double.md * Create rich-jars-remember.md * Apply formatting changes * Update packages/rrweb-snapshot/src/css.ts * Apply formatting changes * Update packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap * Apply formatting changes * Update snapshot * Apply formatting changes * Rename and refactor fixBrowserCompatibilityIssuesInCSSImports, getCssRulesString and getCssRuleString based on @eoghanmurray feedback * Apply formatting changes * Apply formatting changes
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
isShadowRoot,
|
||||
maskInputValue,
|
||||
isNativeShadowDom,
|
||||
getCssRulesString,
|
||||
stringifyStylesheet,
|
||||
getInputType,
|
||||
toLowerCase,
|
||||
validateStringifiedCssRule,
|
||||
@@ -554,7 +554,7 @@ function serializeTextNode(
|
||||
// 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 = getCssRulesString(
|
||||
textContent = stringifyStylesheet(
|
||||
(n.parentNode as HTMLStyleElement).sheet!,
|
||||
);
|
||||
}
|
||||
@@ -644,7 +644,7 @@ function serializeElementNode(
|
||||
});
|
||||
let cssText: string | null = null;
|
||||
if (stylesheet) {
|
||||
cssText = getCssRulesString(stylesheet);
|
||||
cssText = stringifyStylesheet(stylesheet);
|
||||
}
|
||||
if (cssText) {
|
||||
delete attributes.rel;
|
||||
@@ -659,7 +659,7 @@ function serializeElementNode(
|
||||
// TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
|
||||
!(n.innerText || n.textContent || '').trim().length
|
||||
) {
|
||||
const cssText = getCssRulesString(
|
||||
const cssText = stringifyStylesheet(
|
||||
(n as HTMLStyleElement).sheet as CSSStyleSheet,
|
||||
);
|
||||
if (cssText) {
|
||||
|
||||
Reference in New Issue
Block a user