starfederation / datastar

A real-time hypermedia framework.
https://data-star.dev/
MIT License
698 stars 37 forks source link

Empty lines are not recovered on the client side #178

Open stefanohrmann opened 4 weeks ago

stefanohrmann commented 4 weeks ago

I think something broke in the last updates, because in the Multiline-Line example not all line breaks are recovered in the DOM: https://data-star.dev/examples/multiline_fragments

I would expect:

 <div id="replaceMe">
            <pre>
This is a multiline fragment.

Used when you are writing a lot of text by hand
            </pre>
        </div>

but got:

<div id="replaceMe" class="">
            <pre>This is a multiline fragment.
Used when you are writing a lot of text by hand
            </pre>
        </div>

The response from the server is:

event: datastar-fragment
id: 0
data: fragment 
data: <div id="replaceMe">
data:             <pre>
data: This is a multiline fragment.
data: 
data: Used when you are writing a lot of text by hand
data:             </pre>
data:         </div>
data:         

I found the following comment that mentioned the removal of empty lines:

https://github.com/delaneyj/datastar/blob/74b637889de58d1ca6bc439710509a9acd15d870/packages/library/src/lib/external/fetch-event-source.ts#L314