-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: do not throw on empty cdata #1702
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
base: master
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR prevents playback failures caused by empty CDATA sections by returning null instead of creating a CDATA node when the text content is empty.
- Avoid throwing errors on empty CDATA
- Add a conditional check to bypass CDATA creation for empty content
Comments suppressed due to low confidence (1)
packages/rrweb-snapshot/src/rebuild.ts:435
- Ensure that returning null for empty CDATA is safely handled by the calling code. Consider adding a comment or test to verify that null values are appropriately processed to prevent unintended behavior downstream.
if (n.textContent.trim() === '') {
Do you mean that the content didn't get recorded at all? |
@@ -432,6 +432,9 @@ function buildNode( | |||
} | |||
return doc.createTextNode(n.textContent); | |||
case NodeType.CDATA: | |||
if (n.textContent.trim() === '') { | |||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest warning here before return
Dropped this here as a reminder to self before PTO. Will add detail when
I'm back!
…On Fri, 13 Jun 2025, 16:58 Eoghan Murray, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/rrweb-snapshot/src/rebuild.ts
<#1702 (comment)>:
> @@ -432,6 +432,9 @@ function buildNode(
}
return doc.createTextNode(n.textContent);
case NodeType.CDATA:
+ if (n.textContent.trim() === '') {
+ return null;
Suggest warning here before return
—
Reply to this email directly, view it on GitHub
<#1702 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHQN4KZLDXH7CTQ3GZX6O33DLRJ3AVCNFSM6AAAAAB65XKHZGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMRVGEZTINBUGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
we had a customer whose SVGs are created with styling provided in CDATA tags
these ended up in replay with empty text content and would throw in the player, making the entire recording unplayable
we should be able to record them, but, for now, at least to not fail when we try to playback