feat(challenge33): about performance

This commit is contained in:
thomas
2023-09-12 11:39:36 +02:00
parent 323c38e334
commit bc1c772820
23 changed files with 270 additions and 323 deletions

View File

@@ -0,0 +1 @@
export * from './lib/cd-flashing.directive';

View File

@@ -0,0 +1,23 @@
/* eslint-disable @angular-eslint/directive-selector */
import { Directive, DoCheck, ElementRef, NgZone } from '@angular/core';
@Directive({
selector: '[cd-flash]',
standalone: true,
})
export class CDFlashingDirective implements DoCheck {
constructor(private elementRef: ElementRef, private zone: NgZone) {}
ngDoCheck(): void {
this.cdRan();
}
public cdRan(): void {
this.zone.runOutsideAngular(() => {
this.elementRef.nativeElement.classList.add('!bg-orange-500');
setTimeout(() => {
this.elementRef.nativeElement.classList.remove('!bg-orange-500');
}, 1000);
});
}
}

View File

@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
import 'jest-preset-angular/setup-jest';