Closed westonruter closed 2 years ago
Alternatively, we could still use the CSS selector parser to construct the XPath expressions with an awareness of which parts are dynamic in an AMP document. Note also:
This is not going to be so straightforward because the library requires PHP 7.1. The plugin currently requires PHP 5.4, though we should soon update to 5.6 like core. But this won't be feasible until PHP 7.1 is the minimum supported version. This could happen in core by the end of 2019, so we might be able to do it at that time.
Symfony has a
CssSelector
component which can be used to convert a CSS selector to an XPath expression. This in theory could be used to do evaluate a given selector against the document to determine whether it applies. This could shake quite a bit of CSS that we currently don't consider, for example selectors with multiple class names. Special care would be needed to account for selectors that interact with elements in an AMP document that are dynamically modified at runtime.