Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. if (!("classList" in SVGElement.prototype)) {
  2. Object.defineProperty(SVGElement.prototype, "classList", {
  3. get() {
  4. return {
  5. contains: className => {
  6. return this.className.baseVal.split(" ").indexOf(className) !== -1;
  7. },
  8. add: className => {
  9. return this.setAttribute('class', this.getAttribute('class') + ' ' + className);
  10. },
  11. remove: className => {
  12. var removedClass = this.getAttribute('class').replace(new RegExp('(\\s|^)' + className + '(\\s|$)', 'g'), '$2');
  13. if (this.classList.contains(className)) {
  14. this.setAttribute('class', removedClass);
  15. }
  16. }
  17. };
  18. }
  19. });
  20. }
Add Comment
Please, Sign In to add comment