How do I figure out what is causing the jQuery message "Using mutation events is deprecated. Use MutationObserver instead"?

I get this message when loading a normal page in my browser:

The use of mutation events is not recommended. Use MutationObserver instead.

The line number on which this message is issued looks like: jquery-3.2.1.js:5062:6

If you look at the jQuery source code, this is the code it contains, where the line with elem.addEventListener( type, eventHandle );

-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 can I find out the code responsible for triggering this message?

+3


source to share


2 answers


According to the comments in question:

Search your codebase for legacy DOM events i.e. regex:



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

It will show you offensive lines that trigger outdated events.

+3


source


We recently switched to jQuery 1.9, we started to notice this problem. Are you thinking of any reasons? We only face this problem in Firefox



0


source







All Articles