Improve support for CustomFunction
transforms
#485
Closed
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.
This PR enables authoring custom transformers for
PseudoElement
andPseudoClass
CustomFunction
s.Parsing whitespace inside custom pseudo functions is now more conservative
Previously,
:foo(.bar .baz .qux)
was parsed as:foo(.bar.baz.qux)
which greatly limited custom transformers.This PR bypasses aggressive whitespace removal inside
TokenList::parse_into
behind a flag.To ensure that no API change is introduced, conservative parsing is only enabled for
CustomFunction
via newTokenList::parse_preserve_whitespace
.Selector
manipulations got two more public methodsSelector::append
is a useful method for adding extra components to selectors, however it is quite limited when addingComponent::Combinator
and makes it impossible to reliably append complex expressions like.foo > .bar #baz
Selector::insert_raw(&mut self, index: usize, component: Component)
can be used for inserting new selector components into an arbitrary location, bypassing the limitations ofappend
;Selector::insert_raw_multiple(&mut self, index: usize, mut components: Vec<Component>)
is an optimized version ofinsert_raw
to avoid the extra cost of allocations and memcpy when making multiple calls.Tests
Tests were added to ensure the correctness of a different parsing strategy. No existing tests changed