@@ -15,7 +15,7 @@ export abstract class BaseNestedOption implements INestedOptionContainer, IColle
1515 protected abstract get _optionPath ( ) : string ;
1616 protected abstract _fullOptionPath ( ) : string ;
1717
18- constructor ( private _element : ElementRef ) {
18+ constructor ( ) {
1919 this . _collectionContainerImpl = new CollectionNestedOptionContainerImpl ( this . _setOption . bind ( this ) , this . _filterItems . bind ( this ) ) ;
2020 }
2121
@@ -40,11 +40,6 @@ export abstract class BaseNestedOption implements INestedOptionContainer, IColle
4040 this . _hostOptionPath = optionPath ;
4141 }
4242
43- _template ( ...args ) {
44- let container = args [ 2 ] || args [ 1 ] || args [ 0 ] ;
45- return container . append ( this . _element . nativeElement ) ;
46- }
47-
4843 setChildren < T extends ICollectionNestedOption > ( propertyName : string , items : QueryList < T > ) {
4944 return this . _collectionContainerImpl . setChildren ( propertyName , items ) ;
5045 }
@@ -121,6 +116,34 @@ export abstract class CollectionNestedOption extends BaseNestedOption implements
121116 }
122117}
123118
119+ export interface OptionWithTemplate extends BaseNestedOption {
120+ template : any ;
121+ }
122+ export function extractTemplate ( option : OptionWithTemplate , element : ElementRef ) {
123+ if ( ! option . template === undefined || ! element . nativeElement . hasChildNodes ( ) ) {
124+ return ;
125+ }
126+
127+ let childNodes = [ ] . slice . call ( element . nativeElement . childNodes ) ;
128+ let userContent = childNodes . filter ( ( n ) => {
129+ if ( n . tagName ) {
130+ let tagNamePrefix = n . tagName . toLowerCase ( ) . substr ( 0 , 3 ) ;
131+ return ! ( tagNamePrefix === 'dxi' || tagNamePrefix === 'dxo' ) ;
132+ } else {
133+ return n . textContent . replace ( / \s / g, '' ) . length ;
134+ }
135+ } ) ;
136+ if ( ! userContent . length ) {
137+ return ;
138+ }
139+
140+ option . template = {
141+ render : ( options ) => {
142+ return options . container . append ( element . nativeElement ) ;
143+ }
144+ } ;
145+ }
146+
124147export class NestedOptionHost {
125148 private _host : INestedOptionContainer ;
126149 private _optionPath : OptionPathGetter ;
0 commit comments