Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG: Fix the element <animate> #306

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# NEXT

* 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)

Expand All @@ -20,15 +24,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 @@ -862,7 +862,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,13 +486,13 @@ 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_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 @@ -884,8 +884,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 @@ -963,7 +963,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 @@ -1593,12 +1593,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 @@ -2056,3 +2056,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 @@ -269,10 +269,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 @@ -370,9 +370,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"]] []] ;

]

Expand Down