From fb183bc6c62f29d1d73a8f6ca9a1275a44db7c66 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 15 Sep 2016 10:04:16 +0530 Subject: [PATCH] A spot of refactoring --- src/pyj/dom.pyj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pyj/dom.pyj b/src/pyj/dom.pyj index 7fb731b54b..e90fd65668 100644 --- a/src/pyj/dom.pyj +++ b/src/pyj/dom.pyj @@ -92,14 +92,17 @@ def element(elem_id, child_selector): ans = ans.querySelector(child_selector) return ans +def unique_id(): + unique_id.count += 1 + return 'auto-id-' + unique_id.count +unique_id.count = 0 + def ensure_id(w): ans = w.getAttribute('id') if not ans: - ensure_id.count += 1 - ans = 'auto-id-' + ensure_id.count + ans = unique_id() w.setAttribute('id', ans) return ans -ensure_id.count = 0 extra_css = v'[]' @@ -108,4 +111,3 @@ def add_extra_css(func): def get_widget_css(): return extra_css.join('\n') -