@@ -23,49 +23,9 @@ function printNode(node: PostCSSValueASTNode): string {
23
23
}
24
24
}
25
25
26
- // Splits PostCSS value nodes for border-radius into horizontal and vertical groups by slash.
27
- function splitNodesBySlash (
28
- nodes : PostCSSValueASTNode [ ] ,
29
- ) : PostCSSValueASTNode [ ] [ ] {
30
- const result = [ ] ;
31
- let current = [ ] ;
32
-
33
- for ( const node of nodes ) {
34
- const isSeparator = node . type === 'div' && node . value === '/' ;
35
- if ( isSeparator ) {
36
- if ( current . length > 0 ) {
37
- result . push ( current ) ;
38
- current = [ ] ;
39
- }
40
- } else {
41
- current . push ( node ) ;
42
- }
43
- }
44
-
45
- if ( current . length > 0 ) {
46
- result . push ( current ) ;
47
- }
48
-
49
- return result ;
50
- }
51
-
52
- // Expands a border-radius shorthand value to an array of four values.
53
- function expandBorderRadiusShorthand ( group : PostCSSValueASTNode [ ] ) {
54
- if ( group . length === 2 ) return [ group [ 0 ] , group [ 1 ] , group [ 0 ] , group [ 1 ] ] ;
55
- if ( group . length === 3 ) return [ group [ 0 ] , group [ 1 ] , group [ 2 ] , group [ 1 ] ] ;
56
- if ( group . length === 4 ) return [ group [ 0 ] , group [ 1 ] , group [ 2 ] , group [ 3 ] ] ;
57
- return Array ( 4 ) . fill ( group [ 0 ] ) ;
58
- }
59
-
60
- // Combines two arrays of border-radius values into a single formatted string.
61
- function combineBorderRadiusValues ( verticals : string [ ] , horizontals : string [ ] ) {
62
- return verticals . map ( ( value , i ) => `${ value } ${ horizontals [ i ] } ` ) ;
63
- }
64
-
65
26
// Using split(' ') Isn't enough because of values like calc.
66
27
export default function splitValue (
67
28
str : TStyleValue ,
68
- propertyName : string = '' ,
69
29
) : $ReadOnlyArray < number | string | null > {
70
30
if ( str == null || typeof str === 'number' ) {
71
31
return [ str ] ;
@@ -78,28 +38,9 @@ export default function splitValue(
78
38
79
39
const parsed = parser ( str . trim ( ) ) ;
80
40
81
- let nodes : string [ ] = [ ] ;
82
- if ( propertyName === 'borderRadius' ) {
83
- const groups = splitNodesBySlash (
84
- parsed . nodes . filter ( ( node ) => node . type !== 'space' ) ,
85
- ) ;
86
- if ( groups . length === 1 ) {
87
- nodes = parsed . nodes . filter ( ( node ) => node . type !== 'div' ) . map ( printNode ) ;
88
- } else {
89
- // edge case
90
- const vertical = expandBorderRadiusShorthand (
91
- groups [ 0 ] . filter ( ( node ) => node . type !== 'div' ) ,
92
- ) . map ( printNode ) ;
93
- const horizontal = expandBorderRadiusShorthand (
94
- groups [ 1 ] . filter ( ( node ) => node . type !== 'div' ) ,
95
- ) . map ( printNode ) ;
96
- nodes = combineBorderRadiusValues ( vertical , horizontal ) ;
97
- }
98
- } else {
99
- nodes = parsed . nodes
100
- . filter ( ( node ) => node . type !== 'space' && node . type !== 'div' )
101
- . map ( printNode ) ;
102
- }
41
+ const nodes = parsed . nodes
42
+ . filter ( ( node ) => node . type !== 'space' && node . type !== 'div' )
43
+ . map ( printNode ) ;
103
44
104
45
if (
105
46
nodes . length > 1 &&
0 commit comments