@@ -104,7 +104,6 @@ export default class Radar {
104104 this . _componentPool = [ ] ;
105105 this . _prependComponentPool = [ ] ;
106106 this . _appendComponentPool = [ ] ; // https://github.com/html-next/vertical-collection/issues/296
107- this . _removeComponentPool = [ ] ; // Defer removal when shouldRecycle=false to avoid race condition
108107
109108 // Boundaries
110109 this . _occludedContentBefore = new OccludedContent ( occlusionTagName ) ;
@@ -652,45 +651,6 @@ export default class Radar {
652651 : '' ;
653652 }
654653
655- _scheduleLayout ( ) {
656- if ( this . _nextLayout === null ) {
657- this . _nextLayout = this . schedule ( 'layout' , ( ) => {
658- this . _nextLayout = null ;
659-
660- const {
661- _appendComponentPool,
662- _prependComponentPool,
663- _occludedContentBefore,
664- _occludedContentAfter,
665- _itemContainer,
666- } = this ;
667-
668- while ( _prependComponentPool . length > 0 ) {
669- const component = _prependComponentPool . pop ( ) ;
670- const relativeNode =
671- _occludedContentBefore . realLowerBound . nextSibling ;
672- insertRangeBefore (
673- _itemContainer ,
674- relativeNode ,
675- component . realUpperBound ,
676- component . realLowerBound ,
677- ) ;
678- }
679-
680- while ( _appendComponentPool . length > 0 ) {
681- const component = _appendComponentPool . pop ( ) ;
682- const relativeNode = _occludedContentAfter . realUpperBound ;
683- insertRangeBefore (
684- _itemContainer ,
685- relativeNode ,
686- component . realUpperBound ,
687- component . realLowerBound ,
688- ) ;
689- }
690- } ) ;
691- }
692- }
693-
694654 _appendComponent ( component ) {
695655 const {
696656 virtualComponents,
@@ -719,7 +679,26 @@ export default class Radar {
719679 // We have to move them _after_ they render, so we schedule that if they exist
720680 if ( ! shouldRecycle ) {
721681 _appendComponentPool . unshift ( component ) ;
722- this . _scheduleLayout ( ) ;
682+
683+ if ( this . _nextLayout === null ) {
684+ this . _nextLayout = this . schedule ( 'layout' , ( ) => {
685+ this . _nextLayout = null ;
686+
687+ while ( _appendComponentPool . length > 0 ) {
688+ const component = _appendComponentPool . pop ( ) ;
689+
690+ // Changes with each inserted component
691+ const relativeNode = _occludedContentAfter . realUpperBound ;
692+
693+ insertRangeBefore (
694+ this . _itemContainer ,
695+ relativeNode ,
696+ component . realUpperBound ,
697+ component . realLowerBound ,
698+ ) ;
699+ }
700+ } ) ;
701+ }
723702 }
724703 }
725704 }
@@ -748,7 +727,27 @@ export default class Radar {
748727 // Components that are both new and prepended still need to be rendered at the end because Glimmer.
749728 // We have to move them _after_ they render, so we schedule that if they exist
750729 _prependComponentPool . unshift ( component ) ;
751- this . _scheduleLayout ( ) ;
730+
731+ if ( this . _nextLayout === null ) {
732+ this . _nextLayout = this . schedule ( 'layout' , ( ) => {
733+ this . _nextLayout = null ;
734+
735+ while ( _prependComponentPool . length > 0 ) {
736+ const component = _prependComponentPool . pop ( ) ;
737+
738+ // Changes with each inserted component
739+ const relativeNode =
740+ _occludedContentBefore . realLowerBound . nextSibling ;
741+
742+ insertRangeBefore (
743+ _itemContainer ,
744+ relativeNode ,
745+ component . realUpperBound ,
746+ component . realLowerBound ,
747+ ) ;
748+ }
749+ } ) ;
750+ }
752751 }
753752 }
754753
0 commit comments