@@ -231,12 +231,14 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
231
231
232
232
private _sealed : boolean ;
233
233
234
+ private _reservedClassNames : Set < string > ;
235
+
234
236
/** whether all styles have been added and the styles can be analyzed now. */
235
237
get sealed ( ) : boolean {
236
238
return this . _sealed ;
237
239
}
238
240
239
- constructor ( location : SourceLocation , tagName ?: string , id ?: string ) {
241
+ constructor ( reservedClassNames : Set < string > , location : SourceLocation , tagName ?: string , id ?: string ) {
240
242
this . id = id ;
241
243
this . tagName = tagName ;
242
244
this . sourceLocation = location ;
@@ -249,6 +251,7 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
249
251
this . allAttributes = new Set ( ) ;
250
252
this . addedStyles = new Array ( ) ;
251
253
this . _sealed = false ;
254
+ this . _reservedClassNames = reservedClassNames ;
252
255
}
253
256
254
257
hasStyles ( ) : boolean {
@@ -818,15 +821,15 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
818
821
let classes = new Array < AttributeValueSetItem > ( ) ;
819
822
let classMap = new Map < string , Style > ( ) ;
820
823
for ( let style of this . allStaticStyles ) {
821
- let classNames = style . cssClassesWithAliases ( configuration ) ;
824
+ let classNames = style . cssClassesWithAliases ( configuration , this . _reservedClassNames ) ;
822
825
classNames . forEach ( className => {
823
826
classes . push ( attrValues . constant ( className ) ) ;
824
827
classMap . set ( className , style ) ;
825
828
} ) ;
826
829
}
827
830
828
- let mapper : ClassMapper = mapClasses . bind ( null , configuration , classMap ) ;
829
- let choices : ChoiceMapper = mapChoiceClasses . bind ( null , configuration , classMap ) ;
831
+ let mapper : ClassMapper = mapClasses . bind ( null , configuration , this . _reservedClassNames , classMap ) ;
832
+ let choices : ChoiceMapper = mapChoiceClasses . bind ( null , configuration , this . _reservedClassNames , classMap ) ;
830
833
831
834
let depAttrsMap = new MultiMap < BlockClass , DynamicAttrs < BooleanExpression , StringExpression > > ( ) ;
832
835
for ( let dynAttr of this . dynamicAttributes ) {
@@ -986,13 +989,15 @@ function addToSet(
986
989
type ClassMapper = ( style : Style ) => ValueConstant | AttributeValueSet ;
987
990
function mapClasses (
988
991
configuration : ResolvedConfiguration ,
992
+ reservedClassNames : Set < string > ,
989
993
map : Map < string , Style > ,
990
994
style : Style ,
991
995
) : ValueConstant | AttributeValueSet {
992
996
let classes = new Array < string > ( ) ;
993
997
let resolvedStyles = style . resolveStyles ( ) ;
994
998
for ( let resolvedStyle of resolvedStyles ) {
995
- let classNames = resolvedStyle . cssClassesWithAliases ( configuration ) ;
999
+ // TODO: update with a non empty set here
1000
+ let classNames = resolvedStyle . cssClassesWithAliases ( configuration , reservedClassNames ) ;
996
1001
classNames . forEach ( cls => {
997
1002
map . set ( cls , resolvedStyle ) ;
998
1003
classes . push ( cls ) ;
@@ -1008,6 +1013,7 @@ function mapClasses(
1008
1013
type ChoiceMapper = ( includeAbsent : boolean , ...styles : Style [ ] ) => AttributeValueChoice ;
1009
1014
function mapChoiceClasses (
1010
1015
configuration : ResolvedConfiguration ,
1016
+ reservedClassNames : Set < string > ,
1011
1017
map : Map < string , Style > ,
1012
1018
includeAbsent : boolean ,
1013
1019
/* tslint:disable-next-line */
@@ -1018,7 +1024,7 @@ function mapChoiceClasses(
1018
1024
choices . push ( attrValues . absent ( ) ) ;
1019
1025
}
1020
1026
for ( let style of styles ) {
1021
- choices . push ( mapClasses ( configuration , map , style ) ) ;
1027
+ choices . push ( mapClasses ( configuration , reservedClassNames , map , style ) ) ;
1022
1028
}
1023
1029
return attrValues . oneOf ( choices ) ;
1024
1030
}
0 commit comments