Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change implements the starting point of a new v2 major version of the dom package. It is now implemented on top of the syscall/js API, which is supported by Go WebAssembly and GopherJS (as of version 1.12-2). The design goal has been to stay as close as possible to v1 API to make the transition easier to make. The only changes that were done were out of neccessity: - All struct fields with `js:"foo"` tags have been replaced with equivalent methods - Underlying() returns js.Value instead of *js.Object - AddEventListener() returns js.Func instead of func(*js.Object) There is a remaining TODO in window.RequestAnimationFrame method to make it so that cancelling the callback via CancelAnimationFrame makes it so the js.Func wrapper's Release method is called. Arranging this is difficult (it requires either having an internal map and sync primitive for tracking js.Func by IDs, or changing the return value of the RequestAnimationFrame method from int to something where the js.Func and its Release method can be accessed easily. The current implementation is functional but may end up using more memory in some situations. It's not blocking for the initial alpha release, so it remains a TODO for now. This implementation was based on work done in by @yml in Pull Request #59. Fixes #57. Co-authored-by: Yann Malet <yann.malet@gmail.com>
- Loading branch information