[ACS-7382] Standalone core directives, improved lint performance (#9559)

This commit is contained in:
Denys Vuika
2024-04-15 15:16:17 -04:00
committed by GitHub
parent 86d3ca7892
commit 7854cde20f
16 changed files with 86 additions and 108 deletions

View File

@@ -21,10 +21,10 @@ import { Directive, ElementRef, Input, Renderer2, AfterViewChecked } from '@angu
import { HighlightTransformService, HighlightTransformResult } from '../common/services/highlight-transform.service';
@Directive({
selector: '[adf-highlight]'
selector: '[adf-highlight]',
standalone: true
})
export class HighlightDirective implements AfterViewChecked {
/** Class selector for highlightable elements. */
@Input('adf-highlight-selector')
selector: string = '';
@@ -37,11 +37,7 @@ export class HighlightDirective implements AfterViewChecked {
@Input('adf-highlight-class')
classToApply: string = 'adf-highlight';
constructor(
private el: ElementRef,
private renderer: Renderer2,
private highlightTransformService: HighlightTransformService) {
}
constructor(private el: ElementRef, private renderer: Renderer2, private highlightTransformService: HighlightTransformService) {}
ngAfterViewChecked() {
this.highlight();
@@ -52,7 +48,11 @@ export class HighlightDirective implements AfterViewChecked {
const elements = this.el.nativeElement.querySelectorAll(selector);
elements.forEach((element) => {
const highlightTransformResult: HighlightTransformResult = this.highlightTransformService.highlight(element.innerHTML, search, classToApply);
const highlightTransformResult: HighlightTransformResult = this.highlightTransformService.highlight(
element.innerHTML,
search,
classToApply
);
if (highlightTransformResult.changed) {
this.renderer.setProperty(element, 'innerHTML', highlightTransformResult.text);
}