Guest User

Untitled

a guest
Oct 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. if (mutationObserver) mutationObserver.disconnect()
  2. var mutationObserver = new MutationObserver(function(mutations) {
  3. mutations.forEach(function(mutation) {
  4. if (mutation.addedNodes.length === 0 && mutation.removedNodes.length === 0 && mutation.attributeName === "class") {
  5. mutation.target.dispatchEvent(new CustomEvent('classChanged', {bubbles: true, detail: {}}))
  6. }
  7. })
  8. })
  9. mutationObserver.observe(document.documentElement, {attributes: true, subtree: true})
  10. function callback() {
  11. console.log(this, arguments)
  12. }
  13. var candidates = document.querySelectorAll('.candidate')
  14. for(var i = 0; i < candidates.length; i++) {
  15. candidates[i].addEventListener('classChanged', callback, false)
  16. }
Add Comment
Please, Sign In to add comment