Skip to content

Commit

Permalink
Merge pull request #11 from ptxmac/ptx/support_nil
Browse files Browse the repository at this point in the history
JSValue() returns js.Null() if the object is nil
  • Loading branch information
janpfeifer authored Dec 1, 2022
2 parents 873ab09 + 7298e3c commit 909cb6c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gowasm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ type {{.Type.Def}} struct {
}
{{if not .If.Inherits}}
// JSValue returns the js.Value or js.Null() if _this is nil
func (_this *{{.Type.Def}}) JSValue() js.Value {
if _this == nil {
return js.Null()
}
return _this.Value_JS
}
{{end}}
Expand Down

0 comments on commit 909cb6c

Please sign in to comment.