From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id A29F37F058 for ; Sat, 2 Jan 2016 22:30:37 +0100 (CET) IronPort-PHdr: 9a23:/M+ZJx8/pDD6dv9uRHKM819IXTAuvvDOBiVQ1KB91u4cTK2v8tzYMVDF4r011RmSDduds6oMotGVmp6jcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47AblHf6ke/8SQVUk2mc1EleKKtQsb7tIee6aObw9XreQJGhT6wM/tZDS6dikHvjPQQmpZoMa0ryxHE8TNicuVSwn50dxrIx06vrpT4wJk22CRZo/Np3M5JSaKyK745XbFUJDQvK3gk4MDzqRjICwyV6S1PfH8Rl09wAwnB7QniU9/PvyH3rKIpwCmbOczuVb1yRzmo4r1DRxrhiSNBPDk8pjKEwvdshb5W9Ury7yd0xJTZNdmY Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=philippe.veber@gmail.com; spf=Pass smtp.mailfrom=philippe.veber@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f46.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of philippe.veber@gmail.com) identity=pra; client-ip=74.125.82.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of philippe.veber@gmail.com designates 74.125.82.46 as permitted sender) identity=mailfrom; client-ip=74.125.82.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wm0-f46.google.com) identity=helo; client-ip=74.125.82.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="postmaster@mail-wm0-f46.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DuAQC3QIhWmy5SfUpeg1g0bQaIU6kwjDIihW0CgQoHPBABAQEBAQEBARABAQEBAQYLCwkhLkESgVqCCAEBAwESER0BGx0BAwELBgMCBAcDNAICIgERAQUBHAYTIod3AQMKCA6RSY9MgTE+MYtIgWqCeYgRChknDVaCSAEBAQEBAQEDAQEBAQEBAQEVAQUOhkiEf4UEgm+BSQWXBoVAiBGBXEqMVUSFFIcWESSBFzmCLyKBZT00gQaECgEBAQ X-IPAS-Result: A0DuAQC3QIhWmy5SfUpeg1g0bQaIU6kwjDIihW0CgQoHPBABAQEBAQEBARABAQEBAQYLCwkhLkESgVqCCAEBAwESER0BGx0BAwELBgMCBAcDNAICIgERAQUBHAYTIod3AQMKCA6RSY9MgTE+MYtIgWqCeYgRChknDVaCSAEBAQEBAQEDAQEBAQEBAQEVAQUOhkiEf4UEgm+BSQWXBoVAiBGBXEqMVUSFFIcWESSBFzmCLyKBZT00gQaECgEBAQ X-IronPort-AV: E=Sophos;i="5.20,513,1444687200"; d="scan'208";a="195297950" Received: from mail-wm0-f46.google.com ([74.125.82.46]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 02 Jan 2016 22:30:36 +0100 Received: by mail-wm0-f46.google.com with SMTP id l65so127304001wmf.1 for ; Sat, 02 Jan 2016 13:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=3Yk5xDbRbHBw1bdahfv3AfYJ3qbueEwD1kzvoWmZtWI=; b=jnEWv6JWhoPlvLAXkvTvWgTu9xfpfwDWPR9hs0QJJ09DEUgW5PZq/0/yP/HNIqROBf a67ABgsqyG7WqsSroK6Cga8N222omE9Sz3kUapDJIsXZynjQNGkABsonu5S+NDS0ld5X fZeK4imrPyRtVWvlRkjzMWOsPW9FJmXDFCY3bsfs+9VWJK7hnrulYePGt9JDCDzTmNtH rPeNxLjjekLjuwchU0lXq8Ihx6aBoy12mCB1mXPWXHZoZnjt8cVrCkCDKJV+rFC3Inyb Q4KJIfG1SnCA+oeWdAEYo1pyCRWJmseAfrq7zrpoli1+JgWWtJmRYppuzqK9MAUM06EC iApA== X-Received: by 10.194.192.99 with SMTP id hf3mr87772457wjc.30.1451770236669; Sat, 02 Jan 2016 13:30:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.175.20 with HTTP; Sat, 2 Jan 2016 13:30:17 -0800 (PST) In-Reply-To: <20160102204246.GA23759@pim.happyleptic.org> References: <20160102174325.GA22783@pim.happyleptic.org> <20160102204246.GA23759@pim.happyleptic.org> From: Philippe Veber Date: Sat, 2 Jan 2016 22:30:17 +0100 Message-ID: To: Chapi Chapo Cc: caml users Content-Type: multipart/alternative; boundary=047d7bae46964095890528609922 X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] js_of_ocaml and --047d7bae46964095890528609922 Content-Type: text/plain; charset=UTF-8 Drup provided the easiest answer, that is using Tyxml_js. In particular it provides a functional (reactive) API to update the DOM, which is a lot better than using the [createElement] functions. Also, using [Dom_svg.document] here is not appropriate since you want the SVG fragment to be embedded in HTML. This function should be used when the whole document is an SVG. 2016-01-02 21:42 GMT+01:00 : > Indeed TyXML can generate XHTML trees with svg elements. > But how to use that to update the DOM from JS generated by js_of_ocaml? > > # echo > toto.ml < let svg = Dom_svg.createSvg Dom_html.window##document > EOF > # ocamlfind ocamlc -syntax camlp4o -package "js_of_ocaml > js_of_ocaml.syntax" -c toto.ml > Error: This expression has type Dom_html.document Js.t > but an expression was expected of type Dom_svg.document Js.t > Type > Dom_html.document = (... yanked for sanity ...) > is not compatible with type > Dom_svg.document = (... yum yum ...) > The second object type has no method anchors > > Apparently that's a known issue of js_of_ocaml: > https://github.com/ocsigen/js_of_ocaml/issues/276 > > that I don't know how to work around nicely, may be because I have no idea > how > js_of_ocaml interacts with tyxml. I guess you are the pveber of that > discussion > so probably you can shed some light on this? > --047d7bae46964095890528609922 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Drup provided the easiest answer, that is using Tyxml_js. = In particular it provides a functional (reactive) API to update the DOM, wh= ich is a lot better than using the [createElement] functions. Also, using [= Dom_svg.document] here is not appropriate since you want the SVG fragment t= o be embedded in HTML. This function should be used when the whole document= is an SVG.

2016-01-02 21:42 GMT+01:00 <rixed@happyleptic.org>:=
Indeed TyXML can generate XHTML trees wi= th svg elements.
But how to use that to update the DOM from JS generated by js_of_ocaml?

# echo > toto.ml <<EOF
let svg =3D Dom_svg.createSvg Dom_html.window##document
EOF
# ocamlfind ocamlc -syntax camlp4o -package "js_of_ocaml js_of_ocaml.s= yntax" -c toto.ml
Error: This expression has type Dom_html.document Js.t
=C2=A0 =C2=A0 =C2=A0 =C2=A0but an expression was expected of type Dom_svg.d= ocument Js.t
=C2=A0 =C2=A0 =C2=A0 =C2=A0Type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Dom_html.document =3D (... yanked for san= ity ...)
=C2=A0 =C2=A0 =C2=A0 =C2=A0is not compatible with type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Dom_svg.document =3D (... yum yum ...)
=C2=A0 =C2=A0 =C2=A0 =C2=A0The second object type has no method anchors

Apparently that's a known issue of js_of_ocaml:
https://github.com/ocsigen/js_of_ocaml/issues/276

that I don't know how to work around nicely, may be because I have no i= dea how
js_of_ocaml interacts with tyxml. I guess you are the pveber of that discus= sion
so probably you can shed some light on this?

--047d7bae46964095890528609922--