src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js
function (href) {
                var self = this;


                // Inspect CSSRules for @imports:
                // styleSheet obejct is required to scan CSSImportRules but
                // browsers differ on the implementation of MutationObserver interface.
                // Webkit triggers notifications before stylesheets are loaded,
                // Firefox does it after loading.
                // There are also differences on when 'load' event is triggered for
                // the 'link' nodes. Webkit triggers it before stylesheet is loaded.
                // Some references to check:
                //      http://www.phpied.com/when-is-a-stylesheet-really-loaded/
                //      http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load
                //        http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events
                //
                // TODO: This is just a temporary 'cross-browser' solution, it needs optimization.
                var loadInterval = setInterval(function () {
                    var i;
                    for (i = 0; i < window.document.styleSheets.length; i++) {
                        if (window.document.styleSheets[i].href === href) {
                            //clear interval
                            clearInterval(loadInterval);
                            // notify stylesheets added
                            self.notifyStylesheetAdded(href);
                            break;
                        }
                    }
                }, 50);
            }
function (href) {
                var self = this;


                // Inspect CSSRules for @imports:
                // styleSheet obejct is required to scan CSSImportRules but
                // browsers differ on the implementation of MutationObserver interface.
                // Webkit triggers notifications before stylesheets are loaded,
                // Firefox does it after loading.
                // There are also differences on when 'load' event is triggered for
                // the 'link' nodes. Webkit triggers it before stylesheet is loaded.
                // Some references to check:
                //      http://www.phpied.com/when-is-a-stylesheet-really-loaded/
                //      http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load
                //        http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events
                //
                // TODO: This is just a temporary 'cross-browser' solution, it needs optimization.
                var loadInterval = setInterval(function () {
                    var i;
                    for (i = 0; i < window.document.styleSheets.length; i++) {
                        if (window.document.styleSheets[i].href === href) {
                            //clear interval
                            clearInterval(loadInterval);
                            // notify stylesheets added
                            self.notifyStylesheetAdded(href);
                            break;
                        }
                    }
                }, 50);
            }
function ( href ) { var self = this ; // Inspect CSSRules for @imports: // styleSheet obejct is required to scan CSSImportRules but // browsers differ on the implementation of MutationObserver interface. // Webkit triggers notifications before stylesheets are loaded, // Firefox does it after loading. // There are also differences on when 'load' event is triggered for // the 'link' nodes. Webkit triggers it before stylesheet is loaded. // Some references to check: //      http://www.phpied.com/when-is-a-stylesheet-really-loaded/ //      http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load //        http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events // // TODO: This is just a temporary 'cross-browser' solution, it needs optimization. var loadInterval = setInterval ( function ( ) { var i ; for ( i = 0 ; i < window . document . styleSheets . length ; i ++ ) { if ( window . document . styleSheets [ i ] . href === href ) { //clear interval clearInterval ( loadInterval ) ; // notify stylesheets added self . notifyStylesheetAdded ( href ) ; break ; } } } , 50 ) ; }
Check the stylesheet that was just added be really loaded
to be able to extract potential import-ed stylesheets.
It invokes notifyStylesheetAdded once the sheet is loaded.
@param  {string} href Absolute URL of the stylesheet.
Check the stylesheet that was just added be really loaded to be able to extract potential import - ed stylesheets . It invokes notifyStylesheetAdded once the sheet is loaded .