Skip to content

Commit

Permalink
Merge pull request #306 from ilankri/svg-fix-animate
Browse files Browse the repository at this point in the history
SVG: Fix the element `<animate>`
  • Loading branch information
Drup committed Sep 27, 2023
2 parents bf3d9cb + 6537b2f commit c05cb5c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
8 changes: 6 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* Expand options for `autocomplete` attribute on `<input>` elements
(#302 by Aron @aronerben Erben)

* Fix the SVG element `<animate>` (by the way, deprecate `animation` et
al. in favor of `animate` et al.)
(#306 by Idir @ilankri Lankri)

* Add support for `dialog` element and `onclose` attribute
(#301 by Julien Sagot)
* Add an escape hatch for emitting attributes with non-standard names
Expand All @@ -30,15 +34,15 @@

# 4.4.0

* Add support for Reason's JSX syntax with a new `tyxml-jsx` package
* Add support for Reason's JSX syntax with a new `tyxml-jsx` package
(#254 by Joris Giovannangeli and Gabriel Radanne
with help from Ulrik Strid and Louis Roché)
* Modernize the handling of toplevel printers for utop.
(Gabriel Radanne)

## Elements and attributes

* Add `allowfullscreen`, `allowpaymentrequest`, `referrerpolicy` attributes
* Add `allowfullscreen`, `allowpaymentrequest`, `referrerpolicy` attributes
(#242 by Thibault Suzanne)
* Allow `crossorigin` attribute for script element
(#243 by Thibault Suzanne)
Expand Down
4 changes: 3 additions & 1 deletion lib/svg_f.ml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,9 @@ struct

let script = unary "script"

let animation = star "animate"
let animate = star "animate"

let animation = animate

let set = star "set"

Expand Down
15 changes: 10 additions & 5 deletions lib/svg_sigs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@ module type T = sig
val a_fill : paint wrap -> [> | `Fill ] attrib

val a_animation_fill : [< | `Freeze | `Remove ] wrap -> [> | `Fill_Animation ] attrib
[@@reflect.attribute "fill" ["animation"]]
[@@reflect.attribute "fill" ["animate"]]

val a_fill_rule : fill_rule wrap -> [> | `Fill_rule ] attrib

val a_calcMode :
[< | `Discrete | `Linear | `Paced | `Spline ] wrap -> [> | `CalcMode ] attrib

val a_animation_values : strings wrap -> [> | `Valuesanim ] attrib
[@@reflect.attribute "values" ["animation"]]
[@@reflect.attribute "values" ["animate"]]

val a_keyTimes : strings wrap -> [> | `KeyTimes ] attrib

Expand Down Expand Up @@ -886,8 +886,8 @@ module type T = sig
val script :
([< | script_attr], [< | script_content], [> | script]) unary

val animation :
([< | animation_attr], [< | animation_content], [> | animation]) star
val animate :
([< | animate_attr], [< | animate_content], [> | animate]) star

val set : ([< | set_attr], [< | set_content], [> | set]) star

Expand Down Expand Up @@ -965,7 +965,12 @@ module type T = sig
[@@ocaml.deprecated "Use txt instead"]
(** @deprecated Use txt instead *)

(** {2 Conversion with untyped representation}
val animation :
([< | animate_attr], [< | animate_content], [> | animate]) star
[@@ocaml.deprecated "Use animate instead"]
(** @deprecated Use animate instead *)

(** {2 Conversion with untyped representation}
WARNING: These functions do not ensure HTML or SVG validity! You should
always explicitly given an appropriate type to the output.
Expand Down
20 changes: 17 additions & 3 deletions lib/svg_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1597,12 +1597,12 @@ type script_attr =
| `Xlink_href
]

type animation = [ | `Animation ]
type animate = [ | `Animate ]

(* star *)
type animation_content = descriptive_element
type animate_content = descriptive_element

type animation_attr =
type animate_attr =
[
| conditional_processing_attr
| core_attr
Expand Down Expand Up @@ -2060,3 +2060,17 @@ type big_variant =
| `XML
| `Xor
]

(** {2 Deprecated} *)

type animation = animate
[@@ocaml.deprecated "Use animate instead"]
(** @deprecated Use animate instead *)

type animation_content = animate_content
[@@ocaml.deprecated "Use animate_content instead"]
(** @deprecated Use animate_content instead *)

type animation_attr = animate_attr
[@@ocaml.deprecated "Use animate_attr instead"]
(** @deprecated Use animate_attr instead *)
8 changes: 4 additions & 4 deletions test/test_jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ let basics = (
},
],
[p([a([])])],
)
)
],
),
);
Expand Down Expand Up @@ -322,10 +322,10 @@ let svg = (
[feMorphology(~a=[a_feMorphology_operator(`Erode)], [])],
),
(
"animation fill, values",
[<animation fill="freeze" values="1 2" />],
"animate fill, values",
[<animate fill="freeze" values="1 2" />],
[
animation(
animate(
~a=[a_animation_fill(`Freeze), a_animation_values(["1", "2"])],
[],
),
Expand Down
8 changes: 4 additions & 4 deletions test/test_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ let basics = "ppx basics", HtmlTests.make Html.[

"datalist",
[[%html {|<datalist>
<option value="foo">foo</option>
<option value="foo">foo</option>
</datalist>|}]],
[datalist ~children:(`Options [option ~a:[a_value "foo"] (txt "foo")]) ()];

Expand Down Expand Up @@ -412,9 +412,9 @@ let svg = "svg", SvgTests.make Svg.[
[[%svg "<feMorphology operator='erode'/>"]],
[feMorphology ~a:[a_feMorphology_operator `Erode] []] ;

"animation fill, values",
[[%svg "<animation fill='freeze' values='1 2'/>"]],
[animation ~a:[a_animation_fill `Freeze; a_animation_values ["1"; "2"]] []] ;
"animate fill, values",
[[%svg "<animate fill='freeze' values='1 2'/>"]],
[animate ~a:[a_animation_fill `Freeze; a_animation_values ["1"; "2"]] []] ;

"fill_rule type nonzero",
[[%svg "<path fill-rule='nonzero'/>"]],
Expand Down

0 comments on commit c05cb5c

Please sign in to comment.