Fails when radial-gradient shape is omitted but a size is provided #5

Merged
rafaelcaricio merged 1 commit from fixes-4 into master 2016-01-10 12:26:56 +00:00
7 changed files with 79 additions and 23 deletions

View file

@ -1,2 +1,5 @@
all:
python -m SimpleHTTPServer 3000
test:
grunt

View file

@ -60,7 +60,14 @@ GradientParser.stringify = (function() {
},
'visit_extent-keyword': function(node) {
return node.value;
var result = node.value,
at = visitor.visit(node.at);
if (at) {
result += ' at ' + at;
}
return result;
},
'visit_position-keyword': function(node) {
@ -309,6 +316,14 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
@ -318,6 +333,7 @@ GradientParser.parse = (function() {
};
}
}
}
return radialType;
}

View file

@ -152,6 +152,14 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
@ -161,6 +169,7 @@ GradientParser.parse = (function() {
};
}
}
}
return radialType;
}
@ -400,7 +409,14 @@ GradientParser.stringify = (function() {
},
'visit_extent-keyword': function(node) {
return node.value;
var result = node.value,
at = visitor.visit(node.at);
if (at) {
result += ' at ' + at;
}
return result;
},
'visit_position-keyword': function(node) {

View file

@ -150,6 +150,14 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
@ -159,6 +167,7 @@ GradientParser.parse = (function() {
};
}
}
}
return radialType;
}

View file

@ -60,7 +60,14 @@ GradientParser.stringify = (function() {
},
'visit_extent-keyword': function(node) {
return node.value;
var result = node.value,
at = visitor.visit(node.at);
if (at) {
result += ' at ' + at;
}
return result;
},
'visit_position-keyword': function(node) {

View file

@ -197,7 +197,10 @@ describe('lib/parser.js', function () {
'ellipse cover',
'circle cover',
'center bottom, ellipse cover',
'circle at 87.23px -58.3px'
'circle at 87.23px -58.3px',
'farthest-side, red, blue',
'farthest-corner, red, blue',
'farthest-corner at 87.23px -58.3px, red, blue'
].forEach(function(declaration) {
it('should parse ' + declaration + ' declaration', function() {

View file

@ -79,7 +79,9 @@ describe('lib/stringify.js', function () {
'ellipse cover',
'circle cover',
'center bottom, ellipse cover',
'circle at 87.23px -58.3px'
'circle at 87.23px -58.3px',
'farthest-corner, red, blue',
'farthest-corner at 87.23px -58.3px, red, blue'
].forEach(function(declaration) {
it('should parse ' + declaration + ' declaration', function() {