@@ -251,7 +251,10 @@ ValidationTypes = {
251
251
i , len , found = false ;
252
252
253
253
for ( i = 0 , len = args . length ; i < len && ! found ; i ++ ) {
254
- if ( text === args [ i ] . toLowerCase ( ) ) {
254
+ if ( args [ i ] . slice ( - 2 ) === "()" ) {
255
+ found = ( part . type === "function" &&
256
+ part . name === args [ i ] . slice ( 0 , - 2 ) ) ;
257
+ } else if ( text === args [ i ] . toLowerCase ( ) ) {
255
258
found = true ;
256
259
}
257
260
}
@@ -344,7 +347,7 @@ ValidationTypes = {
344
347
} ,
345
348
346
349
"<attr>" : function ( part ) {
347
- return part . type === "function" && part . name === "attr" ;
350
+ return ValidationTypes . isLiteral ( part , "attr()" ) ;
348
351
} ,
349
352
350
353
"<bg-image>" : function ( part ) {
@@ -360,7 +363,7 @@ ValidationTypes = {
360
363
} ,
361
364
362
365
"<content>" : function ( part ) {
363
- return part . type === "function" && part . name === "content" ;
366
+ return ValidationTypes . isLiteral ( part , "content()" ) ;
364
367
} ,
365
368
366
369
"<relative-size>" : function ( part ) {
@@ -438,17 +441,15 @@ ValidationTypes = {
438
441
} ,
439
442
440
443
"<shape>" : function ( part ) {
441
- return part . type === "function" && ( part . name === "rect" || part . name === " inset-rect") ;
444
+ return ValidationTypes . isLiteral ( part , "rect() | inset-rect() " ) ;
442
445
} ,
443
446
444
447
"<basic-shape>" : function ( part ) {
445
448
// inset() = inset( <shape-arg>{1,4} [round <border-radius>]? )
446
449
// circle() = circle( [<shape-radius>]? [at <position>]? )
447
450
// ellipse() = ellipse( [<shape-radius>{2}]? [at <position>]? )
448
451
// polygon() = polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )
449
- return part . type === "function" && (
450
- part . name === "inset" || part . name === "circle" || part . name === "ellipse" || part . name === "polygon"
451
- ) ;
452
+ return ValidationTypes . isLiteral ( part , "inset() | circle() | ellipse() | polygon()" ) ;
452
453
} ,
453
454
454
455
"<shape-box>" : function ( part ) {
@@ -492,18 +493,11 @@ ValidationTypes = {
492
493
} ,
493
494
494
495
"<filter-function>" : function ( part ) {
495
- return part . type === "function" && (
496
- part . name === 'blur' ||
497
- part . name === 'brightness' ||
498
- part . name === 'contrast' ||
499
- part . name === 'custom' || // Not actually in formal spec.
500
- part . name === 'drop-shadow' ||
501
- part . name === 'grayscale' ||
502
- part . name === 'hue-rotate' ||
503
- part . name === 'invert' ||
504
- part . name === 'opacity' ||
505
- part . name === 'saturate' ||
506
- part . name === 'sepia' ) ;
496
+ // custom() isn't actually in the spec
497
+ return ValidationTypes . isLiteral (
498
+ part , "blur() | brightness() | contrast() | custom() | " +
499
+ "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
500
+ "opacity() | saturate() | sepia()" ) ;
507
501
}
508
502
} ,
509
503
0 commit comments