Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chrome grid template #1586

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jaj1014
Copy link

@jaj1014 jaj1014 commented Oct 21, 2024

Add replaceChromeGridTemplateAreas utility function to fix grid-template-area styles that are improperly improperly parsed by Chrome into rule.cssText and causing broken recordings when attempting to play back.

Approach: rather than using regex to parse and manipulate the cssText directly (see original PR), we can check for when the cssText contains the grid issue and rebuild by iterating through rule.style: CSSStyleDeclaration collection and creating the string directly from the style declarations.

Link to chrome bug: https://issues.chromium.org/issues/40227336
Verified in Firefox and Safari that the issue does not exist. It doesn't try to convert to grid-template shorthand

Examples:

example declared styles 1:

image

example declared styles 2:

image

rule.cssText for above declared style examples:

// repeat 4 when there were actually 8
.floating-bars {
    grid-template: "bar1 bar2" repeat(4, 1fr) / 56rem 56rem 1fr 0px;
    content: "{}";
    display: grid;
    height: 100vh;
    gap: 0px;
}
// missing \"footer footer\"
.test-styles {
  display: grid;
  grid-template: \"header header\" \"aside main\" minmax(0px, 1fr) / 14.5em minmax(0px, 1fr);
}

fortunately, values in rule.style collection of CSSStyleDeclaration are correct, so we can use these to rebuild:

example1.style.getPropertyValue('grid-template-areas') === '"bar1 bar2" "bar1 bar2" "bar1 bar2" "bar1 bar2" "bar1 bar2" "bar1 bar2" "bar1 bar2" "bar1 bar2"'
example2.style.getPropertyValue('grid-template-areas') === '"header header" "aside main" "footer footer"'

jaj1014 and others added 2 commits October 18, 2024 15:05
…ate-area styles that are improperly improperly parsed by Chrome into rule.cssText and causing broken recordings when attempting to play back
Copy link

changeset-bot bot commented Oct 21, 2024

🦋 Changeset detected

Latest commit: fa25875

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb-snapshot Patch
rrweb Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jaj1014 jaj1014 changed the title Ajax fix chrome grid template Fix chrome grid template Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant