-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3544, Allow multiple ancestors to be encapsulated with svelte class in case of ambiguity #3679
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Two more notes I forgot to mention:
|
Conduitry
reviewed
Oct 24, 2019
…kAppliesToNode to have three possible return values from block_might_apply_to_node
@Conduitry I've added an enum and removed the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've fixed issue #3544 by allowing for multiple ancestors to match a selector, in the case that the ancestors have eg. dynamic classes and it's non-deterministic which of the ancestors will match.
I removed the filter that enforced only the first and last node to be encapsulated, so now multiple nodes are able to be encapsulated for a single selector-node pairing.
I didn't want to lose the optimization of skipping inner matches, so I had to change the logic so that it iterates over all blocks and ancestors until it finds the outermost non-global block that matches one or more ancestors. We include all the matching ancestors and then also include the child node.
apply_selector
was originally written as a recursive function, but I chose to refactor out part of this into ablock_might_apply_to_node
function so that we're able to compare whether an ancestor node might match a selector block without doing it recursively.Any feedback is very much welcome! This is my first time working with this code base so if there's anything I should have done differently, please let me know.
Thanks!
Before submitting the PR, please make sure you do the following
npm run lint
!)Tests
npm test
oryarn test
)