fix(snapshot): dimensions for blocked element not being applied (#1331)

fix for replay of a blocked element when using 'fast forward' (rrdom)

 - Dimensions were not being properly applied when you seek to a position in the replay. Need to use `setProperty` rather than trying to set the width/height directly
This commit is contained in:
Billy Vong
2026-04-01 12:00:00 +08:00
committed by GitHub
parent dee8d684fd
commit f664e6478b
4 changed files with 61 additions and 2 deletions

View File

@@ -328,9 +328,9 @@ function buildNode(
}
if (name === 'rr_width') {
(node as HTMLElement).style.width = value.toString();
(node as HTMLElement).style.setProperty('width', value.toString());
} else if (name === 'rr_height') {
(node as HTMLElement).style.height = value.toString();
(node as HTMLElement).style.setProperty('height', value.toString());
} else if (
name === 'rr_mediaCurrentTime' &&
typeof value === 'number'

View File

@@ -72,6 +72,32 @@ describe('rebuild', function () {
});
});
describe('rr_width/rr_height', function () {
it('rebuild blocked element with correct dimensions', function () {
const node = buildNodeWithSN(
{
id: 1,
tagName: 'svg',
type: NodeType.Element,
isSVG: true,
attributes: {
rr_width: '50px',
rr_height: '50px',
},
childNodes: [],
},
{
doc: document,
mirror,
hackCss: false,
cache,
},
) as HTMLDivElement;
expect(node.style.width).toBe('50px');
expect(node.style.height).toBe('50px');
});
});
describe('shadowDom', function () {
it('rebuild shadowRoot without siblings', function () {
const node = buildNodeWithSN(