1- import gleam/int
21import gleam/list
32import gleam/option
43import gleam/pair
@@ -10,7 +9,6 @@ import sketch.{type Cache}
109pub opaque type Element ( msg) {
1110 Nothing
1211 Text ( content : String )
13- Fragment ( key : String , children : List ( Element ( msg) ) )
1412 Map ( subtree : fn ( ) -> Element ( msg) )
1513 Element (
1614 key : String ,
@@ -69,7 +67,8 @@ pub fn namespaced_(
6967}
7068
7169pub fn fragment ( children : List ( Element ( msg) ) ) {
72- Fragment ( "" , children )
70+ let attrs = [ attribute . style ( [ # ( "display" , "contents" ) ] ) ]
71+ Element ( "" , "" , "lustre-fragment" , option . None , attrs , children )
7372}
7473
7574pub fn keyed (
@@ -87,21 +86,6 @@ fn do_keyed(element: Element(msg), key: String) {
8786 Nothing -> Nothing
8887 Text ( content ) -> Text ( content )
8988 Map ( subtree ) -> Map ( fn ( ) { do_keyed ( subtree ( ) , key ) } )
90- Fragment ( _ , children ) ->
91- children
92- |> list . index_map ( fn ( element , idx ) {
93- case element {
94- Element ( el_key , _ , _ , _ , _ , _ ) -> {
95- let new_key = case el_key {
96- "" -> key <> "-" <> int . to_string ( idx )
97- _ -> key <> "-" <> el_key
98- }
99- do_keyed ( element , new_key )
100- }
101- _ -> do_keyed ( element , key )
102- }
103- } )
104- |> Fragment ( key , _)
10589 Element ( _ , namespace , tag , attributes , children , styles ) ->
10690 Element ( key , namespace , tag , attributes , children , styles )
10791 }
@@ -112,7 +96,6 @@ pub fn map(element: Element(a), mapper: fn(a) -> b) {
11296 Nothing -> Nothing
11397 Text ( content ) -> Text ( content )
11498 Map ( subtree ) -> Map ( fn ( ) { map ( subtree ( ) , mapper ) } )
115- Fragment ( key , children ) -> Fragment ( key , list . map ( children , map ( _, mapper ) ) )
11699 Element ( key , namespace , tag , class , attributes , children ) -> {
117100 let attributes = list . map ( attributes , attribute . map ( _, mapper ) )
118101 let children = list . map ( children , map ( _, mapper ) )
@@ -137,9 +120,6 @@ pub fn unstyled(cache: Cache, element: Element(msg)) {
137120 Nothing -> # ( cache , el . none ( ) )
138121 Text ( content ) -> # ( cache , el . text ( content ) )
139122 Map ( subtree ) -> unstyled ( cache , subtree ( ) )
140- Fragment ( _ , children ) ->
141- unstyled_children ( cache , children )
142- |> pair . map_second ( fn ( node ) { el . fragment ( node ) } )
143123 Element ( key , namespace , tag , class , attributes , children ) -> {
144124 let class = option . map ( class , sketch . class_name ( _, cache ) )
145125 let class_name = option . map ( class , pair . second )
0 commit comments