def element.find

gralha-xml-doc@0.1.0.1 · xml.bend:325

import gralha-xml-doc@0.1.0.1/xml.bend as Xml
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

325def element.find(+xs: List<&2, Element>, +id: String) -> Maybe<&2, Element>:
326  match xs:
327    case Nil{}: None{}
328    case Con{Element{n, as, kids, txt}, rest}:
329      U.branch(Maybe<&2, Element>, U.string.equal(attr.get(as, "id", ""), id),
330        _ => Some{Element{n, as, kids, txt}},
331        _ => element.prefer(U.branch(Maybe<&2, Element>, U.string.equal(n, "#svg-image"), _ => None{}, _ => element.find(kids, id)), element.find(rest, id)))

Uses (8)

Used by (2)