You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
821 B
25 lines
821 B
2 years ago
|
import { DomUtil } from 'leaflet';
|
||
|
function splitClassName(className) {
|
||
|
return className.split(' ').filter(Boolean);
|
||
|
}
|
||
|
export function addClassName(element, className) {
|
||
|
splitClassName(className).forEach((cls)=>{
|
||
|
DomUtil.addClass(element, cls);
|
||
|
});
|
||
|
}
|
||
|
export function removeClassName(element, className) {
|
||
|
splitClassName(className).forEach((cls)=>{
|
||
|
DomUtil.removeClass(element, cls);
|
||
|
});
|
||
|
}
|
||
|
export function updateClassName(element, prevClassName, nextClassName) {
|
||
|
if (element != null && nextClassName !== prevClassName) {
|
||
|
if (prevClassName != null && prevClassName.length > 0) {
|
||
|
removeClassName(element, prevClassName);
|
||
|
}
|
||
|
if (nextClassName != null && nextClassName.length > 0) {
|
||
|
addClassName(element, nextClassName);
|
||
|
}
|
||
|
}
|
||
|
}
|