specific width and stretch should favor the specific width

This commit is contained in:
Christopher Chedeau
2014-04-21 17:16:32 -07:00
parent a17fc43756
commit d5b5ccf56b
2 changed files with 24 additions and 5 deletions

View File

@@ -267,12 +267,14 @@ var computeLayout = (function() {
} else if (alignItem == CSS_ALIGN_FLEX_END) {
leadingCrossDim += remainingCrossDim;
} else if (alignItem == CSS_ALIGN_STRETCH) {
if (!isDimDefined(child, 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]);
}
}
child.layout[pos[crossAxis]] += leadingCrossDim;
}
}

View File

@@ -518,6 +518,23 @@ describe('Layout', function() {
);
});
it('should layout node with specified width and stretch', function() {
testLayout(
{style: {}, children: [{
style: {}, children: [
{style: {width: 400}}
]},
{style: {width: 200, alignSelf: 'stretch'}}
]},
{width: 400, height: 0, top: 0, left: 0, children: [
{width: 400, height: 0, top: 0, left: 0, children: [
{width: 400, height: 0, top: 0, left: 0}
]},
{width: 200, height: 0, top: 0, left: 0}
]}
);
});
it('should layout randomly', function() {
function RNG(seed) {
this.state = seed;