From 45178e7fedafe30b6e28e82f769767b12aa9d45a Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 24 Feb 2021 14:56:34 -0800 Subject: [PATCH] vdom: Move update_attrs definition before use. Signed-off-by: Anders Kaseorg --- static/js/vdom.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/static/js/vdom.js b/static/js/vdom.js index 3f661013a3..a79e206a0c 100644 --- a/static/js/vdom.js +++ b/static/js/vdom.js @@ -55,6 +55,23 @@ exports.render_tag = (tag) => { return start_tag + "\n" + innards + "\n" + end_tag; }; +exports.update_attrs = (elem, new_attrs, old_attrs) => { + const new_dict = new Map(new_attrs); + const old_dict = new Map(old_attrs); + + for (const [k, v] of new_attrs) { + if (v !== old_dict.get(k)) { + elem.attr(k, v); + } + } + + for (const [k] of old_attrs) { + if (!new_dict.has(k)) { + elem.removeAttr(k); + } + } +}; + exports.update = (replace_content, find, new_dom, old_dom) => { /* The update method allows you to continually @@ -167,21 +184,4 @@ exports.update = (replace_content, find, new_dom, old_dom) => { exports.update_attrs(find(), new_opts.attrs, old_opts.attrs); }; -exports.update_attrs = (elem, new_attrs, old_attrs) => { - const new_dict = new Map(new_attrs); - const old_dict = new Map(old_attrs); - - for (const [k, v] of new_attrs) { - if (v !== old_dict.get(k)) { - elem.attr(k, v); - } - } - - for (const [k] of old_attrs) { - if (!new_dict.has(k)) { - elem.removeAttr(k); - } - } -}; - window.vdom = exports;