diff --git a/src/Layout.js b/src/Layout.js index 363ca17e..0003b3b6 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -128,7 +128,7 @@ var computeLayout = (function() { } function isDimDefined(node, axis) { - return !isUndefined(node.style[dim[axis]]); + return !isUndefined(node.style[dim[axis]]) && node.style[dim[axis]] >= 0; } function isPosDefined(node, pos) { diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index 42296290..f8f847a1 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -722,6 +722,19 @@ describe('Layout', function() { ); }); + it('should layout node with negative width', function() { + testLayout( + {style: {width: -31}, children: [ + {style: {borderRightWidth: 5}} + ]}, + {width: 5, height: 0, top: 0, left: 0, children: [ + {width: 5, height: 0, top: 0, left: 0} + ]} + ); + }); + + + it('should layout randomly', function() { @@ -765,8 +778,8 @@ describe('Layout', function() { } function generateRandomNode() { var node = {style: {}}; - randMinMax(node, 0.5, 'width', 0, 1000); - randMinMax(node, 0.5, 'height', 0, 1000); + randMinMax(node, 0.5, 'width', -100, 1000); + randMinMax(node, 0.5, 'height', -100, 1000); randMinMax(node, 0.5, 'top', -10, 10); randMinMax(node, 0.5, 'left', -10, 10); randMinMax(node, 0.5, 'right', -10, 10);