diff --git a/src/Layout.js b/src/Layout.js index b9b5c648..e297c496 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -231,7 +231,8 @@ var computeLayout = (function() { for (var/*int*/ i = 0; i < node.children.length; ++i) { var/*css_node_t**/ child = node.children[i]; if (getPositionType(child) === 'absolute' && isPosDefined(child, leading[mainAxis])) { - child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]); + child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]) + + getMargin(child, leading[mainAxis]); } else { child.layout[pos[mainAxis]] += mainPos; } diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index 1e7a7b63..39fba088 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -570,6 +570,17 @@ describe('Layout', function() { ); }); + it('should layout node with position: absolute, top and marginTop', function() { + testLayout( + {style: {}, children: [ + {style: {top: 5, marginTop: 5, position: 'absolute'}} + ]}, + {width: 0, height: 0, top: 0, left: 0, children: [ + {width: 0, height: 0, top: 10, left: 0} + ]} + ); + }); + it('should layout randomly', function() { function RNG(seed) { this.state = seed;