(moduleRef: NgModuleRef<StylingModule>)
| 13 | import {StylingModule} from './styling'; |
| 14 | |
| 15 | export function init(moduleRef: NgModuleRef<StylingModule>) { |
| 16 | const injector = moduleRef.injector; |
| 17 | const appRef = injector.get(ApplicationRef); |
| 18 | const componentRef = appRef.components[0]; |
| 19 | const component = componentRef.instance; |
| 20 | const componentHostEl = componentRef.location.nativeElement; |
| 21 | const select = document.querySelector('#scenario-select')! as HTMLSelectElement; |
| 22 | |
| 23 | const empty: number[] = []; |
| 24 | const items: number[] = []; |
| 25 | |
| 26 | function create(tplRefIdx: number) { |
| 27 | component.tplRefIdx = tplRefIdx; |
| 28 | component.data = items; |
| 29 | appRef.tick(); |
| 30 | } |
| 31 | |
| 32 | function destroy() { |
| 33 | component.data = empty; |
| 34 | appRef.tick(); |
| 35 | } |
| 36 | |
| 37 | function update() { |
| 38 | component.exp = component.exp === 'bar' ? 'baz' : 'bar'; |
| 39 | appRef.tick(); |
| 40 | } |
| 41 | |
| 42 | function detectChanges() { |
| 43 | appRef.tick(); |
| 44 | } |
| 45 | |
| 46 | function modifyExternally() { |
| 47 | const buttonEls = componentHostEl.querySelectorAll('button') as HTMLButtonElement[]; |
| 48 | buttonEls.forEach((buttonEl: HTMLButtonElement) => { |
| 49 | const cl = buttonEl.classList; |
| 50 | if (cl.contains('external')) { |
| 51 | cl.remove('external'); |
| 52 | } else { |
| 53 | cl.add('external'); |
| 54 | } |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | for (let i = 0; i < 2000; i++) { |
| 59 | items.push(i); |
| 60 | } |
| 61 | |
| 62 | bindAction('#create', () => create(select.selectedIndex)); |
| 63 | bindAction('#update', update); |
| 64 | bindAction('#detect_changes', detectChanges); |
| 65 | bindAction('#destroy', destroy); |
| 66 | bindAction( |
| 67 | '#profile_update', |
| 68 | profile( |
| 69 | () => { |
| 70 | for (let i = 0; i < 10; i++) { |
| 71 | update(); |
| 72 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…