diff --git a/spec/LayoutSpec.js b/spec/LayoutSpec.js index dc01bb65..a7a1d900 100755 --- a/spec/LayoutSpec.js +++ b/spec/LayoutSpec.js @@ -512,7 +512,6 @@ describe('Layout', function() { ); }); - it('should layout node with inner & outer padding and stretch', function() { testLayout( {style: {padding: 50}, children: [ @@ -524,6 +523,22 @@ describe('Layout', function() { ); }); + it('should layout node with stretch and child with margin', function() { + testLayout( + {style: {}, children: [ + {style: {alignSelf: 'stretch'}, children: [ + {style: {margin: 16}} + ]} + ]}, + + {width: 32, height: 32, top: 0, left: 0, children: [ + {width: 32, height: 32, top: 0, left: 0, children: [ + {width: 0, height: 0, top: 16, left: 16} + ]} + ]} + ); + }); + it('should layout randomly', function() { function RNG(seed) { this.state = seed; diff --git a/src/Layout.js b/src/Layout.js index 70268f5e..7e73b60b 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -202,13 +202,11 @@ function computeLayout(node) { } else if (alignItem === 'flex-end') { leadingCrossDim += remainingCrossDim; } else if (alignItem === 'stretch') { - child.layout[dim[crossAxis]] += node.layout[dim[crossAxis]] - + child.layout[dim[crossAxis]] = node.layout[dim[crossAxis]] - getPadding(node, leading[crossAxis]) - getPadding(node, trailing[crossAxis]) - getMargin(child, leading[crossAxis]) - - getMargin(child, trailing[crossAxis]) - - getPadding(child, leading[crossAxis]) - - getPadding(child, trailing[crossAxis]); + getMargin(child, trailing[crossAxis]); } child.layout[pos[crossAxis]] += leadingCrossDim; });