5

I get this message when loading a typical page on my browser:

Use of Mutation Events is deprecated. Use MutationObserver instead.

Line Number where this message happens to be thrown is given as: jquery-3.2.1.js:5062:6

Looking at jQuery source, this is the code it contains, where the offending line is elem.addEventListener( type, eventHandle );

// Init the event handler queue if we're the first
if ( !( handlers = events[ type ] ) ) {
    handlers = events[ type ] = [];
    handlers.delegateCount = 0;

    // Only use addEventListener if the special events handler returns false
    if ( !special.setup ||
        special.setup.call( elem, data, namespaces, eventHandle ) === false ) {

        if ( elem.addEventListener ) {
            elem.addEventListener( type, eventHandle );
            # ^^^^^ the line that throws the Mutation Observer message
        }
    }
}

How do I find out the code responsible for triggering this message?

Dennis
  • 7,907
  • 11
  • 65
  • 115
  • It's likely due to a third-party library using the deprecated events. See http://stackoverflow.com/q/19965211/215552, http://stackoverflow.com/q/18223315/215552, many others. I just searched on that error message and found those two. – Heretic Monkey May 18 '17 at 14:03
  • The error says your code uses obsolete [DOM mutation events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events). – wOxxOm May 19 '17 at 02:42
  • 1
    This seems like deja vu... Do a search of your code base (and those of the plugins you're using, etc.) looking for a [mutation event name](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events#Mutation_events_list) (e.g., "DOMAttrModified"). – Heretic Monkey Jul 25 '18 at 20:50
  • I found the offending line. Goes something like this: `$('#main').on('DOMNodeInserted', function() {load_ui_globals();});` – Dennis Jul 25 '18 at 20:58

1 Answers1

5

Per comments under the question:

Search your codebase for the deprecated DOM events, i.e the regex of:

DOMAttrModified|DOMAttributeNameChanged|DOMCharacterDataModified|DOMElementNameChanged|DOMNodeInserted|DOMNodeInsertedIntoDocument|DOMNodeRemoved|DOMNodeRemovedFromDocument|DOMSubtreeModified

It will show you offending lines that trigger deprecated events.

Dennis
  • 7,907
  • 11
  • 65
  • 115