fix(rrweb-snapshot): keep every attribute on an inlined img that has a srcset - #1938
Open
SaintPepsi wants to merge 3 commits into
Open
SaintPepsi wants to merge 3 commits into
SaintPepsi wants to merge 3 commits into
Conversation
…a srcset buildNode's srcset backup branch matched on the node (img with srcset and rr_dataURL) instead of the attribute (name === 'srcset'), so every attribute of such an img was routed into the backup and never set. The img rendered with no id, class, style or src. Introduced in rrweb-io#822. Co-Authored-By: Maple <ianhogers@hotmail.com>
This was referenced Sep 9, 2026
🦋 Changeset detectedLatest commit: 51a7cfc The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 |
@rrweb/all
@rrweb/browser-client
@rrweb/packer
@rrweb/record
@rrweb/replay
rrdom
rrdom-nodejs
rrvideo
rrweb
rrweb-player
rrweb-snapshot
@rrweb/types
@rrweb/utils
@rrweb/rrweb-plugin-canvas-webrtc-record
@rrweb/rrweb-plugin-canvas-webrtc-replay
@rrweb/rrweb-plugin-console-record
@rrweb/rrweb-plugin-console-replay
@rrweb/rrweb-plugin-network-record
@rrweb/rrweb-plugin-network-replay
@rrweb/rrweb-plugin-sequential-id-record
@rrweb/rrweb-plugin-sequential-id-replay
commit: |
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.
Fixes #1937.
Bug
buildNode()inrebuild.tshas one branch that backs upsrcsettorrweb-original-srcset. The condition checks the node (imgwithsrcsetandrr_dataURL) but not the attribute name. For such an img, every attribute in the loop enters that branch.alt,class,style,idandsizesare never set. Onlysrcsurvives, because therr_dataURLstep sets it later.Effect: responsive images (Next.js
<Image fill>, lazysizes) replay at natural size with no style. Present in 2.0.1, 2.1.4 andmain. Introduced in #822.Fix
Add
name === 'srcset'to the condition and drop the redundantn.attributes.srcsetcheck.Test
New case in
rebuild.test.ts: rebuild an img withid,alt,class,style,src,srcset,rr_dataURL. Assertsrcsetmoves torrweb-original-srcsetand the other attributes are kept.Without the fix:
With the fix,
packages/rrweb-snapshot:Live repro in rrwebdebug.com (two identical imgs, one with
srcset; bug: one red box, fixed: two): https://rrwebdebug.com/play/index.html?url=https%3A%2F%2Fgist.github.com%2FSaintPepsi%2F1aa63b3b23d690b987258fca4a21c632&version=2.0.1&virtual-dom=on&play=onChangeset:
rrweb-snapshotpatch.