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
Conversation
✅ Deploy Preview for unocss canceled.
|
} | ||
/* you can have multiple rules */ | ||
[custom~=\\"\\\\31 \\"]::after { | ||
.custom-2::after { |
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.
This seems not correct 🤔
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.
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:
unocss/test/preset-attributify.test.ts
Lines 87 to 91 in 0c861eb
[/^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.
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.