From f1fbb9d07eef551b6a1a765173c31a43a96fae33 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Fri, 21 Dec 2018 14:31:19 +0800 Subject: [PATCH] safely scroll element since its last event may fired after being removed --- src/replay/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index d853ebd6..d678ca8e 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -1,4 +1,4 @@ -import { rebuild, buildNodeWithSN } from 'rrweb-snapshot'; +import { rebuild, buildNodeWithSN, INode } from 'rrweb-snapshot'; import * as mittProxy from 'mitt'; import Timer from './timer'; import { @@ -422,8 +422,15 @@ export class Replayer { behavior: isSync ? 'instant' : 'smooth', }); } else { - (target as Element).scrollTop = d.y; - (target as Element).scrollLeft = d.x; + try { + (target as Element).scrollTop = d.y; + (target as Element).scrollLeft = d.x; + } catch (error) { + /** + * Seldomly we may found scroll target was removed before + * its last scroll event. + */ + } } break; }