All files / src/lib/wvr-list wvr-list.component.ts

84.62% Statements 11/13
50% Branches 1/2
80% Functions 4/5
83.33% Lines 10/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                          1x     1x   1x         1x       1x 1x 1x                   1x 1x       1x        
import { AfterViewInit, ChangeDetectionStrategy, Component, Injector, Input, OnDestroy } from '@angular/core';
import { projectContent } from '../shared/utility/projection.utility';
import { WvrBaseComponent } from '../shared/wvr-base.component';
 
/**
 * A stylable list.
 */
@Component({
  selector: 'wvr-list-component',
  templateUrl: './wvr-list.component.html',
  styleUrls: ['./wvr-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.Default
})
export class WvrListComponent extends WvrBaseComponent implements AfterViewInit, OnDestroy {
 
  /** Specifies the display format of this list.  */
  @Input() listType = 'unordered';
 
  private readonly observer = new MutationObserver(() => {
    this.project();
  });
 
  constructor(injector: Injector) {
    super(injector);
  }
 
  ngAfterViewInit(): void {
    this.project();
    const element: Element = this.eRef.nativeElement.querySelector('template[list-items],template[wvr-compile]');
    Iif (!!element) {
      this.observer.observe(element, {
        attributes: false,
        childList: true,
        subtree: false
      });
    }
  }
 
  ngOnDestroy(): void {
    super.ngOnDestroy();
    this.observer.disconnect();
  }
 
  private project(): void {
    projectContent(this.eRef, 'template[list-items],template[wvr-compile]', 'ul[list-items],ol[list-items],dl[list-items],div[list-items]');
  }
 
}