Skip to content

Commit

Permalink
Merge pull request #44585 from davekaro/remove_circle_void_element
Browse files Browse the repository at this point in the history
Remove circle from HTML_VOID_ELEMENTS set.
  • Loading branch information
byroot committed Mar 2, 2022
2 parents 5772ecd + 8d51706 commit 13dd6f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/tag_helper.rb
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion actionview/test/template/tag_helper_test.rb
Expand Up @@ -21,13 +21,21 @@ def test_tag_builder
def test_tag_builder_void_tag
assert_equal "<br>", tag.br
assert_equal "<br class=\"some_class\">", tag.br(class: "some_class")
assert_equal "<svg><use href=\"#cool-icon\" /></svg>", tag.svg { tag.use("href" => "#cool-icon") }
end

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

def test_tag_builder_self_closing_tag
assert_equal "<svg><use href=\"#cool-icon\" /></svg>", tag.svg { tag.use("href" => "#cool-icon") }
assert_equal "<svg><circle cx=\"5\" cy=\"5\" r=\"5\" /></svg>", tag.svg { tag.circle(cx: "5", cy: "5", r: "5") }
end

def test_tag_builder_self_closing_tag_with_content
assert_equal "<svg><circle><desc>A circle</desc></circle></svg>", tag.svg { tag.circle { tag.desc "A circle" } }
end

def test_tag_builder_is_singleton
assert_equal tag, tag
end
Expand Down

0 comments on commit 13dd6f9

Please sign in to comment.