@@ -546,18 +546,13 @@ defmodule Phoenix.LiveView.HTMLFormatter do
546546 opts
547547 ) do
548548 { mode , block } =
549- cond do
550- tag_name in [ "pre" , "textarea" ] or contains_special_attrs? ( attrs ) ->
551- content =
552- content_from_source ( opts . source , open_meta . inner_location , close_meta . inner_location )
549+ if tag_name in [ "pre" , "textarea" ] or contains_special_attrs? ( attrs ) do
550+ content =
551+ content_from_source ( opts . source , open_meta . inner_location , close_meta . inner_location )
553552
554- { :preserve , [ { :text , content , % { newlines_before_text: 0 , newlines_after_text: 0 } } ] }
555-
556- preceeded_by_non_white_space? ( upper_buffer ) ->
557- { :preserve , Enum . reverse ( reversed_buffer ) }
558-
559- true ->
560- { :normal , Enum . reverse ( reversed_buffer ) }
553+ { :preserve , [ { :text , content , % { newlines_before_text: 0 , newlines_after_text: 0 } } ] }
554+ else
555+ { :normal , Enum . reverse ( reversed_buffer ) }
561556 end
562557
563558 tag_block = { :tag_block , tag_name , attrs , block , % { mode: mode } }
@@ -639,15 +634,6 @@ defmodule Phoenix.LiveView.HTMLFormatter do
639634 end
640635 end
641636
642- # In case the opening tag is immediately preceeded by non whitespace text,
643- # or an interpolation, we will set it as preserve.
644- defp preceeded_by_non_white_space? ( [ { :text , text , _meta } | _ ] ) ,
645- do: String . trim_leading ( text ) != "" and :binary . last ( text ) not in ~c" \s \t \n \r "
646-
647- defp preceeded_by_non_white_space? ( [ { :body_expr , _ , _ } | _ ] ) , do: true
648- defp preceeded_by_non_white_space? ( [ { :eex , _ , _ } | _ ] ) , do: true
649- defp preceeded_by_non_white_space? ( _ ) , do: false
650-
651637 # In case the closing tag is immediatelly followed by non whitespace text,
652638 # we want to set mode as preserve.
653639 defp may_set_preserve_on_block ( [ { :tag_block , name , attrs , block , meta } | list ] , text ) do
0 commit comments