Fragment
Several nodes with no element of their own.
A Fragment renders its children and nothing of its own, so one tree child can become several DOM nodes, and every index after it would run ahead of the tree if the fragment were left in place. For example, div(span("a"), text("x") ++ text("y"), span("z")) renders `
axyz, which a browser parses as three DOM children; left unspliced, the two text nodes would sit behind one tree child. [[Tag.apply]] is the guard: it splices aFragmentchild into its parent's children, then merges adjacentTextchildren and drops empty ones, because the parser knows no boundary betweenxandyeither, so anElementbuilt through a tag holds exactly three children here and tree child index equals DOM child index. That guard isTag.apply's alone; building anElementby hand with aFragmentamong its children, or nesting oneFragment` inside another before it reaches a tag, sits outside it. The case survives as a root level value, where there is no parent to index into.
Attributes
- Source
- Html.scala