Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this PR intended to solve?
In preparation for #2560's work to introduce a new CSS selector parser, I want to take the opportunity to clean some things up, including the awkward cache API that I wrote in (gulp) 2008.
None of this should be considered a breaking change, since the
CSS::Parser
and related classes are undocumented and considered internal-only (with the notable exception ofCSS::XPathVisitor
).Big changes in this PR:
CSS::SelectorCache
CSS.xpath_for
takes acache:
kwarg and this is where the caching is done (not in the Parser)CSS.set_cache
,CSS.cache_on?
andCSS.without_cache(&blk)
. Using thecache:
argument toCSS.xpath_for
should be sufficient and is in fact clearer code to write.prefix
parameter for CSS-to-XPath transpilation is now pushed into theXPathVisitor
class rather than being handled as an additional argument.CSS::Parser
API has changed: the selector is now passed to.new
and not#parse
.Smaller changes:
CSS.xpath_for
deprecates the options hash and emits a warning. Users should prefer keyword arguments.CSS.parse
is deprecated and emits a warnings. (I will probably remove this in the parser rewrite since it returns an AST that is not supported.)XPathVisitor
exposes#prefix
,#builtins
, and#doctype
attributes.CSS.xpath_for
.@tenderlove I would love your eyeballs on this if you get a few minutes.
Have you included adequate test coverage?
Yes.
Does this change affect the behavior of either the C or the Java implementations?
No native behavior changes.