@@ -8,7 +8,10 @@ var ValidationTypes = {
8
8
i , len , found = false ;
9
9
10
10
for ( i = 0 , len = args . length ; i < len && ! found ; i ++ ) {
11
- if ( text === args [ i ] . toLowerCase ( ) ) {
11
+ if ( args [ i ] . slice ( - 2 ) === "()" ) {
12
+ found = ( part . type === "function" &&
13
+ part . name === args [ i ] . slice ( 0 , - 2 ) ) ;
14
+ } else if ( text === args [ i ] . toLowerCase ( ) ) {
12
15
found = true ;
13
16
}
14
17
}
@@ -92,7 +95,7 @@ var ValidationTypes = {
92
95
} ,
93
96
94
97
"<attr>" : function ( part ) {
95
- return part . type === "function" && part . name === "attr" ;
98
+ return ValidationTypes . isLiteral ( part , "attr()" ) ;
96
99
} ,
97
100
98
101
"<bg-image>" : function ( part ) {
@@ -108,7 +111,7 @@ var ValidationTypes = {
108
111
} ,
109
112
110
113
"<content>" : function ( part ) {
111
- return part . type === "function" && part . name === "content" ;
114
+ return ValidationTypes . isLiteral ( part , "content()" ) ;
112
115
} ,
113
116
114
117
"<relative-size>" : function ( part ) {
@@ -186,17 +189,15 @@ var ValidationTypes = {
186
189
} ,
187
190
188
191
"<shape>" : function ( part ) {
189
- return part . type === "function" && ( part . name === "rect" || part . name === " inset-rect") ;
192
+ return ValidationTypes . isLiteral ( part , "rect() | inset-rect() " ) ;
190
193
} ,
191
194
192
195
"<basic-shape>" : function ( part ) {
193
196
// inset() = inset( <shape-arg>{1,4} [round <border-radius>]? )
194
197
// circle() = circle( [<shape-radius>]? [at <position>]? )
195
198
// ellipse() = ellipse( [<shape-radius>{2}]? [at <position>]? )
196
199
// polygon() = polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )
197
- return part . type === "function" && (
198
- part . name === "inset" || part . name === "circle" || part . name === "ellipse" || part . name === "polygon"
199
- ) ;
200
+ return ValidationTypes . isLiteral ( part , "inset() | circle() | ellipse() | polygon()" ) ;
200
201
} ,
201
202
202
203
"<shape-box>" : function ( part ) {
@@ -240,18 +241,11 @@ var ValidationTypes = {
240
241
} ,
241
242
242
243
"<filter-function>" : function ( part ) {
243
- return part . type === "function" && (
244
- part . name === 'blur' ||
245
- part . name === 'brightness' ||
246
- part . name === 'contrast' ||
247
- part . name === 'custom' || // Not actually in formal spec.
248
- part . name === 'drop-shadow' ||
249
- part . name === 'grayscale' ||
250
- part . name === 'hue-rotate' ||
251
- part . name === 'invert' ||
252
- part . name === 'opacity' ||
253
- part . name === 'saturate' ||
254
- part . name === 'sepia' ) ;
244
+ // custom() isn't actually in the spec
245
+ return ValidationTypes . isLiteral (
246
+ part , "blur() | brightness() | contrast() | custom() | " +
247
+ "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
248
+ "opacity() | saturate() | sepia()" ) ;
255
249
}
256
250
} ,
257
251
0 commit comments