fbredius/storybook

View on GitHub
lib/core-common/templates/base-manager-head.html

Summary

Maintainability
Test Coverage
<style>
  html, body {
    overflow: hidden;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  * {
    box-sizing: border-box;
  }
</style>

<script>
  /* globals window */
  /* eslint-disable no-underscore-dangle */
  try {
    if (window.top !== window) {
      window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.top.__REACT_DEVTOOLS_GLOBAL_HOOK__;
    }
  } catch (e) {
    // eslint-disable-next-line no-console
    console.warn('unable to connect to top frame for connecting dev tools');
  }

  window.onerror = function onerror(message, source, line, column, err) {
    if (window.CONFIG_TYPE !== 'DEVELOPMENT') return;
    // eslint-disable-next-line no-var, vars-on-top
    var xhr = new window.XMLHttpRequest();
    xhr.open('POST', '/runtime-error');
    xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
    xhr.send(
      JSON.stringify({
        /* eslint-disable object-shorthand */
        message: message,
        source: source,
        line: line,
        column: column,
        error: err && { message: err.message, name: err.name, stack: err.stack },
        origin: 'manager',
        /* eslint-enable object-shorthand */
      })
    );
  };
</script>