Please sign in to comment.
Let extended translators override what XPathExpr class is used
GenericTranslator offers an excelent way to support custom selectors trough method hooks and allowing to return a *new* XPathExpr from this hooks. The main problem is that returning extended `XPathExpr` instances fail for combiners because `XPathExpr.join()` assume a fixed XPathExpr instance attributes (element, path and condition) to copy from `other` to `self` `XPathExpr.join()` can be extended in subclass but needs that `left` xpath instance to be of the extended class too, and right now we can only control `right` xpath type. The problem can be mitigated by recasting all xpath returned from `GenericTranslator.xpath_element()` that only works because it is the only hook that cast `XPathExpr` instances. The proposed change allow projects extending GenericTranslator to also safely extend `XPathExpr` to correctly support combiners in extended features.
- Loading branch information...