Skip to content Skip to sidebar Skip to footer

What Is The New Equivalent Of Domnodeinserted?

The DOMNodeInserted event has been deprecated and all Mutation Events have been replaced with mutation observers. But, within mutation observers there are only config options for w

Solution 1:

I don't really consider this to be the answer to the question, but I'd like to share it anyways because it's better than nothing.

This question has some good answers: What is the most efficient way of detecting when an element with a particular ID is inserted in the DOM

In particular, this answer: https://stackoverflow.com/a/25107064/4808079 from schettino72

iframe elements trigger load/unoad events. You can insert a dumb iframe in the element you want to watch... And trigger a 'load' event in the original element yourself.

functionwatch($ele){
    var$iframe = document.createElement('iframe');
    $iframe.style.display = 'none';
    $ele.appendChild($iframe);
    $iframe.addEventListener('load', function(){
      var event = new CustomEvent('load');
      $ele.dispatchEvent(event);
    });
}

I would still like to keep this question open as this is a hack and not a true answer. DOMNodeInserted was probably not deprecated so everyone could do it this way instead.

Post a Comment for "What Is The New Equivalent Of Domnodeinserted?"