mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
cmd/gogio: use URL query for passing arguments to wasm programs
The location.hash method doesn't work correctly with multiple iframes and Safari. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -51,12 +51,11 @@ func buildJS(bi *buildInfo) error {
|
|||||||
|
|
||||||
const go = new Go();
|
const go = new Go();
|
||||||
|
|
||||||
// Pick up argv from location hash (#args).
|
// Pick up argv from the argv query argument (if set).
|
||||||
var hash = location.hash;
|
const params = new URLSearchParams(location.search);
|
||||||
if (hash.length > 0 && hash[0] == '#') {
|
const argv = params.get("argv");
|
||||||
hash = decodeURIComponent(hash.substr(1));
|
if (argv) {
|
||||||
go.argv = hash.split(" ");
|
go.argv = go.argv.concat(argv.split(" "));
|
||||||
go.argv.unshift("gio"); // os.Args(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
|
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user