Symptom
Today, the query map syntax supports a number of "functions," identified using :fn/* keywords, that expand into specific, helpful XPath constructs. The (Clojure) function that performs this expansion to XPath is etaoin.impl.xpath/expand. Today, if you supply expand with an unknown "function," say :fn/unknown, it doesn't throw an exception, but silently converts such a function to a search for an element with an attribute named unknown.
For example:
user> (xpath/expand {:fn/has-text "some test"}) ;; known "function" - OK
".//*[contains(text(), \"some test\")]"
user> (xpath/expand {:unknown-attr :value}) ;; random attribute - OK
".//*[@unknown-attr=\"value\"]"
user> (xpath/expand {:fn/unknown-attr :value}) ;; random unknown "function" - should throw
".//*[@unknown-attr=\"value\"]"
Actual behavior
Just silently accepts the unknown :fn/* keyword, strips off the fn namespace, and uses it like it would any other keyword specifying an attribute to search for.
Expected behavior
When supplied with an unknown function keyword, expand should throw an error and identify the keyword. If this is not done, simple typos can be very difficult to debug because they are silently converted to queries for attributes.
Diagnosis
The etaoin.impl.xpath/expand function doesn't check for unknown function keywords.
Version 1.1.41
Platform All
Symptom Today, the
query
map syntax supports a number of "functions," identified using:fn/*
keywords, that expand into specific, helpful XPath constructs. The (Clojure) function that performs this expansion to XPath isetaoin.impl.xpath/expand
. Today, if you supplyexpand
with an unknown "function," say:fn/unknown
, it doesn't throw an exception, but silently converts such a function to a search for an element with an attribute namedunknown
.For example:
Actual behavior Just silently accepts the unknown
:fn/*
keyword, strips off thefn
namespace, and uses it like it would any other keyword specifying an attribute to search for.Expected behavior When supplied with an unknown function keyword,
expand
should throw an error and identify the keyword. If this is not done, simple typos can be very difficult to debug because they are silently converted to queries for attributes.Diagnosis The
etaoin.impl.xpath/expand
function doesn't check for unknown function keywords.Action I'll submit a PR.