Skip to content

Latest commit

 

History

History

wasm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
https://godoc.org/github.com/siongui/godom/wasm?status.png https://api.travis-ci.org/siongui/godom.png?branch=master https://goreportcard.com/badge/github.com/siongui/godom/wasm

https://img.shields.io/twitter/url/https/github.com/siongui/godom.svg?style=social

Make DOM Manipulation in Go as similar to JavaScript as possible via WebAssembly. For DOM Manipulation via GopherJS, visit root directory.

$ GOARCH=wasm GOOS=js go get -u github.com/siongui/godom/wasm

Why not use syscall/js directly?

Because the code written directly using syscall/js without any wrapper is really ugly. For example, if you want to getElementById, you need to write:

import (
      "syscall/js"
)

foo := js.Global().Get("document").Call("getElementById", "foo")

With godom, you write:

import (
      . "github.com/siongui/godom/wasm"
)

foo := Document.GetElementById("foo")

which looks like JavaScript and more readable.

godom is only a wrapper for syscall/js package. If something is not implemented, you can still use methods in syscall/js to call or get the method/property you need. For example, if the Play() method of the audio element is not implemented, you can use syscall/js Call method to call play method directly:

import (
      . "github.com/siongui/godom/wasm"
)

a := Document.GetElementById("foo")
a.Call("play")
[1]WebAssembly · golang/go Wiki · GitHub