luci-mod-network: gracefully handle empty channel lists
authorJo-Philipp Wich <[email protected]>
Thu, 27 Oct 2022 14:08:11 +0000 (16:08 +0200)
committerJo-Philipp Wich <[email protected]>
Thu, 27 Oct 2022 14:13:47 +0000 (16:13 +0200)
Avoid undefined value access when the channel list is empty.

Fixes: #5937, #5951
Signed-off-by: Jo-Philipp Wich <[email protected]>
(cherry picked from commit 9af8486517e87eea837fbce0ce787fc89ab46627)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js

index eca35d3c1a8362ef9438a0f8f237e3d24f98ddf2..9fbc66039090305078aea2212ec4198f8fab89f7 100644 (file)
@@ -480,7 +480,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
                this.toggleWifiBand(elem);
 
                bwdt.value = htval;
-               chan.value = chval || chan.options[0].value;
+               chan.value = chval || (chan.options[0] ? chan.options[0].value : 'auto');
 
                return elem;
        },