TransWikia.com

characterData in mutation observer not working as expected

Stack Overflow Asked by raja pateriya on November 29, 2021

According to mutation observer documentation, characterData property is used to specify whether or not to monitor the node or nodes being observed for changes to their textual contents.

I have changed characterData to false in Config but still I am getting the callback when text is changed

Code Below:

 var CONFIG = {
    childList: true,
    attributes: false,
    characterData: false,
    subtree: true,
    attributeOldValue: false,
    characterDataOldValue: false
};
  var callback = function(mutationsList, observer) {      
    for (var i in mutationsList) {
        try {
            if (mutationsList[i].type === 'childList' && mutationsList[i].addedNodes.length && document.getElementById('abc')) {
                document.getElementById('abc').getElementsByTagName('span')[0].textContent = "changed text";
            }
        } catch (e) {
            
        }
    }
};

I am getting infinite callback in above code.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP