-
Notifications
You must be signed in to change notification settings - Fork 3.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
Fixes #1421 - re-parses variable-interpolated elements to selectors #3217
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c383326
WIP - partially solves 1241 but breaks other tests
matthew-dean 15d662a
Fix element to selector list conversion, passing all tests!
matthew-dean d1ed1fe
Add passing test from #3098
matthew-dean 94e7c50
Added passing test example from #1817
matthew-dean 9cec20e
Allow lists to be re-evaluated as selectors (Fixes #1694)
matthew-dean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
input[type=text]:focus, | ||
input[type=email]:focus, | ||
input[type=password]:focus, | ||
textarea:focus { | ||
foo: bar; | ||
} | ||
.a + .z, | ||
.b + .z, | ||
.c + .z { | ||
color: blue; | ||
} | ||
.master-page-1 .selector-1, | ||
.master-page-1 .selector-2 { | ||
background-color: red; | ||
} | ||
.fruit-apple, | ||
.fruit-satsuma, | ||
.fruit-banana, | ||
.fruit-pear { | ||
content: "Just a test."; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@inputs: input[type=text], input[type=email], input[type=password], textarea; | ||
|
||
@{inputs} { | ||
&:focus { | ||
foo: bar; | ||
} | ||
} | ||
|
||
@classes: ~".a, .b, .c"; | ||
|
||
@{classes} { | ||
+ .z { | ||
color: blue; | ||
} | ||
} | ||
|
||
@my-selector: ~'.selector-1, .selector-2'; | ||
.master-page-1 { | ||
@{my-selector} { | ||
background-color: red; | ||
} | ||
} | ||
|
||
@list: apple, satsuma, banana, pear; | ||
@{list} { | ||
.fruit-& { | ||
content: "Just a test."; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about more complex tests like:
etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shit, that borks it entirely. I reverted this PR. Any other test cases you can think of? Basically, I put in the test cases that people had filed as their use cases, but yeah it should be more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, the result of that should be an error, but it doesn't even get close. I THINK that's because I had it jump out if it's an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this working perfectly with:
and more complex cases, and then I tried....
...aaaaaand wasted the rest of my weekend lol.
The problem was I had a kind of "selector merging" behavior with something like:
That is, if we assume that interpolated text should be merged into the selector list, then it stands to reason that it should merged with any adjacent elements and combinators.
All of that I got working, but naïvely. As soon as there were multiple vars containing multiple selectors, elements, and combinators, it borked. Not only would it be inconsistent behavior, it's not clear what the expected behavior SHOULD be.
Maybe a more rational approach is to try to stringify everything in the selector, including the eval'd variable, THEN re-parse the entire selector list, rather than try to parse the variable and merge. That would not allow that
input[class="text"], input.text
output, but that seems to have add-on misery with multiple vars and combinators.I dunno. My brain has died now.