luci-base: forms.js safe call on this.map.data.remove()
authorSergey Ponomarev <[email protected]>
Tue, 25 Feb 2025 21:31:15 +0000 (23:31 +0200)
committerPaul Donald <[email protected]>
Wed, 26 Feb 2025 04:08:12 +0000 (22:08 -0600)
Signed-off-by: Sergey Ponomarev <[email protected]>
modules/luci-base/htdocs/luci-static/resources/form.js

index 2d0304003cd75e30c4dbd7c7d2319a340465e144..c9af17f1b37e1e71fa3610c3d0d8895d9b2332d8 100644 (file)
@@ -2219,7 +2219,7 @@ const CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSect
        handleRemove(section_id, ev) {
                const config_name = this.uciconfig ?? this.map.config;
 
-               this.map.data.remove(config_name, section_id);
+               this.map.data?.remove(config_name, section_id);
                return this.map.save(null, true);
        },
 
@@ -3391,7 +3391,7 @@ const CBIGridSection = CBITableSection.extend(/** @lends LuCI.form.GridSection.p
                const prevMap = mapNode ? dom.findClassInstance(mapNode) : this.map;
 
                if (prevMap.addedSection != null && !isSaving)
-                       this.map.data.remove(config_name, prevMap.addedSection);
+                       this.map.data?.remove(config_name, prevMap.addedSection);
 
                delete prevMap.addedSection;
 
@@ -3550,7 +3550,7 @@ const CBINamedSection = CBIAbstractSection.extend(/** @lends LuCI.form.NamedSect
                const section_id = this.section;
                const config_name = this.uciconfig ?? this.map.config;
 
-               this.map.data.remove(config_name, section_id);
+               this.map.data?.remove(config_name, section_id);
                return this.map.save(null, true);
        },