@@ -57,15 +57,16 @@ export class StylesheetBuilder {
5757 animations ?: AnimationRecord ;
5858 rem : number ;
5959 ruleOrder : number ;
60+ warningProperty ?: string ;
6061 warningProperties : string [ ] ;
61- warningValues : [ string , unknown ] [ ] ;
62+ warningValues : Record < string , unknown [ ] > ;
6263 warningFunctions : string [ ] ;
6364 } = {
6465 ruleSets : { } ,
6566 rem : 14 ,
6667 ruleOrder : 0 ,
6768 warningProperties : [ ] ,
68- warningValues : [ ] ,
69+ warningValues : { } ,
6970 warningFunctions : [ ] ,
7071 } ,
7172 private selectors ?: NormalizeSelector [ ] ,
@@ -172,30 +173,60 @@ export class StylesheetBuilder {
172173 ) ;
173174 }
174175
176+ setWarningProperty ( property : string ) {
177+ this . shared . warningProperty = property ;
178+ }
179+
180+ addWarning ( type : "property" | "value" , property : string ) : void ;
181+ addWarning ( type : "style" , property : string , value : unknown ) : void ;
175182 addWarning (
176- type : "property" | "value " | "function " ,
183+ type : "property" | "style " | "value " ,
177184 property : string ,
178185 value ?: unknown ,
179186 ) : void {
180187 switch ( type ) {
181188 case "property" :
182189 this . shared . warningProperties . push ( property ) ;
183190 break ;
184- case "value" :
185- this . shared . warningValues . push ( [ property , value ] ) ;
191+ case "value" : {
192+ value = property ;
193+ property = this . shared . warningProperty ?? "" ;
194+
195+ if ( ! property ) {
196+ return ;
197+ }
198+
199+ this . shared . warningValues [ property ] ??= [ ] ;
200+ this . shared . warningValues [ property ] ?. push ( value ) ;
186201 break ;
187- case "function" :
188- this . shared . warningFunctions . push ( property ) ;
202+ }
203+ case "style" :
204+ this . shared . warningValues [ property ] ??= [ ] ;
205+ this . shared . warningValues [ property ] ?. push ( value ) ;
189206 break ;
190207 }
191208 }
192209
193210 getWarnings ( ) {
194- return {
195- properties : this . shared . warningProperties ,
196- values : this . shared . warningValues ,
197- functions : this . shared . warningFunctions ,
198- } ;
211+ const result : {
212+ properties ?: string [ ] ;
213+ values ?: Record < string , unknown [ ] > ;
214+ functions ?: string [ ] ;
215+ } = { } ;
216+
217+ if ( this . shared . warningProperties . length ) {
218+ result . properties = this . shared . warningProperties ;
219+ }
220+
221+ if ( Object . keys ( this . shared . warningValues ) . length ) {
222+ result . values = this . shared . warningValues ;
223+ }
224+
225+ if ( this . shared . warningFunctions . length ) {
226+ result . functions = this . shared . warningFunctions ;
227+ }
228+
229+ return result ;
199230 }
200231
201232 addMapping ( mapping : StyleRuleMapping ) {
0 commit comments