From a18bc27c6b0ac92705b93ef0e4ad9b8958859418 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 22 Apr 2014 10:02:33 -0700 Subject: [PATCH] flex and position absolute --- src/Layout.js | 4 +++- src/__tests__/Layout-test.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Layout.js b/src/Layout.js index 2c009cd8..2297140d 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -183,7 +183,9 @@ var computeLayout = (function() { var/*int*/ absoluteChildrenCount = 0; for (var/*int*/ i = 0; i < node.children.length; ++i) { var/*css_node_t**/ child = node.children[i]; - if (isUndefined(node.layout[dim[mainAxis]]) || !getFlex(child)) { + if (isUndefined(node.layout[dim[mainAxis]]) || + getPositionType(child) === 'absolute' || + !getFlex(child)) { layoutNode(child); if (getPositionType(child) === 'relative') { mainContentDim += getDimWithMargin(child, mainAxis); diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index 88235377..0d590d59 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -658,6 +658,17 @@ describe('Layout', function() { ); }); + it('should layout node with flex and position absolute', function() { + testLayout( + {style: {width: 600, flexDirection: 'row'}, children: [ + {style: {flex: 1, position: 'absolute'}} + ]}, + {width: 600, height: 0, top: 0, left: 0, children: [ + {width: 0, height: 0, top: 0, left: 0} + ]} + ); + }); + @@ -720,7 +731,7 @@ describe('Layout', function() { return node; } - for (var i = 0; i < 100; ++i) { + for (var i = 0; i < 1000; ++i) { var node = generateRandomNode(); if (JSON.stringify(computeLayout(node)) !== JSON.stringify(computeDOMLayout)) {