From 39cc1e9b01765b56e8773f83634d9dc2cb0af66c Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Mon, 21 Apr 2014 17:31:04 -0700 Subject: [PATCH] position: absolute should respect cross padding --- src/Layout.js | 2 ++ src/__tests__/Layout-test.js | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Layout.js b/src/Layout.js index 905ed392..8ebcabdc 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -276,6 +276,8 @@ var computeLayout = (function() { } } child.layout[pos[crossAxis]] += leadingCrossDim; + } else { + child.layout[pos[crossAxis]] += getPadding(node, leading[crossAxis]); } } diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index 2dc7cf15..e1621496 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -535,6 +535,17 @@ describe('Layout', function() { ); }); + it('should layout node with specified width', function() { + testLayout( + {style: {padding: 5}, children: [ + {style: {position: 'absolute'}} + ]}, + {width: 10, height: 10, top: 0, left: 0, children: [ + {width: 0, height: 0, top: 5, left: 5} + ]} + ); + }); + it('should layout randomly', function() { function RNG(seed) { this.state = seed; @@ -556,9 +567,6 @@ describe('Layout', function() { } function randEnum(node, chance, attribute, enumValues) { if (rng.nextFloat() < chance) { - if (attribute === 'position') { - return; - } node.style[attribute] = enumValues[Math.floor(rng.nextFloat() * enumValues.length)]; } }