-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer-js-util.go
53 lines (46 loc) · 1.13 KB
/
renderer-js-util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package domrender
import "github.com/vugu/vugu"
// namespaceToURI resolves the given namespaces to the URI with the specifications
func namespaceToURI(namespace string) string {
switch namespace {
case "html":
return "http://www.w3.org/1999/xhtml"
case "math":
return "http://www.w3.org/1998/Math/MathML"
case "svg":
return "http://www.w3.org/2000/svg"
case "xlink":
return "http://www.w3.org/1999/xlink"
case "xml":
return "http://www.w3.org/XML/1998/namespace"
case "xmlns":
return "http://www.w3.org/2000/xmlns/"
default:
return ""
}
}
type renderedCtx struct {
eventEnv vugu.EventEnv
first bool
}
// EventEnv implements RenderedCtx by returning the EventEnv.
func (c *renderedCtx) EventEnv() vugu.EventEnv {
return c.eventEnv
}
// First returns true for the first render and otherwise false.
func (c *renderedCtx) First() bool {
return c.first
}
type rendered0 interface {
Rendered()
}
type rendered1 interface {
Rendered(ctx vugu.RenderedCtx)
}
func invokeRendered(c interface{}, rctx *renderedCtx) {
if i, ok := c.(rendered0); ok {
i.Rendered()
} else if i, ok := c.(rendered1); ok {
i.Rendered(rctx)
}
}