├── example
├── video.mp4
├── html
│ ├── video.mp4
│ ├── wasm.wasm
│ ├── index.html
│ ├── wasm.js
│ └── wasm_exec.js
├── index.html
├── wasm.js
├── wasm-server
│ └── main.go
├── wasm.go
└── wasm_exec.js
├── elements
├── form
│ ├── errors.go
│ ├── methods.go
│ ├── output.go
│ ├── fieldset.go
│ └── form.go
├── input
│ ├── errors.go
│ ├── datalist.go
│ ├── types.go
│ └── input.go
├── href
│ └── href.go
├── li
│ └── li.go
├── label
│ └── label.go
├── media
│ ├── track.go
│ └── video.go
├── a
│ ├── rel.go
│ └── a.go
├── nav
│ └── nav.go
├── table
│ └── table.go
├── img
│ └── img.go
└── picture
│ ├── source.go
│ └── picture.go
├── targets.go
├── navigator.go
├── Makefile
├── .gitignore
├── tokenlist.go
├── xslt.go
├── history.go
├── event.go
├── location.go
├── storage.go
├── document.go
├── window.go
├── xmlhttprequest.go
├── README.md
├── element.go
├── LICENSE
└── css.go
/example/video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nerzal/tinydom/HEAD/example/video.mp4
--------------------------------------------------------------------------------
/example/html/video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nerzal/tinydom/HEAD/example/html/video.mp4
--------------------------------------------------------------------------------
/example/html/wasm.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nerzal/tinydom/HEAD/example/html/wasm.wasm
--------------------------------------------------------------------------------
/elements/form/errors.go:
--------------------------------------------------------------------------------
1 | package form
2 |
3 | import "errors"
4 |
5 | var ErrInvalidTagAppended = errors.New("invalid tag appended")
6 |
--------------------------------------------------------------------------------
/elements/input/errors.go:
--------------------------------------------------------------------------------
1 | package input
2 |
3 | import "errors"
4 |
5 | var ErrInvalidAttribute = errors.New("invalid attribute provided for input type")
6 |
--------------------------------------------------------------------------------
/elements/form/methods.go:
--------------------------------------------------------------------------------
1 | package form
2 |
3 | type Method string
4 |
5 | const (
6 | GET Method = "get"
7 | POST Method = "post"
8 | )
9 |
10 | func (m Method) String() string {
11 | return string(m)
12 | }
13 |
--------------------------------------------------------------------------------
/targets.go:
--------------------------------------------------------------------------------
1 | package tinydom
2 |
3 | type Target string
4 |
5 | const (
6 | Blank Target = "_blank"
7 | Self Target = "_self"
8 | Parent Target = "_parent"
9 | Top Target = "_top"
10 | )
11 |
12 | func (t Target) String() string {
13 | return string(t)
14 | }
15 |
--------------------------------------------------------------------------------
/navigator.go:
--------------------------------------------------------------------------------
1 | package tinydom
2 |
3 | import "syscall/js"
4 |
5 | type Navigator struct {
6 | js.Value
7 | }
8 |
9 | func (n *Navigator) Language() string {
10 | return n.Get("language").String()
11 | }
12 |
13 | func (n *Navigator) Languages() string {
14 | return n.Get("languages").String()
15 | }
16 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | example-app:
2 | rm -rf example/html
3 | mkdir example/html
4 | tinygo build -o example/html/wasm.wasm -target wasm -no-debug example/wasm.go
5 | cp example/wasm_exec.js example/html/
6 | cp example/wasm.js example/html/
7 | cp example/index.html example/html/
8 | cp example/video.mp4 example/html/
9 | go run example/wasm-server/main.go
--------------------------------------------------------------------------------
/elements/href/href.go:
--------------------------------------------------------------------------------
1 | package href
2 |
3 | import "github.com/Nerzal/tinydom"
4 |
5 | type Href struct {
6 | *tinydom.Element
7 | }
8 |
9 | func New(link, innerHTML string) *Href {
10 | a := tinydom.GetDocument().CreateElement("a")
11 | a.Set("href", link)
12 | a.Set("target", "_blank")
13 | a.SetInnerHTML(innerHTML)
14 | return &Href{a}
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.exe~
4 | *.dll
5 | *.so
6 | *.dylib
7 |
8 | # Test binary, built with `go test -c`
9 | *.test
10 |
11 | # Output of the go coverage tool, specifically when used with LiteIDE
12 | *.out
13 |
14 | # Dependency directories (remove the comment below to include it)
15 | # vendor/
16 |
17 | .vscode
18 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TinyDom
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/elements/li/li.go:
--------------------------------------------------------------------------------
1 | package li
2 |
3 | import "github.com/Nerzal/tinydom"
4 |
5 | // Li is a li element
6 | // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li for reference
7 | type Li struct {
8 | *tinydom.Element
9 | }
10 |
11 | func New() *Li {
12 | doc := tinydom.GetDocument()
13 | element := doc.CreateElement("li")
14 |
15 | return &Li{
16 | Element: element,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/example/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TinyDom
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/elements/label/label.go:
--------------------------------------------------------------------------------
1 | package label
2 |
3 | import "github.com/Nerzal/tinydom"
4 |
5 | type Label struct {
6 | *tinydom.Element
7 | }
8 |
9 | func New() *Label {
10 | return &Label{tinydom.GetDocument().CreateElement("label")}
11 | }
12 |
13 | func (l *Label) SetFor(value string) *Label {
14 | l.SetAttribute("for", value)
15 | return l
16 | }
17 |
18 | func (l *Label) For() string {
19 | return l.Get("for").String()
20 | }
21 |
--------------------------------------------------------------------------------
/elements/media/track.go:
--------------------------------------------------------------------------------
1 | package media
2 |
3 | import "github.com/Nerzal/tinydom"
4 |
5 | //