@@ -251,7 +251,10 @@ ValidationTypes = {
251251 i , len , found = false ;
252252
253253 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 ( ) ) {
255258 found = true ;
256259 }
257260 }
@@ -344,7 +347,7 @@ ValidationTypes = {
344347 } ,
345348
346349 "<attr>" : function ( part ) {
347- return part . type === "function" && part . name === "attr" ;
350+ return ValidationTypes . isLiteral ( part , "attr()" ) ;
348351 } ,
349352
350353 "<bg-image>" : function ( part ) {
@@ -360,7 +363,7 @@ ValidationTypes = {
360363 } ,
361364
362365 "<content>" : function ( part ) {
363- return part . type === "function" && part . name === "content" ;
366+ return ValidationTypes . isLiteral ( part , "content()" ) ;
364367 } ,
365368
366369 "<relative-size>" : function ( part ) {
@@ -438,17 +441,15 @@ ValidationTypes = {
438441 } ,
439442
440443 "<shape>" : function ( part ) {
441- return part . type === "function" && ( part . name === "rect" || part . name === " inset-rect") ;
444+ return ValidationTypes . isLiteral ( part , "rect() | inset-rect() " ) ;
442445 } ,
443446
444447 "<basic-shape>" : function ( part ) {
445448 // inset() = inset( <shape-arg>{1,4} [round <border-radius>]? )
446449 // circle() = circle( [<shape-radius>]? [at <position>]? )
447450 // ellipse() = ellipse( [<shape-radius>{2}]? [at <position>]? )
448451 // 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()" ) ;
452453 } ,
453454
454455 "<shape-box>" : function ( part ) {
@@ -492,18 +493,11 @@ ValidationTypes = {
492493 } ,
493494
494495 "<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()" ) ;
507501 }
508502 } ,
509503
0 commit comments