diff --git a/parsel/csstranslator.py b/parsel/csstranslator.py index 24834622..43b6a790 100644 --- a/parsel/csstranslator.py +++ b/parsel/csstranslator.py @@ -98,16 +98,26 @@ def xpath_text_simple_pseudo_element(self, xpath): class GenericTranslator(TranslatorMixin, OriginalGenericTranslator): + @lru_cache(maxsize=256) def css_to_xpath(self, css, prefix='descendant-or-self::'): return super(GenericTranslator, self).css_to_xpath(css, prefix) + def xpath_pseudo_element(self, xpath, pseudo_element): + return TranslatorMixin.xpath_pseudo_element( + self, xpath, pseudo_element) + class HTMLTranslator(TranslatorMixin, OriginalHTMLTranslator): + @lru_cache(maxsize=256) def css_to_xpath(self, css, prefix='descendant-or-self::'): return super(HTMLTranslator, self).css_to_xpath(css, prefix) + def xpath_pseudo_element(self, xpath, pseudo_element): + return TranslatorMixin.xpath_pseudo_element( + self, xpath, pseudo_element) + _translator = HTMLTranslator()