@@ -93,7 +93,7 @@ static CGFloat maxDimensionForLayout(const ASLayout *l,
9393  const  auto  ascenderIt = std::max_element (positionedLayout.sublayouts .begin (), positionedLayout.sublayouts .end (), [&](const  ASLayout *a, const  ASLayout *b){
9494    return  a.layoutableObject .ascender  < b.layoutableObject .ascender ;
9595  });
96-   const  CGFloat maxAscender = baselineIt  == positionedLayout.sublayouts .end () ? 0  : (*ascenderIt).layoutableObject .ascender ;
96+   const  CGFloat maxAscender = ascenderIt  == positionedLayout.sublayouts .end () ? 0  : (*ascenderIt).layoutableObject .ascender ;
9797
9898  /* 
9999    Step 3: Take each child and update its layout position based on the baseline offset. 
@@ -103,33 +103,40 @@ static CGFloat maxDimensionForLayout(const ASLayout *l,
103103    spacing between the two nodes is from the baseline, not the bounding box. 
104104    
105105  */  
106-   CGPoint p = CGPointZero;
107-   BOOL  first = YES ;
108-   auto  stackedChildren = AS::map (positionedLayout.sublayouts , [&](ASLayout *l) -> ASLayout *{
109-     __weak id <ASLayoutable> child = l.layoutableObject ;
110-     p = p + directionPoint (style.direction , child.spacingBefore , 0 );
111-     if  (first) {
112-       //  if this is the first item use the previously computed start point
113-       p = l.position ;
114-     } else  {
115-       //  otherwise add the stack spacing
116-       p = p + directionPoint (style.direction , style.spacing , 0 );
117-     }
118-     first = NO ;
119-     
120-     //  Find the difference between this node's baseline and the max baseline of all the children. Add this difference to the child's y position.
121-     l.position  = p + CGPointMake (0 , baselineOffset (style, l, maxAscender, maxBaseline));
122-     
123-     //  If we are a vertical stack, add the item's descender (it is negative) to the offset for the next node. This will ensure we are spacing
124-     //  node from baselines and not bounding boxes.
125-     CGFloat spacingAfterBaseline = 0 ;
126-     if  (style.direction  == ASStackLayoutDirectionVertical) {
127-       spacingAfterBaseline = child.descender ;
128-     }
129-     p = p + directionPoint (style.direction , stackDimension (style.direction , l.size ) + child.spacingAfter  + spacingAfterBaseline, 0 );
130-     
131-     return  l;
132-   });
106+   std::vector<ASLayout *> stackedChildren;
107+   //  Only change positions of layouts this stackSpec is aligning to a baseline. Otherwise we are only here to
108+   //  compute the min/max descender/ascender for this stack spec.
109+   if  (style.baselineRelativeArrangement  || style.alignItems  == ASStackLayoutAlignItemsBaselineFirst || style.alignItems  == ASStackLayoutAlignItemsBaselineLast) {
110+     CGPoint p = CGPointZero;
111+     BOOL  first = YES ;
112+     stackedChildren = AS::map (positionedLayout.sublayouts , [&](ASLayout *l) -> ASLayout *{
113+       __weak id <ASLayoutable> child = l.layoutableObject ;
114+       p = p + directionPoint (style.direction , child.spacingBefore , 0 );
115+       if  (first) {
116+         //  if this is the first item use the previously computed start point
117+         p = l.position ;
118+       } else  {
119+         //  otherwise add the stack spacing
120+         p = p + directionPoint (style.direction , style.spacing , 0 );
121+       }
122+       first = NO ;
123+       
124+       //  Find the difference between this node's baseline and the max baseline of all the children. Add this difference to the child's y position.
125+       l.position  = p + CGPointMake (0 , baselineOffset (style, l, maxAscender, maxBaseline));
126+       
127+       //  If we are a vertical stack, add the item's descender (it is negative) to the offset for the next node. This will ensure we are spacing
128+       //  node from baselines and not bounding boxes.
129+       CGFloat spacingAfterBaseline = 0 ;
130+       if  (style.direction  == ASStackLayoutDirectionVertical) {
131+         spacingAfterBaseline = child.descender ;
132+       }
133+       p = p + directionPoint (style.direction , stackDimension (style.direction , l.size ) + child.spacingAfter  + spacingAfterBaseline, 0 );
134+       
135+       return  l;
136+     });
137+   } else  {
138+     stackedChildren = positionedLayout.sublayouts ;
139+   }
133140
134141  /* 
135142    Step 4: Since we have been mucking with positions, there is a chance that our cross size has changed. Imagine a node with a font size of 40 
0 commit comments