@@ -13,8 +13,10 @@ function composeVisitors(visitors) {
1313
1414 /** @type Visitor */
1515 let res = { } ;
16- composeObjectVisitors ( res , visitors , 'Rule' , ruleVisitor , wrapUnknownAtRule ) ;
17- composeObjectVisitors ( res , visitors , 'RuleExit' , ruleVisitor , wrapUnknownAtRule ) ;
16+ composeSimpleVisitors ( res , visitors , 'StyleSheet' ) ;
17+ composeSimpleVisitors ( res , visitors , 'StyleSheetExit' ) ;
18+ composeObjectVisitors ( res , visitors , 'Rule' , ruleVisitor , wrapCustomAndUnknownAtRule ) ;
19+ composeObjectVisitors ( res , visitors , 'RuleExit' , ruleVisitor , wrapCustomAndUnknownAtRule ) ;
1820 composeObjectVisitors ( res , visitors , 'Declaration' , declarationVisitor , wrapCustomProperty ) ;
1921 composeObjectVisitors ( res , visitors , 'DeclarationExit' , declarationVisitor , wrapCustomProperty ) ;
2022 composeSimpleVisitors ( res , visitors , 'Url' ) ;
@@ -45,8 +47,14 @@ function composeVisitors(visitors) {
4547
4648module . exports = composeVisitors ;
4749
48- function wrapUnknownAtRule ( k , f ) {
49- return k === 'unknown' ? ( value => f ( { type : 'unknown' , value } ) ) : f ;
50+ function wrapCustomAndUnknownAtRule ( k , f ) {
51+ if ( k === 'unknown' ) {
52+ return ( value => f ( { type : 'unknown' , value } ) ) ;
53+ }
54+ if ( k === 'custom' ) {
55+ return ( value => f ( { type : 'custom' , value } ) ) ;
56+ }
57+ return f ;
5058}
5159
5260function wrapCustomProperty ( k , f ) {
@@ -66,6 +74,13 @@ function ruleVisitor(f, item) {
6674 }
6775 return v ?. ( item . value ) ;
6876 }
77+ if ( item . type === 'custom' ) {
78+ let v = f . custom ;
79+ if ( typeof v === 'object' ) {
80+ v = v [ item . value . name ] ;
81+ }
82+ return v ?. ( item . value ) ;
83+ }
6984 return f [ item . type ] ?. ( item ) ;
7085 }
7186 return f ?. ( item ) ;
0 commit comments