def instance.root

gralha-svg-render@0.1.0.1 · svg.bend:2771

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-xml-doc@0.1.0.1/xml.bend as XML
import gralha-css-style@0.1.0.1/css.bend as CSS

2771def instance.root(result: Maybe<&2, XML.Element>, +useAttrs: List<&2, XML.Attr>) -> List<&2, XML.Element>:
2772  match result:
2773    case None{}: Nil{}
2774    case Some{XML.Element{n, attrs, kids, txt}}:
2775      +tagname = n
2776      +as = CSS.properties(attrs)
2777      +width = XML.attr.get(useAttrs, "width", "auto")
2778      +height = XML.attr.get(useAttrs, "height", "auto")
2779      +viewport = U.string.equal(tagname, "svg") || U.string.equal(tagname, "symbol")
2780      Con{XML.Element{U.choose(String, U.string.equal(tagname, "symbol"), "svg", tagname),
2781        U.choose(List<&2, XML.Attr>, viewport,
2782          Con{XML.Attr{"style", ""}, Con{XML.Attr{"width", U.choose(String, U.string.equal(width, "auto"), XML.attr.get(as, "width", "auto"), width)},
2783            Con{XML.Attr{"height", U.choose(String, U.string.equal(height, "auto"), XML.attr.get(as, "height", "auto"), height)}, as}}}, as), kids, txt}, Nil{}}

Uses (10)

Used by (1)