As we advance closer to the stable release of WebSharper 3.0, more and more of the breaking changes we have wanted to implement for a long time are coming out. The main theme of the just-released version 3.0.8-alpha is naming conventions streamlining. With these changes, WebSharper should be more intuitive to use than ever. The changes necessary to update an existing project are fairly simple and detailed in the comprehensive guide below.
In names below,
IF is short for
The general rule is:
If a module contains client-side code, you should
If it only contains server-side code, you should not.
For the purpose of the above rule, WIG definitions ("Extension" projects) are not considered client-side code, since they are run during compilation to generate inlines. In fact, it is important not to
In more detail:
IFWS.Html5are removed and all types defined under them are now under
IFWS.EcmaScript.Globalis merged with the old
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
JS.Document, which obsolete
IFWS.Domis renamed to
IFWS.Pervasivesis split in two:
IFWS.Pervasivescontains definitions useful for both client-side and server-side code, such as attributes (
1 2 3 4 5 6 7 8
- The namespaces
IFWS.Htmlhave been a constant source of confusion for beginners. In WebSharper 3.0.8, they have been renamed to
IFWS.Html.Client, respectively. Hopefully this should make it more obvious when one or the other is needed.
- Tag and attribute combinators that were previously under a
HTML5module are now grouped back together with the "normal" ones. We judged that it doesn't make sense to separate them out anymore.
- The type
IF.Html.Element<'T>was originally intended to allow embedding various types of client-side controls. But ultimately, only
Web.Controlhas ever been used for this purpose. Therefore, we made the corresponding new
IFWS.Html.Server.Elementand all associated types (such as
The following namespaces have been renamed for consistency with Sitelets and Piglets:
IF.Formlet --> IF.Formlets
IFWS.Formlet --> IFWS.Formlets
IFWS.Formlet.JQueryUI --> IFWS.Formlets.JQueryUI(extension)
IFWS.Formlet.TinyMce --> IFWS.Formlets.TinyMce(extension)
The NuGet package WebSharper.Formlet.JQueryUI has also been renamed to WebSharper.Formlets.JQueryUI.
Web.Control and HTML type hierarchy
In preparation for an upcoming tighter integration of UI.Next, we changed the behavior of
Web.Control. Namely, the
Body property doesn't have the type
IPagelet anymore, but a new interface
IControlBody that is implemented by pagelets and will be soon implemented by UI.Next
Docs. As a consequence:
- The interface
IPageletis replaced by an abstract class
Pagelet, which implements
Html.Client.Elements now has type
Dom.Element. Some methods (such as
JQuery.Append) require a
Dom.Element; in this case, replace
1 2 3 4 5 6 7 8 9 10 11 12 13
// old code open IntelliFactory.WebSharper.Html open IntelliFactory.WebSharper.JQuery let e = Div [Text "some content"] JQuery.Of("#myElt").Append(e.Body).Ignore // new code open IntelliFactory.WebSharper.Html.Client open IntelliFactory.WebSharper.JQuery let e = Div [Text "some content"] JQuery.Of("#myElt").Append(e.Dom).Ignore
nuget install. This more standard behavior should harbor fewer opportunities for problems.
Phew, that was a long one! Overall these changes are fairly simple to apply to an existing project, and we are confident that they remove a number of idiosyncrasies that hinder the learning of WebSharper for beginners.
If you encounter any problems porting a project to the latest WebSharper, don't hesitate to tell us on the issue tracker. Happy coding!