Last active
January 21, 2016 13:27
-
-
Save qetr1ck-op/33dee329fe69c13b20e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Let's get hold of those elements | |
| var outer = document.querySelector('#outer'); | |
| var inner = document.querySelector('#inner'); | |
| // Let's listen for attribute changes on the | |
| // outer element | |
| new MutationObserver(() => { | |
| console.log('mutate'); | |
| }).observe(outer, { | |
| attributes: true | |
| }); | |
| // Here's a click listener… | |
| function onClick() { | |
| console.log('click'); | |
| setTimeout(() => { | |
| console.log('timeout'); | |
| }, 0); | |
| Promise.resolve().then(() => { | |
| console.log('promise'); | |
| }); | |
| outer.setAttribute('data-random', Math.random()); | |
| } | |
| // attach handler to both elements | |
| inner.addEventListener('click', onClick); | |
| outer.addEventListener('click', onClick); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment