Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Дмитрий Жук authored and clshortfuse committed Oct 4, 2023
1 parent 4bede0b commit e06e7c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
18 changes: 7 additions & 11 deletions data/features/flexbox-gap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@
* @type {import('../features').Feature}
*/
export default (rule) => {
if (!('some' in rule)) {
return false;
}
if (!('some' in rule)) return false;

let isFlexbox = false;
let isGap = false;
let hasFlexbox = false;
let hasGap = false;

return rule.some((decl) => {
if (decl.type !== 'decl') {
return false;
}
if (decl.type !== 'decl') return false;

isFlexbox ||= decl.prop === 'display' && (decl.value === 'flex' || decl.value === 'inline-flex');
isGap ||= decl.prop === 'gap' || decl.prop.endsWith('-gap');
hasFlexbox ||= decl.prop === 'display' && (decl.value === 'flex' || decl.value === 'inline-flex');
hasGap ||= decl.prop === 'gap' || decl.prop === 'column-gap' || decl.prop === 'row-gap';

return isFlexbox && isGap;
return hasFlexbox && hasGap;
});
};
7 changes: 6 additions & 1 deletion test/cases/features/flexbox-gap.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See: https://caniuse.com/flexbox-gap

/*
expect:
flexbox-gap: 4
flexbox-gap: 5
*/

.test {
Expand All @@ -29,6 +29,11 @@ flexbox-gap: 4
row-gap: 1rem;
}

.test {
display: flex;
column-gap: 1rem;
}

/* should not trigger */
.test {
display: grid;
Expand Down

0 comments on commit e06e7c6

Please sign in to comment.