diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index bfb9c0c81c..265619ffb0 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -45,7 +45,7 @@ class TagBuilder # :nodoc: include CaptureHelper include OutputSafetyHelper - HTML_VOID_ELEMENTS = %i(area base br col circle embed hr img input keygen link meta param source track wbr).to_set + HTML_VOID_ELEMENTS = %i(area base br col embed hr img input keygen link meta param source track wbr).to_set SVG_SELF_CLOSING_ELEMENTS = %i(animate animateMotion animateTransform circle ellipse line path polygon polyline rect set stop use view).to_set def initialize(view_context) diff --git a/actionview/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb index d32ed734db..e7b506fa1b 100644 --- a/actionview/test/template/tag_helper_test.rb +++ b/actionview/test/template/tag_helper_test.rb @@ -21,13 +21,21 @@ def test_tag_builder def test_tag_builder_void_tag assert_equal "
", tag.br assert_equal "
", tag.br(class: "some_class") - assert_equal "", tag.svg { tag.use("href" => "#cool-icon") } end def test_tag_builder_void_tag_with_forced_content assert_equal "
some content
", tag.br("some content") end + def test_tag_builder_self_closing_tag + assert_equal "", tag.svg { tag.use("href" => "#cool-icon") } + assert_equal "", tag.svg { tag.circle(cx: "5", cy: "5", r: "5") } + end + + def test_tag_builder_self_closing_tag_with_content + assert_equal "A circle", tag.svg { tag.circle { tag.desc "A circle" } } + end + def test_tag_builder_is_singleton assert_equal tag, tag end