Fails when radial-gradient shape is omitted but a size is provided #5
7 changed files with 79 additions and 23 deletions
3
Makefile
3
Makefile
|
@ -1,2 +1,5 @@
|
|||
all:
|
||||
python -m SimpleHTTPServer 3000
|
||||
|
||||
test:
|
||||
grunt
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
18
build/web.js
18
build/web.js
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue