Skip to content

Commit 447d765

Browse files
committed
Administration: Prevent race condition in wp-tooltip.js delay timer.
Move the timer variable `openTimeout` from the outer scope of the wrapper function to the inner scope, preventing reuse of the same timer instance by different tooltips. Props fahimmurshed, westonruter, joedolson. Fixes #65674. git-svn-id: https://develop.svn.wordpress.org/trunk@63549 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e075d86 commit 447d765

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/js/_enqueues/wp/wp-tooltip.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
const popovers = /** @type {NodeListOf<HTMLSpanElement>} */ ( document.querySelectorAll( '.wp-is-tooltip' ) );
1818

19-
/** @type {ReturnType<typeof setTimeout>} */
20-
let openTimeout;
21-
2219
popovers.forEach( function( popover ) {
2320
const trigger = /** @type {HTMLButtonElement|HTMLAnchorElement|null} */ ( popover.querySelector( '.wp-tooltip__toggle' ) );
2421
const panel = /** @type {HTMLSpanElement|null} */ ( popover.querySelector( 'span.wp-tooltip__bubble' ) );
@@ -31,6 +28,9 @@
3128
return;
3229
}
3330

31+
/** @type {ReturnType<typeof setTimeout>} */
32+
let openTimeout;
33+
3434
// Show Tooltip Function (with delay to prevent flickering).
3535
const showTooltip = () => {
3636
clearTimeout( openTimeout );

0 commit comments

Comments
 (0)