Skip to content

Commit

Permalink
Merge pull request #204 from racker/fix-area-again
Browse files Browse the repository at this point in the history
fix(components.area) Another empty data check.
  • Loading branch information
sym3tri committed Sep 19, 2013
2 parents f7ff3e4 + 3cf85da commit 85b8f96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/area.js
Expand Up @@ -154,7 +154,7 @@ function(array, config, obj, fn, string, d3util, mixins, dataFns) {

dataConfig = area.data();
// Return early if there's no data.
if (!dataConfig || !dataConfig.data) {
if (!dataConfig || !dataConfig.data || !dataConfig.data.length) {
return area;
}

Expand Down
17 changes: 17 additions & 0 deletions test/unit/components/area.spec.js
Expand Up @@ -312,6 +312,23 @@ function(area, dc) {
expect(exceptionThrown).toBe(false);
});

it('dies gracefully if data is set but empty', function() {
var exceptionThrown = false;
dataCollection = dc.create();
dataCollection.add({
id: 'foo',
data: []
});
testArea = area();
testArea.data(dataCollection);
try {
testArea.render(selection);
} catch (e) {
exceptionThrown = true;
}
expect(exceptionThrown).toBe(false);
});

});

describe('root()', function() {
Expand Down

0 comments on commit 85b8f96

Please sign in to comment.