diff --git a/div/div.go b/div/div.go deleted file mode 100644 index 680fe7f..0000000 --- a/div/div.go +++ /dev/null @@ -1,17 +0,0 @@ -// +build js,wasm - -package div - -import "github.com/dennwc/dom" - -// Writer implements an io.Writer that appends content -// to the dom.Element. It should ideally be used on a
element. -type Writer dom.Element - -// Write implements io.Writer. -func (d Writer) Write(p []byte) (n int, err error) { - node := dom.GetDocument().CreateElement("div") - node.SetInnerHTML(string(p)) - (*dom.Element)(&d).AppendChild(node) - return len(p), nil -} diff --git a/fetch/main.go b/fetch/main.go index 6cc566e..ad0e1a1 100644 --- a/fetch/main.go +++ b/fetch/main.go @@ -9,12 +9,21 @@ import ( "strings" "github.com/dennwc/dom" - "github.com/johanbrandhorst/wasm-experiments/div" ) +type writer dom.Element + +// Write implements io.Writer. +func (d writer) Write(p []byte) (n int, err error) { + node := dom.GetDocument().CreateElement("div") + node.SetInnerHTML(string(p)) + (*dom.Element)(&d).AppendChild(node) + return len(p), nil +} + func main() { t := dom.GetDocument().GetElementById("target") - logger := log.New((*div.Writer)(t), "", log.LstdFlags) + logger := log.New((*writer)(t), "", log.LstdFlags) c := http.Client{} req, err := http.NewRequest( diff --git a/html/test.wasm b/html/test.wasm index eb469a5..679c52a 100755 Binary files a/html/test.wasm and b/html/test.wasm differ diff --git a/js/main.go b/js/main.go index 96fb824..ec7848e 100644 --- a/js/main.go +++ b/js/main.go @@ -2,9 +2,7 @@ package main -import ( - "syscall/js" -) +import "syscall/js" var document js.Value