-
Notifications
You must be signed in to change notification settings - Fork 144
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 dynamic style serialization #2397
🐛 fix dynamic style serialization #2397
Conversation
Some tests were incorrectly labeled and hard to grasp. This commit improves a bit, and adds a test on how style element containing text are currently serialized.
Previously, we serialized the <style> element state (as reflected by its associated StyleSheet object) only if the element was empty / did not have children. This is an issue when the recording starts after a non-empty <style> element is edited via `insertRule`/`deleteRule`, as doing so only changes the <style> element state and not its children, so changes were ignored. This commit fixes this issue by always serializing the <style> element state.
Because the <style> state is now always serialized in the _cssText attribute, providing children is not useful and implies sending the CSS text twice in some cases.
When serializing text nodes, there is no need to check whether the parent element is a <style> since we don't serialize <style> element children anymore. The `isStyle` property on the `TextNode` interface is kept for backward compatibility but won't be defined for newer versions of the SDK.
/to-staging |
🚂 Branch Integration: starting soon, merge in < 0s commit 86f65b3ee4 will soon be integrated into staging-35. This build is going to start soon! (estimated merge in less than 0s) you can cancel this operation by commenting your pull request with |
🚂 Branch Integration: this commit was successfully integrated Commit 86f65b3ee4 has been merged into staging-35 in merge commit 4fd8de709b. Check out the triggered pipeline on Gitlab 🦊 |
Browsers are serializing some CSS rules slightly differently. Let's use CSS that is serialized the same every where.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2397 +/- ##
==========================================
- Coverage 93.99% 93.99% -0.01%
==========================================
Files 212 212
Lines 6298 6292 -6
Branches 1405 1399 -6
==========================================
- Hits 5920 5914 -6
Misses 378 378 ☔ View full report in Codecov by Sentry. |
83ae66a
to
703ba60
Compare
Motivation
See #2380. When a website uses a non-empty
<style>
element, edits it withinsertRule
ordeleteRule
, and then starts recording withstartSessionReplayRecording()
, changes made to the style are lost. Example:This behavior is inherited from rrweb which still has it. There is no justification on why this condition is here in the commit history.
Changes
<style>
element state (from its associated StyleSheet) when serializing it.<style>
element children anymoreisStyle
property on serialized text nodesThis change is compatible with the current implementation of the player.
Testing
I have gone over the contributing documentation.