diff --git a/src/floki_mochi_html.erl b/src/floki_mochi_html.erl index 2f7c71d8..e66342d3 100644 --- a/src/floki_mochi_html.erl +++ b/src/floki_mochi_html.erl @@ -254,16 +254,16 @@ tree([{doctype, _} | Rest], Stack, Opts) -> tree(Rest, Stack, Opts). norm({Tag, Attrs}, Opts) -> - Attrs = [{norm(K, Opts), iolist_to_binary(V)} || {K, V} <- Attrs], + Attrs0 = [{norm(K, Opts), iolist_to_binary(V)} || {K, V} <- Attrs], case lists:keyfind(attributes_as_maps, 1, Opts) of {attributes_as_maps, true} -> % The HTML specs says we should ignore duplicated attributes and keep the first % occurence of a given key. % Since `maps:from_list/1` does the opposite, we need to reverse the attributes. % See https://github.com/philss/floki/pull/467#discussion_r1225548333 - {norm(Tag, Opts), maps:from_list(lists:reverse(Attrs)), []}; + {norm(Tag, Opts), maps:from_list(lists:reverse(Attrs0)), []}; _ -> - {norm(Tag, Opts), Attrs, []} + {norm(Tag, Opts), Attrs0, []} end; norm(Tag, _Opts) when is_binary(Tag) -> Tag;