Skip to content

Commit

Permalink
Replace addClass with classList.add (#6229)
Browse files Browse the repository at this point in the history
This replaces jQuery's `addClass` function with the vanilla JavaScript
`classList.add`.
  • Loading branch information
p8 committed Mar 2, 2023
1 parent bafba7b commit 8bdafc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/js/select2/dropdown/dropdownCss.js
Expand Up @@ -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;
};
Expand Down
6 changes: 5 additions & 1 deletion src/js/select2/selection/selectionCss.js
Expand Up @@ -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;
};
Expand Down

0 comments on commit 8bdafc3

Please sign in to comment.