diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4f865fb4e..76030c564 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,30 +17,29 @@ jobs: ocaml-compiler: - 4.04.x - 4.05.x - - 4.06.x - - 4.07.x - - 4.08.x - - 4.09.x - - 4.10.x - 4.11.x - - 4.12.x + - 4.13.x + - 4.14.x + - 5.0.x + - 5.1.x include: - os: macos-latest - ocaml-compiler: 4.12.x + ocaml-compiler: 4.14.x - os: windows-latest - ocaml-compiler: 4.12.x + ocaml-compiler: 4.14.x + - os: macos-latest + ocaml-compiler: 5.1.x runs-on: ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use OCaml ${{ matrix.ocaml-compiler }} uses: ocaml/setup-ocaml@v2 with: ocaml-compiler: ${{ matrix.ocaml-compiler }} - dune-cache: true opam-depext-flags: --with-test - run: opam install . --deps-only --with-test diff --git a/CHANGES.md b/CHANGES.md index 51542f7d0..8f2859210 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,13 @@ -# NEXT +# 4.6.0 + +* Update for OCaml 5.0 and drop support for OCaml 4.2.0 + (#312 by @rr0gi) + +* Add additional variants to `linktype` for the `rel` attribute + (Leon @LogicalOverflow Vack) + +* Expand options for `autocomplete` attribute on `` elements + (#302 by Aron @aronerben Erben) * Fix the SVG animation attributes `a_animation_values`, `a_keyTimes` and `a_keySplines` to contain semicolon separated values. @@ -10,10 +19,15 @@ * Add support for `dialog` element and `onclose` attribute (#301 by Julien Sagot) - +* Add an escape hatch for emitting attributes with non-standard names + in jsx or ppx code (a leading `_` character on attribute name) + (#295 Chas @cemerick Emerick) * Add support for `type` attribute on `|}]], [script ~a:[a_script_type (`Mime "text/javascript")] @@ txt ""]; + "script empty", + [[%html {||}]], + [script @@ txt ""]; + + "textarea empty", + [[%html {||}]], + [textarea @@ txt ""]; + ] let attribs = "ppx attribs", HtmlTests.make Html.[ @@ -235,17 +243,45 @@ let attribs = "ppx attribs", HtmlTests.make Html.[ [[%html "
"]], [div ~a:[a_draggable false] []] ; - "onoff default", + "form autocomplete default is on", [[%html "
"]], - [form ~a:[a_autocomplete true] []] ; + [form ~a:[a_autocomplete `On] []] ; - "bool true", + "form autocomplete on", [[%html "
"]], - [form ~a:[a_autocomplete true] []] ; + [form ~a:[a_autocomplete `On] []] ; - "bool false", + "form autocomplete off", [[%html "
"]], - [form ~a:[a_autocomplete false] []] ; + [form ~a:[a_autocomplete `Off] []] ; + + "form autocomplete tokenlist", + [[%html "
"]], + [form ~a:[a_autocomplete (`Tokens ["section-blue"; "shipping"; "street-address"] )] []] ; + + "form autocomplete tokenlist empty", + [[%html "
"]], + [form ~a:[a_autocomplete (`Tokens [] )] []] ; + + "input autocomplete default is on", + [[%html ""]], + [input ~a:[a_autocomplete `On] ()] ; + + "input autocomplete on", + [[%html ""]], + [input ~a:[a_autocomplete `On] ()] ; + + "input autocomplete off", + [[%html ""]], + [input~a:[a_autocomplete `Off] ()] ; + + "input autocomplete tokenlist", + [[%html ""]], + [input ~a:[a_autocomplete (`Tokens ["section-blue"; "shipping"; "street-address"] )] ()] ; + + "input autocomplete tokenlist empty", + [[%html ""]], + [input ~a:[a_autocomplete (`Tokens [] )] ()] ; "link rel=canonical", [[%html ""]], @@ -283,6 +319,12 @@ let attribs = "ppx attribs", HtmlTests.make Html.[ [[%html "
"]], [div ~a:[a_user_data "foo" "valfoo"] []] ; + + "arbitrary (unchecked) attributes via an escape hatch", + [[%html "
"]], + [div + ~a:[Unsafe.string_attrib "some-attr" "value"] []] + ] let ns_nesting = "namespace nesting" , HtmlTests.make Html.[ @@ -374,6 +416,14 @@ let svg = "svg", SvgTests.make Svg.[ [[%svg ""]], [animate ~a:[a_animation_fill `Freeze; a_animation_values ["1"; "2"]] []] ; + "fill_rule type nonzero", + [[%svg ""]], + [path ~a:[a_fill_rule `Nonzero] []] ; + + "fill_rule type evenodd", + [[%svg ""]], + [path ~a:[a_fill_rule `Evenodd] []] ; + ] let svg_element_names = "svg element names", SvgTests.make Svg.[ diff --git a/test/test_svg.ml b/test/test_svg.ml index 5c574db1e..0e158a7ac 100644 --- a/test/test_svg.ml +++ b/test/test_svg.ml @@ -1,9 +1,8 @@ open Tyxml -let to_string = Format.asprintf "%a" (Svg.pp_elt ()) - let tyxml_tests l = - let f (name, (ty : Svg_types.text Svg.elt), s) = + let f (name, ty, s) = + let to_string = Format.asprintf "%a" (Svg.pp_elt ()) in name, `Quick, fun () -> Alcotest.(check string) name (to_string ty) s in List.map f l @@ -16,8 +15,26 @@ let svg_attributes = "svg attributes", tyxml_tests Svg.[ ] +let svg_filters = "svg filters", tyxml_tests Svg.[ + + "filter gaussian blur", + filter ~a:[ a_x (-0.1, None) ; a_y (-0.1, None) ; a_width (0.2, None) ; a_height (0.2, None) ] + [ feGaussianBlur ~a:[a_stdDeviation (0.2, None)] [] ], + "" ; + + "linear gradient", + linearGradient ~a:[ a_gradientTransform [`Rotate ((10., None), Some (0.5, 0.5))] ] + [ + stop ~a:[ a_offset (`Percentage 0.) ; a_stop_color "white" ] [] ; + stop ~a:[ a_offset (`Percentage 100.) ; a_stop_color "red" ] [] + ], + "" + +] + let tests = [ svg_attributes ; + svg_filters ] let () = Alcotest.run "tyxml-svg" tests diff --git a/tyxml-syntax.opam b/tyxml-syntax.opam index d556c36c6..5c04ead8b 100644 --- a/tyxml-syntax.opam +++ b/tyxml-syntax.opam @@ -9,7 +9,7 @@ doc: "https://ocsigen.org/tyxml/latest/manual/intro" bug-reports: "https://github.com/ocsigen/tyxml/issues" depends: [ "dune" {>= "2.7"} - "ocaml" {>= "4.02"} + "ocaml" {>= "4.04"} "alcotest" {with-test} "ppxlib" {>= "0.18"} "re" {>= "1.5.0"} diff --git a/tyxml.opam b/tyxml.opam index 569701ece..d6384fd8f 100644 --- a/tyxml.opam +++ b/tyxml.opam @@ -11,7 +11,7 @@ doc: "https://ocsigen.org/tyxml/latest/manual/intro" bug-reports: "https://github.com/ocsigen/tyxml/issues" depends: [ "dune" {>= "2.7"} - "ocaml" {>= "4.02"} + "ocaml" {>= "4.04"} "alcotest" {with-test} "re" {>= "1.5.0"} "seq"