Skip to content

Commit 5e18fc5

Browse files
committed
Adding tests for fill-opacity.
1 parent 925474c commit 5e18fc5

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

syntax/attribute_value.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ let fill_opacity =
502502
if group_matched 2 s then (n /. 100.)
503503
else n in
504504

505-
if v >= 0. && v <= 1. then Some [%expr [%e v]]
505+
if v >= 0. && v <= 1. then
506+
Some [%expr [%e (Common.float loc @@ v)]]
506507
else
507508
Common.error loc "Value of %s must be between 0 and 1." name
508509

test/test_jsx.re

+10
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ let svg = (
331331
),
332332
],
333333
),
334+
(
335+
"fill_opacity float, circle",
336+
[<circle cx=1 cy=2 r=3 fill-opacity=0.5 />],
337+
[circle(~a=[a_cx (1., None); a_cy (2., None); a_r (3., None); a_fill_opacity 0.5], [])],
338+
),
339+
(
340+
"fill_opacity percentage, rect",
341+
[<rect x=1 y='2' width=3 height='4' fill-opacity='50%' />],
342+
[rect(~a=[a_cx (1., None); a_cy (2., None); a_width (3., None); a_height (4., None); a_fill_opacity 0.5], [])],
343+
),
334344
(
335345
"fill_rule nonzero",
336346
[<path fill_rule="nonzero" />],

test/test_ppx.ml

+7-3
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,13 @@ let svg = "svg", SvgTests.make Svg.[
416416
[[%svg "<animate fill='freeze' values='1 2'/>"]],
417417
[animate ~a:[a_animation_fill `Freeze; a_animation_values ["1"; "2"]] []] ;
418418

419-
"fill_opacity, circle",
420-
[[%svg "<circle cx=50 cy=50 r=50 fill-opacity=0.5 />"]],
421-
[rect ~a:[a_cx (50., None); a_cy (50., None); a_r (50., None); a_fill_opacity 0.5] []] ;
419+
"fill_opacity float, circle",
420+
[[%svg "<circle cx=1 cy=2 r=3 fill-opacity=0.5 />"]],
421+
[circle ~a:[a_cx (1., None); a_cy (2., None); a_r (3., None); a_fill_opacity 0.5] []] ;
422+
423+
"fill_opacity percentage, rect",
424+
[[%svg "<rect x=1 y='2' width=3 height='4' fill-opacity='50%' />"]],
425+
[rect ~a:[a_cx (1., None); a_cy (2., None); a_width (3., None); a_height (4., None); a_fill_opacity 0.5] []] ;
422426

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

0 commit comments

Comments
 (0)