              from_box.name = from_box.name + '_old';
  
              // Set up the JavaScript event handlers for the select box filter interface
              var move_selection = function(e, elem, move_func, from, to) {
                  if (elem.className.indexOf('active') !== -1) {
                      move_func(from, to);
                      SelectFilter.refresh_icons(field_id);
                  }
                  e.preventDefault();
              };
 
</s> remove                 if (ps[i].className.indexOf("info") !== -1) {
 </s> add                 if (ps[i].classList.contains("info")) { </s> remove                 } else if (ps[i].className.indexOf("help") !== -1) {
 </s> add                 } else if (ps[i].classList.contains("help")) { </s> remove         element.className += " type-active";
 </s> add         element.classList.add("type-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) {
                if (elem.classList.contains('active')) {
              from_box.name = from_box.name + '_old';
  
              // Set up the JavaScript event handlers for the select box filter interface
              var move_selection = function(e, elem, move_func, from, to) {
                if (elem.classList.contains('active')) {
                      move_func(from, to);
                      SelectFilter.refresh_icons(field_id);
                  }
                  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/admin/static/admin/js/SelectFilter2.js