WebView present() broken after evaluateJavascript

Has anyone seen a symptom where a WebView can’t display HTML / is blank after running evaluateJavascript?

Try running this. First present() works fine, second one doesn’t.

const webView = new WebView()
const webHtml = "<body bgcolor='gray'><div id='animal'>cat</div></body>"
const webJs = `
var s = document.getElementById('animal');
s.innerHTML = "dog"

await webView.loadHTML(webHtml)
await webView.present()
log(await webView.getHTML())

const result = await webView.evaluateJavaScript(webJs)
log(await webView.getHTML())
await webView.present()

Log output seems to indicate it should work, but unfortunately doesn’t -

2019-05-18 16:56:34: <html><head></head><body bgcolor="gray"><div id="animal">cat</div></body></html>
2019-05-18 16:56:34: cat
2019-05-18 16:56:34: <html><head></head><body bgcolor="gray"><div id="animal">dog</div></body></html>
2019-05-18 16:56:34: dog

Even if I loadHtml after evaluateJavascript:

await webView.loadHTML(webHtml)
await webView.evaluateJavaScript(webJs)
webHtml = await webView.getHTML()
await webView.loadHTML(webHtml)
await webView.present()

I’m new to Scriptable, so the flaw may be obvious. Thanks for ideas.

Sorry for the late reply. I’ve reproduced the issue and it does indeed look a bit odd. I’ll take a look at the issue and see if I can fix it in the next update.

Thanks for your feedback. I really appreciate it.

1 Like

Just wanted to let you know that this will be fixed in version 1.3.4 which should be released soon-ish. And just for the fun of it, here’s a video of the script I used to verify that the issue was fixed.

1 Like