Skip to content
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

feat(core)!: support string in rule that returns array #1093

Merged
merged 5 commits into from Jun 12, 2022

Conversation

chu121su12
Copy link
Collaborator

Closes #1092.

This PR expanded support for rule to return string inside an array.
The (somewhat) breaking change is that string-returned value will now be sorted among the same token.

@netlify
Copy link

netlify bot commented Jun 11, 2022

Deploy Preview for unocss canceled.

Name Link
🔨 Latest commit a353eeb
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/62a5525ff55fe400087c395b

@chu121su12 chu121su12 marked this pull request as ready for review June 11, 2022 20:27
@chu121su12 chu121su12 requested a review from antfu as a code owner June 11, 2022 20:27
}
/* you can have multiple rules */
[custom~=\\"\\\\31 \\"]::after {
.custom-2::after {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not correct 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the breaking change noted above. The result was swapped with its second result to its bottom.

That particular rule is based on string return, so it will not have selector in StringifiedUtil hence now sorted by its body. Before this PR this condition is not checked and returned as is as css value. That portion of rule start with the captured token used as selector:

[/^custom-(\d+)$/, ([_, value], { rawSelector }) => {
// return a string instead of an object
const selector = e(rawSelector)
return `
${selector} {

The string to extract was <div custom="1" class="custom-2"> yielding [custom~="1"] and .custom-2. Sorting them leads to . < [ hence the swapped result.

@chu121su12 chu121su12 marked this pull request as draft June 12, 2022 02:26
@chu121su12 chu121su12 marked this pull request as ready for review June 12, 2022 02:44
@chu121su12 chu121su12 merged commit 44313e8 into main Jun 12, 2022
@chu121su12 chu121su12 deleted the feat/string-rule branch June 12, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animate @keyframes genrate twice
2 participants