File tree Expand file tree Collapse file tree
transient-render-engine/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ import TNodeRenderer from './TNodeRenderer';
44import { TChildrenRendererProps } from './shared-types' ;
55import collapseTopMarginForChild from './helpers/collapseTopMarginForChild' ;
66
7+ function generateKey ( childTnode : TNode ) : string {
8+ let key = "" ;
9+ let currNode = childTnode as TNode | null ;
10+ while ( currNode ) {
11+ key = `${ key } -${ currNode . tagName } -${ String ( currNode . nodeIndex ) } `
12+ currNode = currNode . parent ;
13+ }
14+ return `childTnode-${ key } `
15+ }
16+
717const mapCollapsibleChildren = (
818 propsForChildren : TChildrenRendererProps [ 'propsForChildren' ] ,
919 renderChild : TChildrenRendererProps [ 'renderChild' ] ,
@@ -16,7 +26,7 @@ const mapCollapsibleChildren = (
1626 ? null
1727 : collapseTopMarginForChild ( n , tchildren ) ;
1828 const propsFromParent = { ...propsForChildren , collapsedMarginTop } ;
19- const key = childTnode . nodeIndex ;
29+ const key = `tnode_ ${ generateKey ( childTnode ) } ` ;
2030 const childElement = React . createElement ( TNodeRenderer , {
2131 propsFromParent,
2232 tnode : childTnode ,
Original file line number Diff line number Diff line change @@ -132,11 +132,11 @@ exports[`TRenderEngine > buildTTree method should support disabling whitespace c
132132 <TText tagName = " span" nodeIndex = { 1 } data = " phrasing content" webStyles = { { whiteSpace: " normal" }} />
133133 <TText anonymous nodeIndex = { 2 } data = " \\n" webStyles = { { whiteSpace: " normal" }} />
134134 </TPhrasing >
135- <TBlock tagName = " img" nodeIndex = { 3 } src = " https://domain.com/logo.jpg" webStyles = { { whiteSpace: " normal" }} />
136- <TPhrasing anonymous nodeIndex = { 0 } webStyles = { { whiteSpace: " normal" }} >
137- <TText anonymous nodeIndex = { 4 } data = " \\n and this is " webStyles = { { whiteSpace: " normal" }} />
138- <TText tagName = " strong" nodeIndex = { 5 } data = " too" webStyles = { { whiteSpace: " normal" }} />
139- <TText anonymous nodeIndex = { 6 } data = " .\\n" webStyles = { { whiteSpace: " normal" }} />
135+ <TBlock tagName = " img" nodeIndex = { 1 } src = " https://domain.com/logo.jpg" webStyles = { { whiteSpace: " normal" }} />
136+ <TPhrasing anonymous nodeIndex = { 2 } webStyles = { { whiteSpace: " normal" }} >
137+ <TText anonymous nodeIndex = { 0 } data = " \\n and this is " webStyles = { { whiteSpace: " normal" }} />
138+ <TText tagName = " strong" nodeIndex = { 1 } data = " too" webStyles = { { whiteSpace: " normal" }} />
139+ <TText anonymous nodeIndex = { 2 } data = " .\\n" webStyles = { { whiteSpace: " normal" }} />
140140 </TPhrasing >
141141 </TBlock >
142142 </TBlock >
Original file line number Diff line number Diff line change @@ -7,20 +7,20 @@ exports[`hoist function should comply with RFC002 example (hoisting) 1`] = `
77 <TText tagName = " span" nodeIndex = { 1 } data = " phrasing content" />
88 <TText anonymous nodeIndex = { 2 } data = " \\n" />
99 </TPhrasing >
10- <TBlock tagName = " img" nodeIndex = { 3 } src = " https://domain.com/logo.jpg" />
11- <TPhrasing anonymous nodeIndex = { 0 } >
12- <TText anonymous nodeIndex = { 4 } data = " \\n and this is " />
13- <TText tagName = " strong" nodeIndex = { 5 } data = " too" />
14- <TText anonymous nodeIndex = { 6 } data = " .\\n" />
10+ <TBlock tagName = " img" nodeIndex = { 1 } src = " https://domain.com/logo.jpg" />
11+ <TPhrasing anonymous nodeIndex = { 2 } >
12+ <TText anonymous nodeIndex = { 0 } data = " \\n and this is " />
13+ <TText tagName = " strong" nodeIndex = { 1 } data = " too" />
14+ <TText anonymous nodeIndex = { 2 } data = " .\\n" />
1515 </TPhrasing >
1616</TBlock >
1717` ;
1818
1919exports [` hoist function should hoist multiple blocks 1` ] = `
2020<TBlock tagName = " span" nodeIndex = { 0 } >
2121 <TBlock tagName = " div" nodeIndex = { 0 } />
22- <TPhrasing anonymous nodeIndex = { 0 } >
23- <TText anonymous nodeIndex = { 1 } data = " Hello" />
22+ <TPhrasing anonymous nodeIndex = { 1 } >
23+ <TText anonymous nodeIndex = { 0 } data = " Hello" />
2424 </TPhrasing >
2525 <TBlock tagName = " img" nodeIndex = { 2 } />
2626</TBlock >
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function groupText(tnode: TBlockImpl): TNodeImpl {
1616 // some React Native styles working only for the uppermost Text element
1717 // such as "textAlign" are preserved.
1818 parentStyles : tnode . styles ,
19- parent : null
19+ parent : tnode
2020 } ;
2121 let wrapper = new TPhrasingCtor ( wrapperInit ) ;
2222 let wrapperChildren : TNodeImpl [ ] = [ ] ;
@@ -26,18 +26,18 @@ function groupText(tnode: TBlockImpl): TNodeImpl {
2626 } else {
2727 if ( wrapperChildren . length ) {
2828 newChildren . push ( wrapper ) ;
29- wrapper . bindChildren ( wrapperChildren ) ;
29+ wrapper . bindChildren ( wrapperChildren , true ) ;
3030 wrapper = new TPhrasingCtor ( wrapperInit ) ;
3131 wrapperChildren = [ ] ;
3232 }
3333 newChildren . push ( child ) ;
3434 }
3535 }
3636 if ( wrapperChildren . length ) {
37- wrapper . bindChildren ( wrapperChildren ) ;
37+ wrapper . bindChildren ( wrapperChildren , true ) ;
3838 newChildren . push ( wrapper ) ;
3939 }
40- tnode . bindChildren ( newChildren ) ;
40+ tnode . bindChildren ( newChildren , true ) ;
4141 return tnode ;
4242}
4343
You can’t perform that action at this time.
0 commit comments