44from string .templatelib import Interpolation , Template
55
66from .nodes import VOID_ELEMENTS
7- from .placeholders import FRAGMENT_TAG , PlaceholderState
7+ from .placeholders import PlaceholderState
88from .tnodes import (
99 TAttribute ,
1010 TComment ,
@@ -171,10 +171,6 @@ def make_open_tag(self, tag: str, attrs: t.Sequence[HTMLAttribute]) -> OpenTag:
171171 tag_ref = self .placeholders .remove_placeholders (tag )
172172
173173 if tag_ref .is_literal :
174- if tag == FRAGMENT_TAG :
175- if attrs :
176- raise ValueError ("Fragments cannot have attributes." )
177- return OpenTFragment ()
178174 return OpenTElement (tag = tag , attrs = self .make_tattrs (attrs ))
179175
180176 if not tag_ref .is_singleton :
@@ -230,11 +226,7 @@ def validate_end_tag(self, tag: str, open_tag: OpenTag) -> int | None:
230226 return None
231227
232228 case OpenTFragment ():
233- if not tag_ref .is_literal :
234- raise ValueError ("Component closing tag found for fragment." )
235- if tag != FRAGMENT_TAG :
236- raise ValueError (f"Mismatched closing tag </{ tag } > for fragment." )
237- return None
229+ raise NotImplementedError ("We do not support anonymous fragments." )
238230
239231 case OpenTComponent (start_i_index = start_i_index ):
240232 if tag_ref .is_literal :
@@ -327,7 +319,7 @@ def get_tnode(self) -> TNode:
327319 if len (self .root .children ) > 1 :
328320 # The parse structure results in multiple root elements, so we
329321 # return a Fragment to hold them all.
330- return TFragment ( children = tuple ( self .root . children ) )
322+ return self . finalize_tag ( self .root )
331323 elif len (self .root .children ) == 1 :
332324 # The parse structure results in a single root element, so we
333325 # return that element directly. This will be a non-Fragment Node.
@@ -336,16 +328,14 @@ def get_tnode(self) -> TNode:
336328 # Special case: the parse structure is empty; we treat
337329 # this as an empty document fragment.
338330 # CONSIDER: or as an empty text node?
339- return TFragment ( children = tuple () )
331+ return self . finalize_tag ( self . root )
340332
341333 # ------------------------------------------
342334 # Feeding and parsing
343335 # ------------------------------------------
344336
345337 def feed_str (self , s : str ) -> None :
346338 """Feed a string part of a Template to the parser."""
347- # TODO: add tracking for this, or maybe just deprecate it?
348- s = s .replace ("<>" , f"<{ FRAGMENT_TAG } >" ).replace ("</>" , f"</{ FRAGMENT_TAG } >" )
349339 self .feed (s )
350340
351341 def feed_interpolation (self , index : int ) -> None :
0 commit comments