Skip to content

Commit

Permalink
Merge pull request #24 from pendo-io/ajax-revert-grid-template-pr
Browse files Browse the repository at this point in the history
Revert grid template prs
  • Loading branch information
guntherjh authored Oct 21, 2024
2 parents 6321c05 + 1340c80 commit 5a0cb20
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 49 deletions.
5 changes: 0 additions & 5 deletions .changeset/stale-llamas-divide.md

This file was deleted.

45 changes: 1 addition & 44 deletions packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export function getNative<T>(

export const nativeSetTimeout =
typeof window !== 'undefined'
? (getNative<typeof window.setTimeout>('setTimeout').bind(
window,
) as typeof window.setTimeout)
? getNative<typeof window.setTimeout>('setTimeout').bind(window)
: global.setTimeout;

/**
Expand Down Expand Up @@ -159,44 +157,6 @@ export function stringifyStylesheet(s: CSSStyleSheet): string | null {
}
}

function replaceChromeGridTemplateAreas(rule: CSSStyleRule): string {
const hasGridTemplateInCSSText = rule.cssText.includes('grid-template:');
const hasGridTemplateAreaInStyleRules =
rule.style.getPropertyValue('grid-template-areas') !== '';
const hasGridTemplateAreaInCSSText = rule.cssText.includes(
'grid-template-areas:',
);
if (
isCSSStyleRule(rule) &&
hasGridTemplateInCSSText &&
hasGridTemplateAreaInStyleRules &&
!hasGridTemplateAreaInCSSText
) {
// chrome does not correctly provide the grid template areas in the rules cssText
// e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=1303968
// we remove the grid-template rule from the text... so everything from grid-template: to the next semicolon
// and then add each grid-template-x rule into the css text because Chrome isn't doing this correctly
const parts = rule.cssText
.split(';')
.filter((s) => !s.includes('grid-template:'))
.map((s) => s.trim());

const gridStyles: string[] = [];

for (let i = 0; i < rule.style.length; i++) {
const styleName = rule.style[i];
if (styleName.startsWith('grid-template')) {
gridStyles.push(
`${styleName}: ${rule.style.getPropertyValue(styleName)}`,
);
}
}
parts.splice(parts.length - 1, 0, gridStyles.join('; '));
return parts.join('; ');
}
return rule.cssText;
}

export function stringifyRule(rule: CSSRule, sheetHref: string | null): string {
if (isCSSImportRule(rule)) {
let importStringified;
Expand All @@ -222,9 +182,6 @@ export function stringifyRule(rule: CSSRule, sheetHref: string | null): string {
// see https://bugs.webkit.org/show_bug.cgi?id=184604
ruleStringified = fixSafariColons(ruleStringified);
}
if (isCSSStyleRule(rule)) {
ruleStringified = replaceChromeGridTemplateAreas(rule);
}
if (sheetHref) {
return absolutifyURLs(ruleStringified, sheetHref);
}
Expand Down

0 comments on commit 5a0cb20

Please sign in to comment.