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.
24 lines
821 B
24 lines
821 B
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); |
|
} |
|
} |
|
}
|
|
|