back to catalog
DOMNodeInserted callback是同步执行的
DOMNodeInserted 是一个W3C DOM Level 3 Events, 已经被废弃;应该优先选用Mutation Observers (W3C DOM Level 4 Events)
    
      console.log('start')
      let count = 0
      const dom = document.getElementById('container')
      dom.addEventListener('DOMNodeInserted', () => {
        count++;
        console.log('DOMNodeInserted callback', count)
      })

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