Commit 5fa01b15 authored by Rafael Almeida's avatar Rafael Almeida Committed by Tim Neutkens

Improvements to build watcher (#7441)

* Remove fragment from _document

* Directly assign id instead of setAttribute

* Remove getElementById call by using the existing reference
parent e76529a4
import { getEventSourceWrapper } from './dev-error-overlay/eventsource' import { getEventSourceWrapper } from './dev-error-overlay/eventsource'
export default function initializeBuildWatcher () { export default function initializeBuildWatcher () {
const host = document.createElement('div') const shadowHost = document.createElement('div')
host.id = '__next-build-watcher' shadowHost.id = '__next-build-watcher'
document.body.appendChild(host)
const shadowHost = document.getElementById('__next-build-watcher')
if (!shadowHost) return
let shadowRoot
let prefix = ''
// Make sure container is fixed and on a high zIndex so it shows // Make sure container is fixed and on a high zIndex so it shows
shadowHost.style.position = 'fixed' shadowHost.style.position = 'fixed'
shadowHost.style.bottom = '10px' shadowHost.style.bottom = '10px'
shadowHost.style.right = '10px' shadowHost.style.right = '10px'
shadowHost.style.zIndex = 99999 shadowHost.style.zIndex = 99999
document.body.appendChild(shadowHost)
let shadowRoot
let prefix = ''
if (shadowHost.attachShadow) { if (shadowHost.attachShadow) {
shadowRoot = shadowHost.attachShadow({ mode: 'open' }) shadowRoot = shadowHost.attachShadow({ mode: 'open' })
...@@ -91,7 +88,7 @@ export default function initializeBuildWatcher () { ...@@ -91,7 +88,7 @@ export default function initializeBuildWatcher () {
function createContainer (prefix) { function createContainer (prefix) {
const container = document.createElement('div') const container = document.createElement('div')
container.setAttribute('id', `${prefix}container`) container.id = `${prefix}container`
container.innerHTML = ` container.innerHTML = `
<div id="${prefix}icon-wrapper"> <div id="${prefix}icon-wrapper">
<svg viewBox="0 0 226 200"> <svg viewBox="0 0 226 200">
......
...@@ -371,11 +371,7 @@ export class Main extends Component { ...@@ -371,11 +371,7 @@ export class Main extends Component {
render() { render() {
const { amphtml, html } = this.context._documentProps const { amphtml, html } = this.context._documentProps
if (amphtml) return '__NEXT_AMP_RENDER_TARGET__' if (amphtml) return '__NEXT_AMP_RENDER_TARGET__'
return ( return <div id="__next" dangerouslySetInnerHTML={{ __html: html }} />
<>
<div id="__next" dangerouslySetInnerHTML={{ __html: html }} />
</>
)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment