Creating a client node outside a request leads to weird javascript errors.
Here is the code:
[%%shared
open Eliom_lib
open Eliom_content
open Html5.D
]
module Ocaloudcore_app =
Eliom_registration.App (
struct
let application_name = "ocaloudcore"
end)
let main_service =
Eliom_service.App.service ~path:[] ~get_params:Eliom_parameter.unit ()
let test =
Html5.C.node [%client
h2 [pcdata "Welcome from Eliom's distillery!"]]
let () =
Ocaloudcore_app.register
~service:main_service
(fun () () ->
Lwt.return
(Eliom_tools.F.html
~title:"ocaloudcore"
~css:[["css";"ocaloudcore.css"]]
Html5.D.(body [
test
])))
And the error from Firefox:
[eliom:client] Cannot apply unwrapping (i.e. utilize it in whatsoever form) on request node AhHRE8SdNEM8 before the document is initially loaded #text "" ocaloudcore.js:5917:31
uncaught exception: 0,248,Failure,-3,Cannot apply unwrapping (i.e. utilize it in whatsoever form) on request node AhHRE8SdNEM8 before the document is initially loaded <unknown>
[eliom] Async: (Failure
"Cannot apply unwrapping (i.e. utilize it in whatsoever form) on request node AhHRE8SdNEM8 before the document is initially loaded") ocaloudcore.js:5918:1
Well I guess it can make some sense to disallow this.
But it should either work, or raise an exception at runtime, but it should not (more or less) silently fail on the client !
This was an issue that confused me quite a bit, and when I found out became a bit depressed (taken with a grain of salt) - when one is used to functional semantics with referential transparency...
Creating a client node outside a request leads to weird javascript errors. Here is the code:
And the error from Firefox:
Well I guess it can make some sense to disallow this.
But it should either work, or raise an exception at runtime, but it should not (more or less) silently fail on the client !
With Eliom 5.0.0