processImportsIfLoadingDone() {
      // Wait until all resources are ready, then load import resources.
      if (this.inflight) {
        return;
      }

      // Stop observing, flatten & load resource, then restart observing <head>.
      this.dynamicImportsMO.disconnect();
      this.flatten(document);
      // We wait for styles to load, and at the same time we execute the scripts,
      // then fire the load/error events for imports to have faster whenReady
      // callback execution.
      // NOTE: This is different for native behavior where scripts would be
      // executed after the styles before them are loaded.
      // To achieve that, we could select pending styles and scripts in the
      // document and execute them sequentially in their dom order.
      let scriptsOk = false,
        stylesOk = false;
      const onLoadingDone = () => {
        if (stylesOk && scriptsOk) {
          // Restart observing.
          this.dynamicImportsMO.observe(document.head, {
            childList: true,
            subtree: true
          });
          this.fireEvents();
        }
      };
      this.waitForStyles(() => {
        stylesOk = true;
        onLoadingDone();
      });
      this.runScripts(() => {
        scriptsOk = true;
        onLoadingDone();
      });
    }
/**
     * Waits for loaded imports to finish loading scripts and styles, then fires
     * the load/error events.
     */
Waits for loaded imports to finish loading scripts and styles, then fires
the load/error events.
Waits for loaded imports to finish loading scripts and styles then fires the load / error events .
processImportsIfLoadingDone() {
      if (this.inflight) {
        return;
      }
      this.dynamicImportsMO.disconnect();
      this.flatten(document);
      let scriptsOk = false,
        stylesOk = false;
      const onLoadingDone = () => {
        if (stylesOk && scriptsOk) {
          this.dynamicImportsMO.observe(document.head, {
            childList: true,
            subtree: true
          });
          this.fireEvents();
        }
      };
      this.waitForStyles(() => {
        stylesOk = true;
        onLoadingDone();
      });
      this.runScripts(() => {
        scriptsOk = true;
        onLoadingDone();
      });
    }
processImportsIfLoadingDone ( ) { if ( this . inflight ) { return ; } this . dynamicImportsMO . disconnect ( ) ; this . flatten ( document ) ; let scriptsOk = false , stylesOk = false ; const onLoadingDone = ( ) => { if ( stylesOk && scriptsOk ) { this . dynamicImportsMO . observe ( document . head , { childList : true , subtree : true } ) ; this . fireEvents ( ) ; } } ; this . waitForStyles ( ( ) => { stylesOk = true ; onLoadingDone ( ) ; } ) ; this . runScripts ( ( ) => { scriptsOk = true ; onLoadingDone ( ) ; } ) ; }
Waits for loaded imports to finish loading scripts and styles, then fires
 the load/error events.
Waits for loaded imports to finish loading scripts and styles then fires the load / error events .
// Wait until all resources are ready, then load import resources. // Stop observing, flatten & load resource, then restart observing <head>. // We wait for styles to load, and at the same time we execute the scripts, // then fire the load/error events for imports to have faster whenReady // callback execution. // NOTE: This is different for native behavior where scripts would be // executed after the styles before them are loaded. // To achieve that, we could select pending styles and scripts in the // document and execute them sequentially in their dom order. // Restart observing.