_prepareFrameContent()

in lib/websandbox.ts [116:138]


  _prepareFrameContent(options: SandboxOptions) {
    let frameContent = options.frameContent ?? '';

    if (options.codeToRunBeforeInit) {
      frameContent = frameContent
        .replace('<head>', `<head>\n<script>${options.codeToRunBeforeInit}</script>`) ?? '';
    }

    frameContent = frameContent
      .replace('<head>', `<head>\n<script>${CompiledFrameScript}</script>`) ?? '';

    if (options.initialStyles) {
      frameContent = frameContent
        .replace('</head>', `<style>${options.initialStyles}</style>\n</head>`);
    }

    if (options.baseUrl) {
      frameContent = frameContent
        .replace('<head>', `<head>\n<base target="_parent" href="${options.baseUrl}"/>`);
    }

    return frameContent;
  }