Skip to content

Commit 2e8fb07

Browse files
- removed dependency of honnef/dom pkg
- add new function to getElementById - fix golint issue
1 parent 7f3cd5b commit 2e8fb07

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

react.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package react
44

55
import (
66
"github.com/gopherjs/gopherjs/js"
7-
"honnef.co/go/js/dom"
87
)
98

109
var (
@@ -26,8 +25,17 @@ var (
2625
CreateReactClass = js.Global
2726
)
2827

28+
// GetElementByID will return the first element with the specified id in the dom object.
29+
// If no dom is provided, window.document will be used.
30+
func GetElementByID(id string, dom ...*js.Object) *js.Object {
31+
if len(dom) > 0 {
32+
return dom[0].Call("getElementById", id)
33+
}
34+
return js.Global.Get("document").Call("getElementById", id)
35+
}
36+
2937
// Render will render component to the specified target dom element.
30-
func Render(element *js.Object, domTarget dom.Element, callback ...func()) *js.Object {
38+
func Render(element *js.Object, domTarget *js.Object, callback ...func()) *js.Object {
3139
if len(callback) > 0 && callback[0] != nil {
3240
return ReactDOM.Call("render", element, domTarget, callback[0])
3341
}

react_events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *SyntheticEvent) IsTrusted() bool {
6262
return s.O.Get("isTrusted").Bool()
6363
}
6464

65-
// NativeEvents ...
65+
// NativeEvent ...
6666
//
6767
// See: https://reactjs.org/docs/events.html#overview
6868
//

0 commit comments

Comments
 (0)