- htmlElement := js.Global.Get("HTMLElement")
- reflect := js.Global.Get("Reflect")
- xclock := js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- instance := reflect.Call("construct", htmlElement, make([]interface{}, 0), js.Global.Get("XClock"))
- instance.Set("interval", nil)
- instance.Call("addEventListener", "click", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- if this.Get("interval") == nil {
- js.Global.Set("XClock", xclock)
- prototype := xclock.Get("prototype")
- object := js.Global.Get("Object")
- object.Call("setPrototypeOf", prototype, htmlElement.Get("prototype"))
- object.Call("setPrototypeOf", xclock, htmlElement)
- prototype.Set("connectedCallback", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- prototype.Set("start", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- update := this.Get("update").Call("bind", this)
- this.Set("interval", js.Global.Call("setInterval", update, 1000))
- prototype.Set("stop", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- js.Global.Call("clearInterval", this.Get("interval"))
- this.Set("interval", nil)
- prototype.Set("update", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
- this.Set("textContent", time.Now().Format(time.RFC1123))
- js.Global.Get("customElements").Call("define", "x-clock", xclock)
+ htmlElement := js.Global.Get("HTMLElement")
+ reflect := js.Global.Get("Reflect")
+ xclock := js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ instance := reflect.Call("construct", htmlElement, make([]interface{}, 0), js.Global.Get("XClock"))
+ instance.Set("interval", nil)
+ instance.Call("addEventListener", "click", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ if this.Get("interval") == nil {
+ js.Global.Set("XClock", xclock)
+ prototype := xclock.Get("prototype")
+ object := js.Global.Get("Object")
+ object.Call("setPrototypeOf", prototype, htmlElement.Get("prototype"))
+ object.Call("setPrototypeOf", xclock, htmlElement)
+ prototype.Set("connectedCallback", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ prototype.Set("start", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ update := this.Get("update").Call("bind", this)
+ this.Set("interval", js.Global.Call("setInterval", update, 1000))
+ prototype.Set("stop", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ js.Global.Call("clearInterval", this.Get("interval"))
+ this.Set("interval", nil)
+ prototype.Set("update", js.MakeFunc(func(this *js.Object, arguments []*js.Object) interface{} {
+ this.Set("textContent", time.Now().Format(time.RFC1123))
+ js.Global.Get("customElements").Call("define", "x-clock", xclock)