Skip to content

Commit 8d51706

Browse files
committed
Remove circle from HTML_VOID_ELEMENTS set.
`<circle>` is in the SVG_SELF_CLOSING_ELEMENTS list and is not a void element according to 'https://html.spec.whatwg.org/multipage/syntax.html#void-elements'.
1 parent 62b4ca9 commit 8d51706

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

actionview/lib/action_view/helpers/tag_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TagBuilder # :nodoc:
4545
include CaptureHelper
4646
include OutputSafetyHelper
4747

48-
HTML_VOID_ELEMENTS = %i(area base br col circle embed hr img input keygen link meta param source track wbr).to_set
48+
HTML_VOID_ELEMENTS = %i(area base br col embed hr img input keygen link meta param source track wbr).to_set
4949
SVG_SELF_CLOSING_ELEMENTS = %i(animate animateMotion animateTransform circle ellipse line path polygon polyline rect set stop use view).to_set
5050

5151
def initialize(view_context)

actionview/test/template/tag_helper_test.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ def test_tag_builder
2121
def test_tag_builder_void_tag
2222
assert_equal "<br>", tag.br
2323
assert_equal "<br class=\"some_class\">", tag.br(class: "some_class")
24-
assert_equal "<svg><use href=\"#cool-icon\" /></svg>", tag.svg { tag.use("href" => "#cool-icon") }
2524
end
2625

2726
def test_tag_builder_void_tag_with_forced_content
2827
assert_equal "<br>some content</br>", tag.br("some content")
2928
end
3029

30+
def test_tag_builder_self_closing_tag
31+
assert_equal "<svg><use href=\"#cool-icon\" /></svg>", tag.svg { tag.use("href" => "#cool-icon") }
32+
assert_equal "<svg><circle cx=\"5\" cy=\"5\" r=\"5\" /></svg>", tag.svg { tag.circle(cx: "5", cy: "5", r: "5") }
33+
end
34+
35+
def test_tag_builder_self_closing_tag_with_content
36+
assert_equal "<svg><circle><desc>A circle</desc></circle></svg>", tag.svg { tag.circle { tag.desc "A circle" } }
37+
end
38+
3139
def test_tag_builder_is_singleton
3240
assert_equal tag, tag
3341
end

0 commit comments

Comments
 (0)