forked from GirlBossRush/ExampleBabelApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (27 loc) · 942 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function () {
'use strict'
if (!window.addEventListener) return // Check for IE9+
let options = INSTALL_OPTIONS
let element
// updateElement runs every time the options are updated.
// Most of your code will end up inside this function.
function updateElement () {
element = INSTALL.createElement(options.location, element)
// Set the app attribute to your app's dash-delimited alias.
element.setAttribute('app', 'example')
element.innerHTML = options.message
}
// INSTALL_SCOPE is an object that is used to handle option changes without refreshing the page.
window.INSTALL_SCOPE = {
setOptions (nextOptions) {
options = nextOptions
updateElement()
}
}
// This code ensures that the app doesn't run before the page is loaded.
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updateElement)
} else {
updateElement()
}
}())