UNPKG

tsdom

Version:

Fast, lightweight JavaScript DOM manipulation utility

27 lines (20 loc) 489 B
/* ----------------------------------- * * hasClass * * -------------------------------- */ function hasClass(el: HTMLElement, str: string) { let result = false; const value = ` ${str} `; const clean = ` ${el.className} `.replace(/[\n\t]/g, ' '); if (clean.indexOf(value) > -1) { result = true; } return result; } /* ----------------------------------- * * Export * * -------------------------------- */ export { hasClass };