Skip to content

Instantly share code, notes, and snippets.

@pravdomil
Created January 16, 2020 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pravdomil/393bcca7b4bc03b90c4230db674f5e5a to your computer and use it in GitHub Desktop.
Save pravdomil/393bcca7b4bc03b90c4230db674f5e5a to your computer and use it in GitHub Desktop.
for Elm
try {
main()
} catch (e) {
document.body.textContent = ""
create(document.body, "h1", "m-3").textContent = "😔"
create(document.body, "pre", "m-3").textContent = e
throw e
}
function main() {
const node = create(document.body, "div")
const app = Elm.Main.init({ node: node, flags: {} })
}
function create(parent, type, className) {
const el = document.createElement(type)
if (parent) parent.appendChild(el)
if (className) el.className = className
return el
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment