mirror of https://github.com/sveltejs/svelte
parent
2c90c27eb5
commit
9d2f7550bd
@ -1,19 +1,17 @@
|
||||
import ToolBar from './ToolBar.svelte';
|
||||
import { mount } from 'svelte';
|
||||
function create_toolbar_host() {
|
||||
const id = 'svelte-toolbar-host';
|
||||
if (document.getElementById(id) != null) {
|
||||
console.debug('svelte-toolbar-host already exists, skipping');
|
||||
return;
|
||||
}
|
||||
const el = document.createElement('div');
|
||||
el.setAttribute('id', id);
|
||||
// appending to documentElement adds it outside of body
|
||||
document.documentElement.appendChild(el);
|
||||
return el;
|
||||
}
|
||||
|
||||
export function mountUI() {
|
||||
if (typeof window !== 'undefined') {
|
||||
mount(ToolBar, { target: create_toolbar_host() });
|
||||
if(typeof window !== 'undefined') {
|
||||
const id = 'svelte-toolbar-host';
|
||||
if (document.getElementById(id) != null) {
|
||||
console.debug('svelte-toolbar-host already exists, skipping');
|
||||
return
|
||||
}
|
||||
const el = document.createElement('div');
|
||||
el.setAttribute('id', id);
|
||||
// appending to documentElement adds it outside of body
|
||||
document.documentElement.appendChild(el);
|
||||
mount(ToolBar, { target: el });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue