Comparing version 0.14.0 to 0.14.1
{ | ||
"name": "bs-webapi", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "Reason + BuckleScript bindings to DOM", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -29,2 +29,4 @@ # bs-webapi | ||
Please only use the modules exposed through the toplevel module `Webapi`, for example `Webapi.Dom.Element`. In particular, don't use the 'flat' modules like `Webapi__Dom__Element` as these are considered private and are not guaranteed to be backwards-compatible. | ||
## Some notes on the DOM API | ||
@@ -56,12 +58,12 @@ | ||
```reason | ||
include EventTargetRe.Impl({ type nonrec t = t }); | ||
include NodeRe.Impl({ type nonrec t = t }); | ||
include ParentNodeRe.Impl({ type nonrec t = t }); | ||
include NonDocumentTypeChildNodeRe.Impl({ type nonrec t = t }); | ||
include ChildNodeRe.Impl({ type nonrec t = t }); | ||
include SlotableRe.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__EventTarget.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__Node.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__ParentNode.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__NonDocumentTypeChildNode.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__ChildNode.Impl({ type nonrec t = t }); | ||
include Webapi__Dom__Slotable.Impl({ type nonrec t = t }); | ||
include Impl({ type nonrec t = t }); | ||
``` | ||
This is the implementation inheritance. Each "inheritable" module defines an "Impl" module where all its exported functions are defined. `include NodeRe.Impl { type nonrec t = t };` means that all the functions in `NodeRe.Impl` should be included in this module, but with the `t` type of that module replaced by the `t` type of this one. And that's it, it now has all the functions. | ||
This is the implementation inheritance. Each "inheritable" module defines an "Impl" module where all its exported functions are defined. `include Webapi__Dom__Node.Impl { type nonrec t = t };` means that all the functions in `Webapi__Dom__Node.Impl` should be included in this module, but with the `t` type of that module replaced by the `t` type of this one. And that's it, it now has all the functions. | ||
@@ -68,0 +70,0 @@ Implementation inheritance is used instead of subtyping to make it easier to understand which functions operate on any given "subject". If you have an `element` and you need to use a function defined in `Node`, let's say `removeChild` you cannot just use `Node.removeChild`. Instead you need to use `Element.removeChild`, which you can since `Element` inherits from `Node`. As a general rule, always use the function in the module corresponding to the type you have. You'll find this makes it very easy to see what types you're dealing with just by reading the code. |
180473
151