def css.select.scan
gralha-css-style@0.1.0.1 · css.bend:262
import gralha-css-style@0.1.0.1/css.bend as Css
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
262def css.select.scan(scan: U.Scan, +context: CSSContext, +best: CSSMatch, next: String -> CSSMatch -> CSSMatch) -> CSSMatch:
263 U.Scan{h, t} = scan
264 CSSMatch{found, score} = best
265 +sel = U.trim.both(h)
266 +parts = css.parts(sel, 0, Nil{})
267 +hit = Bool.not(U.string.equal(sel, "")) && css.match(parts, Con{context, Nil{}}, True{})
268 +weight = css.specificity(parts)
269 next(U.drop(t, ","))(CSSMatch{found || hit, U.choose(U32, hit && U32.is_gt(weight, score), weight, score)})
270
271@unsafe