improve: some websites rebuild imcomplete (#1163)
* improve: mutation.ts, loop use Set replace Array * improve: add a try-catch to utils.ts to make it robust * Create yellow-mails-cheat.md --------- Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
This commit is contained in:
8
.changeset/yellow-mails-cheat.md
Normal file
8
.changeset/yellow-mails-cheat.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
'rrweb': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: some websites rebuild imcomplete
|
||||||
|
|
||||||
|
1. Some websites, addedSet in emit function is not empty, but the result converted from Array.from is empty.
|
||||||
|
2. Some websites polyfill classList functions of HTML elements. Their implementation may throw errors and cause the snapshot to fail. I add try-catch statements to make the code robust.
|
||||||
@@ -333,7 +333,7 @@ export default class MutationBuffer {
|
|||||||
this.mirror.removeNodeFromMap(this.mapRemoves.shift()!);
|
this.mirror.removeNodeFromMap(this.mapRemoves.shift()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const n of Array.from(this.movedSet.values())) {
|
for (const n of this.movedSet) {
|
||||||
if (
|
if (
|
||||||
isParentRemoved(this.removes, n, this.mirror) &&
|
isParentRemoved(this.removes, n, this.mirror) &&
|
||||||
!this.movedSet.has(n.parentNode!)
|
!this.movedSet.has(n.parentNode!)
|
||||||
@@ -343,7 +343,7 @@ export default class MutationBuffer {
|
|||||||
pushAdd(n);
|
pushAdd(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const n of Array.from(this.addedSet.values())) {
|
for (const n of this.addedSet) {
|
||||||
if (
|
if (
|
||||||
!isAncestorInSet(this.droppedSet, n) &&
|
!isAncestorInSet(this.droppedSet, n) &&
|
||||||
!isParentRemoved(this.removes, n, this.mirror)
|
!isParentRemoved(this.removes, n, this.mirror)
|
||||||
|
|||||||
@@ -229,11 +229,15 @@ export function isBlocked(
|
|||||||
: node.parentElement;
|
: node.parentElement;
|
||||||
if (!el) return false;
|
if (!el) return false;
|
||||||
|
|
||||||
if (typeof blockClass === 'string') {
|
try {
|
||||||
if (el.classList.contains(blockClass)) return true;
|
if (typeof blockClass === 'string') {
|
||||||
if (checkAncestors && el.closest('.' + blockClass) !== null) return true;
|
if (el.classList.contains(blockClass)) return true;
|
||||||
} else {
|
if (checkAncestors && el.closest('.' + blockClass) !== null) return true;
|
||||||
if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
|
} else {
|
||||||
|
if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// e
|
||||||
}
|
}
|
||||||
if (blockSelector) {
|
if (blockSelector) {
|
||||||
if (el.matches(blockSelector)) return true;
|
if (el.matches(blockSelector)) return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user