소스 검색

Replace `addClass` with `classList.add` (#6229)

This replaces jQuery's `addClass` function with the vanilla JavaScript
`classList.add`.
Petrik de Heus 2 년 전
부모
커밋
8bdafc3644
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 1
      src/js/select2/dropdown/dropdownCss.js
  2. 5 1
      src/js/select2/selection/selectionCss.js

+ 5 - 1
src/js/select2/dropdown/dropdownCss.js

@@ -14,7 +14,11 @@ define([
       Utils.copyNonInternalCssClasses($dropdown[0], this.$element[0]);
     }
 
-    $dropdown.addClass(dropdownCssClass);
+    dropdownCssClass.trim().split(' ').forEach(function(cssClass) {
+      if(cssClass.length > 0) {
+        $dropdown[0].classList.add(cssClass);
+      }
+    });
 
     return $dropdown;
   };

+ 5 - 1
src/js/select2/selection/selectionCss.js

@@ -14,7 +14,11 @@ define([
       Utils.copyNonInternalCssClasses($selection[0], this.$element[0]);
     }
 
-    $selection.addClass(selectionCssClass);
+    selectionCssClass.trim().split(' ').forEach(function(cssClass) {
+      if(cssClass.length > 0) {
+        $selection[0].classList.add(cssClass);
+      }
+    });
 
     return $selection;
   };