1window['widgetLoaderComponents'] = []; 2 3// Callback function to execute when mutations are observed and if subtree/childlist change we remove ghosting 4const widgetLoadingCompleteCallback = (mutationList, observer) => { 5 for (const mutation of mutationList) { 6 if (mutation.type === "childList") { 7 document.removeChild(mutation.target); 8 observer.disconnect(); 9 } else if (mutation.type === "subtree") { 10 document.removeChild(mutation.target); 11 observer.disconnect(); 12 } 13 } 14 15}; 16 17/* Adding mutation observer to check if react component started rendering on dom 18/* We need to removed ghosting div in callback */ 19var addMutationObserver = function(widgetLoaderConfig){ 20 if(document.getElementById(widgetLoaderConfig.widgetRenderId + "_ghosting")){ 21 const targetNode = document.getElementById(widgetLoaderConfig.widgetRenderId + "_ghosting"); 22 const config = {childList: true, subtree: true }; 23 24 // Create an observer instance linked to the callback function 25 const observer = new MutationObserver(widgetLoadingCompleteCallback); 26 27 // Start observing the target node for configured mutations 28 observer.observe(targetNode, config); 29 } 30}; 31 32removeGhosting = function(widgetRenderId){ 33 if(document.getElementById(widgetRenderId + "_ghosting")){ 34 document.getElementById(widgetRenderId + "_ghosting").remove(); 35 } 36} 37var makeWidgetCall = function(widgetName, widgetConfig) { 38 try 39 { 40 window["widget-loader"].get(widgetName).then((widget) => { 41 widget(widgetConfig); 42 }).catch(function(e) { 43 console.error(e); 44 removeGhosting(widgetConfig.widgetRenderId); 45 }); 46 } catch(er){ 47 console.error("Got error while loading widget, removing ghosting", er); 48 removeGhosting(widgetConfig.widgetRenderId); 49 } 50}; 51 52window.onload = function() { 53 if(Array.isArray(window['widgetLoaderComponents'])) { 54 window['widgetLoaderComponents'].forEach(widgetLoaderConfig => { 55 addMutationObserver(widgetLoaderConfig); 56 makeWidgetCall(widgetLoaderConfig.widgetName, widgetLoaderConfig); 57 }); 58 } 59};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.