File tree 4 files changed +24
-3
lines changed
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " rrweb " : patch
3
+ ---
4
+
5
+ updating record and playback side to account for mutations where a node is missing a parent but it gets added in a different iteration of the mutation
Original file line number Diff line number Diff line change @@ -367,9 +367,11 @@ export default class MutationBuffer {
367
367
}
368
368
369
369
for ( const n of this . movedSet ) {
370
+ const parentNode = dom . parentNode ( n ) ;
370
371
if (
371
372
isParentRemoved ( this . removesSubTreeCache , n , this . mirror ) &&
372
- ! this . movedSet . has ( dom . parentNode ( n ) ! )
373
+ ! this . movedSet . has ( parentNode ! ) &&
374
+ ( ! this . addedSet . has ( parentNode ! ) )
373
375
) {
374
376
continue ;
375
377
}
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ import {
83
83
getPositionsAndIndex ,
84
84
uniqueTextMutations ,
85
85
StyleSheetMirror ,
86
+ type ResolveTree
86
87
} from '../utils' ;
87
88
import getInjectStyleRules from './styles/inject-style' ;
88
89
import './styles/style.css' ;
@@ -1707,6 +1708,18 @@ export class Replayer {
1707
1708
appendNode ( mutation ) ;
1708
1709
} ) ;
1709
1710
1711
+ const nodeIdsToBeAdded = ( resolveTrees : Array < ResolveTree > ) => {
1712
+ const ids = new Set ( ) ;
1713
+ for ( const tree of resolveTrees ) {
1714
+ ids . add ( tree . value . node . id ) ;
1715
+ if ( tree . children && tree . children . length > 0 ) {
1716
+ const res = nodeIdsToBeAdded ( tree . children ) ;
1717
+ res . forEach ( id => ids . add ( id ) ) ;
1718
+ }
1719
+ }
1720
+ return ids ;
1721
+ } ;
1722
+
1710
1723
const startTime = Date . now ( ) ;
1711
1724
while ( queue . length ) {
1712
1725
// transform queue to resolve tree
@@ -1721,7 +1734,8 @@ export class Replayer {
1721
1734
}
1722
1735
for ( const tree of resolveTrees ) {
1723
1736
const parent = mirror . getNode ( tree . value . parentId ) ;
1724
- if ( ! parent ) {
1737
+ const ids = nodeIdsToBeAdded ( resolveTrees ) ;
1738
+ if ( ! parent && ! ids . has ( tree . value . parentId ) ) {
1725
1739
this . debug (
1726
1740
'Drop resolve tree since there is no parent for the root node.' ,
1727
1741
tree ,
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ export function polyfill(win = window) {
333
333
}
334
334
}
335
335
336
- type ResolveTree = {
336
+ export type ResolveTree = {
337
337
value : addedNodeMutation ;
338
338
children : ResolveTree [ ] ;
339
339
parent : ResolveTree | null ;
You can’t perform that action at this time.
0 commit comments