  
      var element = document.createElement('div');
      element.className = 'switch-type type-' + options.type + ' ol-control ol-unselectable';
      if (options.active) {
          element.className += " type-active";
      }
  
      var self = this;
      var switchType = function(e) {
          e.preventDefault();
 
</s> remove             var className = options.widget.currentGeometryType.element.className.replace(/ type-active/g, '');
            options.widget.currentGeometryType.element.className = className;
 </s> add             options.widget.currentGeometryType.element.classList.remove('type-active'); </s> remove             element.className += " type-active";
 </s> add             element.classList.add("type-active"); </s> remove                 if (elem.className.indexOf('active') !== -1) {
 </s> add                 if (elem.classList.contains('active')) { </s> remove         if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
 </s> add         if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { </s> remove                 if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
 </s> add                 if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
        element.classList.add("type-active");
  
      var element = document.createElement('div');
      element.className = 'switch-type type-' + options.type + ' ol-control ol-unselectable';
      if (options.active) {
        element.classList.add("type-active");
      }
  
      var self = this;
      var switchType = function(e) {
          e.preventDefault();
keep keep keep keep replace keep keep keep keep keep
 Fixed #31028 -- Used classList API to check, add and remove DOM classes.

Thanks to Claude Paroz for review. 
django/contrib/gis/static/gis/js/OLMapWidget.js