File tree 2 files changed +12
-2
lines changed
packages/postcss-merge-longhand
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ const { isValidWsc } = require('../validateWsc.js');
20
20
21
21
const wsc = [ 'width' , 'style' , 'color' ] ;
22
22
const defaults = [ 'medium' , 'none' , 'currentcolor' ] ;
23
+ const colorMightRequireFallback =
24
+ / ( h s l a | r g b a | c o l o r | h w b | l a b | l c h | o k l a b | o k l c h ) \( / i;
23
25
24
26
/**
25
27
* @param {...string } parts
@@ -832,9 +834,11 @@ function merge(rule) {
832
834
) ;
833
835
834
836
if ( duplicates . length ) {
835
- if ( / h s l a \( | r g b a \( / i . test ( getColorValue ( lastNode ) ) ) {
837
+ if ( colorMightRequireFallback . test ( getColorValue ( lastNode ) ) ) {
836
838
const preserve = duplicates
837
- . filter ( ( node ) => ! / h s l a \( | r g b a \( / i. test ( getColorValue ( node ) ) )
839
+ . filter (
840
+ ( node ) => ! colorMightRequireFallback . test ( getColorValue ( node ) )
841
+ )
838
842
. pop ( ) ;
839
843
840
844
duplicates = duplicates . filter ( ( node ) => node !== preserve ) ;
Original file line number Diff line number Diff line change @@ -706,6 +706,12 @@ test(
706
706
)
707
707
) ;
708
708
709
+ test (
710
+ 'should not merge fallback colours with color function' ,
711
+ passthroughCSS (
712
+ 'h1{ border-color:rgb(37,45,49);border-color:color(display-p3 0.1451 0.1765 0.1922 / 1)}'
713
+ )
714
+ ) ;
709
715
test (
710
716
'should not merge fallback colours with shorthand property' ,
711
717
processCSS (
You can’t perform that action at this time.
0 commit comments