Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
  • Loading branch information
thecrypticace and RobinMalfait authored Oct 23, 2024
1 parent 2de2160 commit 8d3b2bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/candidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ it('should not parse compound group with a non-compoundable variant', () => {
utilities.static('flex', () => [])

let variants = new Variants()
variants.compoundWith('group', ['selector'], () => {})
variants.compoundWith('group', Compounds.StyleRules, () => {})

expect(run('group-*:flex', { utilities, variants })).toMatchInlineSnapshot(`[]`)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function parseCss(
for (let selector of selectors) {
selector = selector.trim()

if (selector.startsWith('@')) {
if (selector[0] === '@') {
atRuleSelectors.push(selector)
} else {
styleRuleSelectors.push(selector)
Expand Down
6 changes: 3 additions & 3 deletions packages/tailwindcss/src/intellisense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function getVariants(design: DesignSystem) {
let selectors: string[] = []

// Produce v3-style selector strings in the face of nested rules
// This is more visible for things like group-*, not-*, etc…
// this is more visible for things like group-*, not-*, etc…
walkDepth(node.nodes, (node, { path }) => {
if (node.kind !== 'rule') return
if (node.nodes.length > 0) return
Expand All @@ -90,8 +90,8 @@ export function getVariants(design: DesignSystem) {
// This won't actually happen, but it's here to make TypeScript happy
if (a.kind !== 'rule' || b.kind !== 'rule') return 0

let aIsAtRule = a.selector.startsWith('@')
let bIsAtRule = b.selector.startsWith('@')
let aIsAtRule = a.selector[0] === '@'
let bIsAtRule = b.selector[0] === '@'

if (aIsAtRule && !bIsAtRule) return -1
if (!aIsAtRule && bIsAtRule) return 1
Expand Down
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export function createVariants(theme: Theme): Variants {

if (ruleName === 'container') {
// @container {query}
if (parts[0].startsWith('(')) {
if (parts[0][0] === '(') {
return `not ${condition}`
}

Expand Down Expand Up @@ -377,7 +377,7 @@ export function createVariants(theme: Theme): Variants {
if (selector.includes('::')) return null

let selectors = segment(selector, ',').map((sel) => {
// Remove unncessary wrapping &:is(…) to reduce the selector size
// Remove unnecessary wrapping &:is(…) to reduce the selector size
if (sel.startsWith('&:is(') && sel.endsWith(')')) {
sel = sel.slice(5, -1)
}
Expand Down

0 comments on commit 8d3b2bc

Please sign in to comment.