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) {
@ -310,12 +317,21 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
}
}
}

View file

@ -153,12 +153,21 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
}
}
}
@ -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

@ -151,12 +151,21 @@ GradientParser.parse = (function() {
if (radialType) {
radialType.at = matchAtPosition();
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
var extent = matchExtentKeyword();
if (extent) {
radialType = extent;
var positionAt = matchAtPosition();
if (positionAt) {
radialType.at = positionAt;
}
} else {
var defaultPosition = matchPositioning();
if (defaultPosition) {
radialType = {
type: 'default-radial',
at: defaultPosition
};
}
}
}

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() {