From a1339d0d2d9dd72b49782e499318997b9dcb8a60 Mon Sep 17 00:00:00 2001 From: Mohammad Date: Fri, 17 Jan 2025 22:33:01 +0330 Subject: [PATCH] refactor(getUID): improve performance and simplify logic --- js/src/util/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/util/index.js b/js/src/util/index.js index c271cc5368ca..138325d9b9ff 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -5,7 +5,6 @@ * -------------------------------------------------------------------------- */ -const MAX_UID = 1_000_000 const MILLISECONDS_MULTIPLIER = 1000 const TRANSITION_END = 'transitionend' @@ -36,9 +35,10 @@ const toType = object => { * Public Util API */ +let idCount = 0 const getUID = prefix => { do { - prefix += Math.floor(Math.random() * MAX_UID) + prefix += idCount++ } while (document.getElementById(prefix)) return prefix