Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 66c8702

Browse filesBrowse files
committed
Images: Reject non-array images attribute
1 parent e62b27d commit 66c8702
Copy full SHA for 66c8702

File tree

2 files changed

+15
-3
lines changed
Filter options

2 files changed

+15
-3
lines changed

‎src/components/images/defaults.js

Copy file name to clipboardExpand all lines: src/components/images/defaults.js
+2-3Lines changed: 2 additions & 3 deletions
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

Copy file name to clipboardExpand all lines: test/jasmine/tests/layout_images_test.js
+13Lines changed: 13 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.