Skip to content

Commit a4a4483

Browse files
authored
Merge pull request #69 from courtneycb/polygonChanges
Adds checks for nulls when parsing offsetPath.
2 parents b9f3b68 + da0aab0 commit a4a4483

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(config) {
2323
'tools/internal-scope.js',
2424
],
2525
require('fs').readFileSync('src/fileOrder.txt', 'utf8').split('\n'),
26-
['test/*.js']
26+
['test/testFunctions.js', 'test/basicShapePolygonTest.js']
2727
),
2828

2929
// list of files to exclude

src/offsetPath.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// TODO: Need to support other positions as currently this only supports positions in which both x and y are specified and are in px
4343
if (position === null) {
4444
// TODO: Set default position to the center of the reference box
45-
position = [0, 0];
45+
position = '0px 0px';
4646
if (input !== '') {
4747
radius = input;
4848
}
@@ -89,6 +89,7 @@
8989
var isInArray = internalScope.isInArray;
9090
var parseAngleAsDegrees = internalScope.parseAngleAsDegrees;
9191
var ray = /^ray\((.*)\)$/.exec(input);
92+
9293
if (ray === null) {
9394
return undefined;
9495
}

test/basicShapePolygonTest.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
result = offsetPathParse('polygon(50px 0px, 50px -50px, 0px -50px)');
1717
assert.equal(offsetPathParse(result.path, 'm 50 0 l 0 -50 l -50 0 z'));
1818

19+
result = offsetPathParse('garbage');
20+
assert.equal(offsetPathParse(result, undefined));
21+
22+
result = offsetPathParse('polygon');
23+
assert.equal(offsetPathParse(result, undefined));
24+
25+
result = offsetPathParse('polygon()');
26+
assert.equal(offsetPathParse(result, undefined));
27+
28+
result = offsetPathParse('polygon(garbage)');
29+
assert.equal(offsetPathParse(result, undefined));
30+
1931
assertTransformInterpolation([
2032
{'offsetPath': 'polygon(0px 0px, 50px 0px, 50px -50px, 0px -50px)', 'offsetDistance': '0%'},
2133
{'offsetPath': 'polygon(0px 0px, 50px 0px, 50px -50px, 0px -50px)', 'offsetDistance': '100%'}],

0 commit comments

Comments
 (0)