Compact style mutation fixes and improvements#1268
Merged
eoghanmurray merged 12 commits intorrweb-io:masterfrom Aug 3, 2023
Merged
Compact style mutation fixes and improvements#1268eoghanmurray merged 12 commits intorrweb-io:masterfrom
eoghanmurray merged 12 commits intorrweb-io:masterfrom
Conversation
🦋 Changeset detectedLatest commit: 671b321 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
9a65c18 to
5c674f4
Compare
…on the string length before choosing which format to go for
- this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property
- before this change background:black; was getting expaned to 10 OM properties as follows:
'style': {
'background-color': 'black',
'background-image': false,
'background-position-x': false,
'background-position-y': false,
'background-size': false,
'background-repeat-x': false,
'background-repeat-y': false,
'background-attachment': false,
'background-origin': false,
'background-clip': false
}
5c674f4 to
1d0bb07
Compare
Juice10
reviewed
Aug 3, 2023
Member
Juice10
left a comment
There was a problem hiding this comment.
Great stuff @eoghanmurray and @okeminja!
I had a few tweaks for clarity, and I've spotted a potential bug, but overall this PR looks great!
Use neater object destructuring Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
prefer waitForRAF Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
frontload comment explaining what's going on here in terms of the 'var(' string check
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
Juice10
approved these changes
Aug 3, 2023
Juice10
reviewed
Aug 3, 2023
eoghanmurray
added a commit
to eoghanmurray/rrweb
that referenced
this pull request
Aug 3, 2023
* Don't use the CSSOM when there's `var()` present as it fails badly rrweb-io#1246 * As the CSS Object Model expands out shorthand properties, do a check on the string length before choosing which format to go for - this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property - before this change background:black; was getting expaned to 10 OM properties as follows: 'style': { 'background-color': 'black', 'background-image': false, 'background-position-x': false, 'background-position-y': false, 'background-size': false, 'background-repeat-x': false, 'background-repeat-y': false, 'background-attachment': false, 'background-origin': false, 'background-clip': false } * Updates to remainder of tests based on refined compact style mutations * Apply suggestions from code review by: Justin Halsall <Juice10@users.noreply.github.com> --------- Authored-by: eoghanmurray <eoghan@getthere.ie>
billyvg
pushed a commit
to getsentry/rrweb
that referenced
this pull request
Aug 7, 2023
* Don't use the CSSOM when there's `var()` present as it fails badly rrweb-io#1246 * As the CSS Object Model expands out shorthand properties, do a check on the string length before choosing which format to go for - this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property - before this change background:black; was getting expaned to 10 OM properties as follows: 'style': { 'background-color': 'black', 'background-image': false, 'background-position-x': false, 'background-position-y': false, 'background-size': false, 'background-repeat-x': false, 'background-repeat-y': false, 'background-attachment': false, 'background-origin': false, 'background-clip': false } * Updates to remainder of tests based on refined compact style mutations * Apply suggestions from code review by: Justin Halsall <Juice10@users.noreply.github.com> --------- Authored-by: eoghanmurray <eoghan@getthere.ie>
eoghanmurray
added a commit
to eoghanmurray/rrweb
that referenced
this pull request
Aug 8, 2023
* Don't use the CSSOM when there's `var()` present as it fails badly rrweb-io#1246 * As the CSS Object Model expands out shorthand properties, do a check on the string length before choosing which format to go for - this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property - before this change background:black; was getting expaned to 10 OM properties as follows: 'style': { 'background-color': 'black', 'background-image': false, 'background-position-x': false, 'background-position-y': false, 'background-size': false, 'background-repeat-x': false, 'background-repeat-y': false, 'background-attachment': false, 'background-origin': false, 'background-clip': false } * Updates to remainder of tests based on refined compact style mutations * Apply suggestions from code review by: Justin Halsall <Juice10@users.noreply.github.com> --------- Authored-by: eoghanmurray <eoghan@getthere.ie>
eoghanmurray
added a commit
to eoghanmurray/rrweb
that referenced
this pull request
Aug 8, 2023
* Don't use the CSSOM when there's `var()` present as it fails badly rrweb-io#1246 * As the CSS Object Model expands out shorthand properties, do a check on the string length before choosing which format to go for - this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property - before this change background:black; was getting expaned to 10 OM properties as follows: 'style': { 'background-color': 'black', 'background-image': false, 'background-position-x': false, 'background-position-y': false, 'background-size': false, 'background-repeat-x': false, 'background-repeat-y': false, 'background-attachment': false, 'background-origin': false, 'background-clip': false } * Updates to remainder of tests based on refined compact style mutations * Apply suggestions from code review by: Justin Halsall <Juice10@users.noreply.github.com> --------- Authored-by: eoghanmurray <eoghan@getthere.ie>
Contributor
Author
|
This is the spec issue for reference, however this patch can still stand even if it's later fixed in browsers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1): CSSOM was failing badly with shorthand + variables as reported in #1246 e.g. in
the resultant mutation had no record of the variable. This is a deficiency in the spec for CSSOM as evidenced here:
https://bugs.chromium.org/p/chromium/issues/detail?id=1218159#c_ts1631714802
In this case we can fallback to the regular method before style attributes were special cased in #464, and which is still supported in replay.
2): I realized we can switch between the #464 method and the regular attribute method for a given mutation depending on which is longer. This prevents us converting the following:
to the much more verbose:
Whilst still preserving those cases where the #464 method is more terse. We achieve this by executing both methods and comparing string lengths of the two methods.
Comparison of the two methods upon emission is also the way we verify that the variable functions are being preserved.