From 4758ef1c406633af0848f74acf6e2a67d59dff00 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Thu, 7 Jul 2022 14:05:12 +0200 Subject: [PATCH] mirror change for `setTimeout` debounce This fixes a lot of issues with events as outlined in #3607 --- src/component.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/component.js b/src/component.js index c2043afd5a..010d3b96e8 100644 --- a/src/component.js +++ b/src/component.js @@ -170,17 +170,6 @@ function updateParentDomPointers(vnode) { */ let rerenderQueue = []; -/** - * Asynchronously schedule a callback - * @type {(cb: () => void) => void} - */ -/* istanbul ignore next */ -// Note the following line isn't tree-shaken by rollup cuz of rollup/rollup#2566 -const defer = - typeof Promise == 'function' - ? Promise.prototype.then.bind(Promise.resolve()) - : setTimeout; - /* * The value of `Component.debounce` must asynchronously invoke the passed in callback. It is * important that contributors to Preact can consistently reason about what calls to `setState`, etc. @@ -205,7 +194,7 @@ export function enqueueRender(c) { prevDebounce !== options.debounceRendering ) { prevDebounce = options.debounceRendering; - (prevDebounce || defer)(process); + (prevDebounce || setTimeout)(process); } }