Skip to content

Commit

Permalink
Use MapSet for self_closing_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ypconstante committed Dec 30, 2023
1 parent e24e3cd commit 5339fa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/floki/raw_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Floki.RawHTML do
_ -> :noop
end

self_closing_tags = self_closing_tags()
self_closing_tags = MapSet.new(self_closing_tags())

IO.iodata_to_binary(build_raw_html(html_tree, [], encoder, padding, self_closing_tags))
end
Expand Down Expand Up @@ -143,7 +143,7 @@ defmodule Floki.RawHTML do
]

defp close_open_tag(type, [], self_closing_tags) do
if type in self_closing_tags do
if MapSet.member?(self_closing_tags, type) do
"/>"
else
">"
Expand All @@ -153,7 +153,7 @@ defmodule Floki.RawHTML do
defp close_open_tag(_type, _children, _self_closing_tags), do: ">"

defp close_end_tag(type, [], padding, self_closing_tags) do
if type in self_closing_tags do
if MapSet.member?(self_closing_tags, type) do
[]
else
[leftpad(padding), "</", type, ">", line_ending(padding)]
Expand Down

0 comments on commit 5339fa3

Please sign in to comment.