Using MutationObserver, I am able to detect node insertion in a tree, however, it runs after the node is inserted.
If I need to trigger an event before the node is actually inserted, what steps should I take?
For example:
// create a new observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
// set up the observer configuration:
var config = { subtree: true };
// provide the target node for observation and the configuration options
observer.observe(document.documentElement, config);
Is there an equivalent of "BeforeDOMNodeInserted" similar to the "beforescriptexecute" listener found in Firefox?