iframe-resize-directive.js
function resizeToFit( iframe ) {
   if( !iframe ) {
      // Indicate that the iframe is not there (anymore): Cancel the timeout.
      return false;
   }

   const body = iframe.contentDocument && iframe.contentDocument.body;
   if( !body || !body.scrollHeight ) {
      // not ready yet, but keep trying.
      return true;
   }

   const html = iframe.contentDocument.documentElement;
   setPixelDimensions( iframe, html.offsetWidth, html.offsetHeight );
   return true;
}
function resizeToFit( iframe ) {
   if( !iframe ) {
      // Indicate that the iframe is not there (anymore): Cancel the timeout.
      return false;
   }

   const body = iframe.contentDocument && iframe.contentDocument.body;
   if( !body || !body.scrollHeight ) {
      // not ready yet, but keep trying.
      return true;
   }

   const html = iframe.contentDocument.documentElement;
   setPixelDimensions( iframe, html.offsetWidth, html.offsetHeight );
   return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////