back to catalog
event trigger will not be combined before rendering

    let count = 0
    const dom = document.getElementById('container')

    var config = { attributes: true, childList: true, subtree: true };

    var callback = function(mutationsList, observer) {
        for(var mutation of mutationsList) {
            if (mutation.type == 'childList') {
                count++
                console.log('MutationObserver callback, count: ', count)
            }
            else if (mutation.type == 'attributes') {
                console.log('The ' + mutation.attributeName + ' attribute was modified.');
            }
        }
    };

    var observer = new MutationObserver(callback);

    observer.observe(dom, config);

    for(var i=0;i<5; i++) {
      const span = document.createElement('span')
      dom.appendChild(span)
      span.textContent = 'hello'
    }
    console.log('end')

    setTimeout(() => {
      // count: 10
      console.log('Stuff added to !', count)
      observer.disconnect();
    }, 3000)