From f30328e40c92e84e9a14e0b49872c19de507d681 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Sun, 24 Nov 2019 22:33:45 +0800 Subject: [PATCH] close #143 tweak the code of iterating iterators Originally we use Array.from to transform iterator into array. But we found some framework may overwrite the Array.from with a pollyfill which was not implement correctly. --- src/record/observer.ts | 9 ++++++--- tsconfig.json | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/record/observer.ts b/src/record/observer.ts index 3d6642cb..4a426519 100644 --- a/src/record/observer.ts +++ b/src/record/observer.ts @@ -211,11 +211,11 @@ function initMutationObserver( }); }; - for (var it = movedSet.values(), n = null; (n = it.next().value); ) { + for (const n of movedSet) { pushAdd(n); } - for (var it = addedSet.values(), n = null; (n = it.next().value); ) { + for (const n of addedSet) { if (!isAncestorInSet(droppedSet, n) && !isParentRemoved(removes, n)) { pushAdd(n); } else if (isAncestorInSet(movedSet, n)) { @@ -281,7 +281,10 @@ function initMutationObserver( return observer; } -function initMoveObserver(cb: mousemoveCallBack, mousemoveWait: number): listenerHandler { +function initMoveObserver( + cb: mousemoveCallBack, + mousemoveWait: number, +): listenerHandler { let positions: mousePosition[] = []; let timeBaseline: number | null; const wrappedCb = throttle((isTouch: boolean) => { diff --git a/tsconfig.json b/tsconfig.json index d58ee546..32281a27 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "sourceMap": true, "rootDir": "src", "outDir": "build", - "lib": ["es6", "dom"] + "lib": ["es6", "dom"], + "downlevelIteration": true }, "compileOnSave": true, "exclude": ["test"],