Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions src/css/ValidationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ var ValidationTypes = {
i, len, found = false;

for (i=0,len=args.length; i < len && !found; i++){
if (text === args[i].toLowerCase()){
if (args[i].slice(-2) === "()"){
found = (part.type === "function" &&
part.name === args[i].slice(0, -2));
} else if (text === args[i].toLowerCase()){
found = true;
}
}
Expand Down Expand Up @@ -92,7 +95,7 @@ var ValidationTypes = {
},

"<attr>": function(part){
return part.type === "function" && part.name === "attr";
return ValidationTypes.isLiteral(part, "attr()");
},

"<bg-image>": function(part){
Expand All @@ -108,7 +111,7 @@ var ValidationTypes = {
},

"<content>": function(part){
return part.type === "function" && part.name === "content";
return ValidationTypes.isLiteral(part, "content()");
},

"<relative-size>": function(part){
Expand Down Expand Up @@ -186,17 +189,15 @@ var ValidationTypes = {
},

"<shape>": function(part){
return part.type === "function" && (part.name === "rect" || part.name === "inset-rect");
return ValidationTypes.isLiteral(part, "rect() | inset-rect()");
},

"<basic-shape>": function(part){
// inset() = inset( <shape-arg>{1,4} [round <border-radius>]? )
// circle() = circle( [<shape-radius>]? [at <position>]? )
// ellipse() = ellipse( [<shape-radius>{2}]? [at <position>]? )
// polygon() = polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )
return part.type === "function" && (
part.name === "inset" || part.name === "circle" || part.name === "ellipse" || part.name === "polygon"
);
return ValidationTypes.isLiteral(part, "inset() | circle() | ellipse() | polygon()");
},

"<shape-box>": function(part) {
Expand Down Expand Up @@ -240,18 +241,11 @@ var ValidationTypes = {
},

"<filter-function>": function(part){
return part.type === "function" && (
part.name === 'blur' ||
part.name === 'brightness' ||
part.name === 'contrast' ||
part.name === 'custom' || // Not actually in formal spec.
part.name === 'drop-shadow' ||
part.name === 'grayscale' ||
part.name === 'hue-rotate' ||
part.name === 'invert' ||
part.name === 'opacity' ||
part.name === 'saturate' ||
part.name === 'sepia');
// custom() isn't actually in the spec
return ValidationTypes.isLiteral(
part, "blur() | brightness() | contrast() | custom() | " +
"drop-shadow() | grayscale() | hue-rotate() | invert() | " +
"opacity() | saturate() | sepia()");
}
},

Expand Down