OSDN Git Service

luci-base: form.js: trim option description
authorJo-Philipp Wich <jo@mein.io>
Mon, 16 May 2022 14:12:01 +0000 (16:12 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 16 May 2022 14:12:01 +0000 (16:12 +0200)
If a whitespace-only description is set on an element, the CSS :empty
selector will not match, causing description icons to be shown when
there's no actual content.

To avoid that, trim the description string when building the element.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index 58f5a07..0802d8b 100644 (file)
@@ -3754,7 +3754,7 @@ var CBIValue = CBIAbstractValue.extend(/** @lends LuCI.form.Value.prototype */ {
 
                if (!in_table && typeof(this.description) === 'string' && this.description !== '')
                        dom.append(optionEl.lastChild || optionEl,
-                               E('div', { 'class': 'cbi-value-description' }, this.description));
+                               E('div', { 'class': 'cbi-value-description' }, this.description.trim()));
 
                if (depend_list && depend_list.length)
                        optionEl.classList.add('hidden');