Skip to content

Commit 466a770

Browse files
committed
Images: Reject non-array images attribute
1 parent 83592c1 commit 466a770

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/components/images/defaults.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ var attributes = require('./attributes');
1515

1616
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
1717

18-
if(!layoutIn.images) return;
18+
if(!layoutIn.images || !Array.isArray(layoutIn.images)) return;
1919

2020

21-
var containerIn = Array.isArray(layoutIn.images) ?
22-
layoutIn.images : [layoutIn.images],
21+
var containerIn = layoutIn.images,
2322
containerOut = layoutOut.images = [];
2423

2524

test/jasmine/tests/layout_images_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ describe('Layout images', function() {
2424
expect(layoutOut.images.length).toEqual(0);
2525
});
2626

27+
it('should reject when not an array', function() {
28+
layoutIn.images = {
29+
source: 'http://www.someimagesource.com',
30+
opacity: 0.5,
31+
width: 0.2,
32+
height: 0.2
33+
};
34+
35+
Images.supplyLayoutDefaults(layoutIn, layoutOut);
36+
37+
expect(layoutOut.images).not.toBeDefined();
38+
});
39+
2740
it('should coerce the correct defaults', function() {
2841
layoutIn.images[0] = { source: 'http://www.someimagesource.com' };
2942

0 commit comments

Comments
 (0)