def css.attr.test

gralha-css-style@0.1.0.1 · css.bend:121

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
import gralha-xml-doc@0.1.0.1/xml.bend as XML

121def css.attr.test(scan: U.Scan, +as: List<&2, XML.Attr>) -> Bool:
122  U.Scan{k, tail} = scan
123  +key = k
124  +rest = U.trim(tail)
125  +op = U.choose(String, U.prefix(rest, "="), "=", U.choose(String, U.prefix(rest, "~="), "~=", U.choose(String, U.prefix(rest, "|="), "|=", U.choose(String, U.prefix(rest, "^="), "^=", U.choose(String, U.prefix(rest, "$="), "$=", "*=")))))
126  +v = U.trim(U.drop(rest, op))
127  +actual = XML.attr.get(as, key, "#missing-css-attribute#")
128  U.branch(Bool, U.string.equal(rest, ""), _ => Bool.not(U.string.equal(actual, "#missing-css-attribute#")),
129    _ => Bool.not(U.string.equal(actual, "#missing-css-attribute#")) && css.attr.compare(XML.value(v), actual, op))

Uses (16)

Used by (1)