File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/postcss-merge-longhand Expand file tree Collapse file tree 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');
2020
2121const wsc = [ 'width' , 'style' , 'color' ] ;
2222const 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;
2325
2426/**
2527 * @param {...string } parts
@@ -832,9 +834,11 @@ function merge(rule) {
832834 ) ;
833835
834836 if ( duplicates . length ) {
835- if ( / h s l a \( | r g b a \( / i . test ( getColorValue ( lastNode ) ) ) {
837+ if ( colorMightRequireFallback . test ( getColorValue ( lastNode ) ) ) {
836838 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+ )
838842 . pop ( ) ;
839843
840844 duplicates = duplicates . filter ( ( node ) => node !== preserve ) ;
Original file line number Diff line number Diff line change @@ -706,6 +706,12 @@ test(
706706 )
707707) ;
708708
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+ ) ;
709715test (
710716 'should not merge fallback colours with shorthand property' ,
711717 processCSS (
You can’t perform that action at this time.
0 commit comments