Merge pull request #20 from wailsapp/Update-execution-order-in-Headless-mode

Numerous fixes for headless mode.
This commit is contained in:
Lea Anthony 2019-01-13 17:58:34 +11:00 committed by GitHub
commit 8a3aec6866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 14 deletions

File diff suppressed because one or more lines are too long

View file

@ -101,6 +101,10 @@
}
s.textContent = script;
document.head.appendChild(s)
if (script.indexOf("window.wails._.") == 0) {
var elem = document.querySelector('#' + id);
elem.parentNode.removeChild(elem);
}
}
function handleConnect() {
@ -139,8 +143,13 @@
}, 300);
}
let idcounter = 0
function generateID() {
return "wails-" + idcounter++;
}
function handleMessage(e) {
addScript(e.data);
addScript(e.data, generateID());
}
// Key listener
@ -169,7 +178,6 @@
connect();
}());
</script>

View file

@ -125,16 +125,6 @@ func (h *Headless) start(conn *websocket.Conn) {
h.injectCSS(h.frameworkCSS)
}
// If given an HMTL fragment, mount it on #app
// Otherwise, replace the html tag
var injectHTML string
if h.appConfig.isHTMLFragment {
injectHTML = fmt.Sprintf("$('#app').html('%s')", h.appConfig.HTML)
} else {
injectHTML = fmt.Sprintf("$('html').html('%s')", h.appConfig.HTML)
}
h.evalJS(injectHTML)
// Inject user CSS
if h.appConfig.CSS != "" {
outputCSS := fmt.Sprintf("%.45s", h.appConfig.CSS)
@ -274,7 +264,7 @@ func (h *Headless) NotifyEvent(event *eventData) error {
}
}
message := fmt.Sprintf("wails._.notify('%s','%s')", event.Name, data)
message := fmt.Sprintf("window.wails._.notify('%s','%s')", event.Name, data)
return h.evalJS(message)
}