From 25e9ed8227c2cadba1ae6707a16cc3291ed4d071 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Wed, 23 Oct 2024 01:08:16 -0400 Subject: [PATCH] dev: make el() yet more convenient --- src/gui/src/UI/UIElement.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/src/UI/UIElement.js b/src/gui/src/UI/UIElement.js index 14f66e2d..e376bb86 100644 --- a/src/gui/src/UI/UIElement.js +++ b/src/gui/src/UI/UIElement.js @@ -40,7 +40,12 @@ export default def(class UIElement extends AdvancedBase { const attrs = {}; for ( const a_or_c of a ) { - if ( Array.isArray(a_or_c) ) { + if ( typeof a_or_c === 'string' ) { + el.innerText += a_or_c; + } + else if ( a_or_c instanceof HTMLElement ) { + el.appendChild(a_or_c); + } if ( Array.isArray(a_or_c) ) { for ( const child of a_or_c ) { el.appendChild(child); }