mirror of
https://github.com/taigrr/wasm-experiments
synced 2025-01-18 04:03:21 -08:00
18 lines
435 B
Go
18 lines
435 B
Go
// +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 <div> 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
|
|
}
|