-
-
Notifications
You must be signed in to change notification settings - Fork 780
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 safelist access to RuleContext #3693
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1a2eabe
feat(core): support safelist access to RuleContext
Simon-He95 ccf9951
Merge branch 'main' into safeList-feat
Simon-He95 7291941
fix: create safelist context
zyyv de8b17a
Merge branch 'main' into safeList-feat
zyyv 95979be
Merge branch 'main' into safeList-feat
Simon-He95 548fe1e
chore: lint fix
zyyv 2cae065
chore: update
antfu File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,14 @@ export class UnoGenerator<Theme extends object = object> { | |
if (safelist) { | ||
this.config.safelist.forEach((s) => { | ||
// We don't want to increment count if token is already in the set | ||
if (typeof s === 'function') { | ||
const result = toArray(s(this.config)) | ||
result.forEach((s) => { | ||
if (!tokens.has(s)) | ||
tokens.add(s) | ||
}) | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't |
||
} | ||
if (!tokens.has(s)) | ||
tokens.add(s) | ||
}) | ||
|
@@ -284,7 +292,7 @@ export class UnoGenerator<Theme extends object = object> { | |
|| a[2]?.localeCompare(b[2] || '') // body | ||
|| 0 | ||
}) | ||
.map(([, selector, body,, meta,, variantNoMerge]) => { | ||
.map(([, selector, body, , meta, , variantNoMerge]) => { | ||
const scopedSelector = selector ? applyScope(selector, scope) : selector | ||
return [ | ||
[[scopedSelector ?? '', meta?.sort ?? 0]], | ||
|
@@ -725,8 +733,8 @@ export class UnoGenerator<Theme extends object = object> { | |
} | ||
|
||
const merges = [ | ||
[e.filter(([, noMerge]) => noMerge).map(([entries,, sort]) => [entries, sort]), true], | ||
[e.filter(([, noMerge]) => !noMerge).map(([entries,, sort]) => [entries, sort]), false], | ||
[e.filter(([, noMerge]) => noMerge).map(([entries, , sort]) => [entries, sort]), true], | ||
[e.filter(([, noMerge]) => !noMerge).map(([entries, , sort]) => [entries, sort]), false], | ||
] as [[CSSEntries, number][], boolean][] | ||
|
||
return merges.map(([e, noMerge]) => [ | ||
|
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
Oops, something went wrong.
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.
Providing the entire config is a bit heavy, I suggest creating a lightweight context.