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?
source to share
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.
source to share