From 830457536049b1df1a8abf50abf7e63f9d4d0e15 Mon Sep 17 00:00:00 2001 From: splincode Date: Tue, 27 Feb 2024 16:35:30 +0300 Subject: [PATCH] chore(deps): update taiga-ui --- jest.config.ts | 4 ++-- projects/demo/src/app/app.component.ts | 6 +++--- .../ng-dompurify/lib/ng-dompurify.pipe.ts | 8 +++----- .../ng-dompurify/lib/ng-dompurify.service.ts | 20 ++++++------------- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 840fb9e..02ef1fd 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -32,8 +32,8 @@ const config: Config = { coverageReporters: ['html', 'lcov', 'json', 'text', 'lcov'], moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: `/${compilerOptions.baseUrl}/` - .replace(/\.\//g, '/') - .replace(/\/\/+/g, '/'), + .replaceAll('./', '/') + .replaceAll(/\/\/+/g, '/'), }), verbose: true, }; diff --git a/projects/demo/src/app/app.component.ts b/projects/demo/src/app/app.component.ts index de26975..9488178 100644 --- a/projects/demo/src/app/app.component.ts +++ b/projects/demo/src/app/app.component.ts @@ -1,4 +1,4 @@ -import {ChangeDetectionStrategy, Component, Inject, SecurityContext} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject, SecurityContext} from '@angular/core'; import {DomSanitizer, SafeValue} from '@angular/platform-browser'; const dirtyHtml = @@ -13,11 +13,11 @@ const svg = ` changeDetection: ChangeDetectionStrategy.OnPush, }) export class AppComponent { + private readonly sanitizer = inject(DomSanitizer); + value = dirtyHtml; domValue = svg; - constructor(@Inject(DomSanitizer) private readonly sanitizer: DomSanitizer) {} - unwrap(value: SafeValue | null): string { return this.sanitizer.sanitize(SecurityContext.HTML, value) || ''; } diff --git a/projects/ng-dompurify/lib/ng-dompurify.pipe.ts b/projects/ng-dompurify/lib/ng-dompurify.pipe.ts index 4ee67a3..1cc8e34 100644 --- a/projects/ng-dompurify/lib/ng-dompurify.pipe.ts +++ b/projects/ng-dompurify/lib/ng-dompurify.pipe.ts @@ -1,4 +1,4 @@ -import {Inject, Pipe, PipeTransform, SecurityContext} from '@angular/core'; +import {inject, Pipe, PipeTransform, SecurityContext} from '@angular/core'; import {DomSanitizer, SafeValue} from '@angular/platform-browser'; import {NgDompurifySanitizer} from './ng-dompurify.service'; @@ -12,10 +12,8 @@ import {NgDompurifyConfig} from './types/ng-dompurify-config'; name: 'dompurify', }) export class NgDompurifyPipe implements PipeTransform { - constructor( - @Inject(NgDompurifySanitizer) private readonly sanitizer: NgDompurifySanitizer, - @Inject(DomSanitizer) private readonly domSanitizer: DomSanitizer, - ) {} + private readonly sanitizer = inject(NgDompurifySanitizer); + private readonly domSanitizer = inject(DomSanitizer); transform( value: Record | string | null, diff --git a/projects/ng-dompurify/lib/ng-dompurify.service.ts b/projects/ng-dompurify/lib/ng-dompurify.service.ts index 73ef15b..66e6059 100644 --- a/projects/ng-dompurify/lib/ng-dompurify.service.ts +++ b/projects/ng-dompurify/lib/ng-dompurify.service.ts @@ -1,13 +1,11 @@ import {DOCUMENT} from '@angular/common'; -import {Inject, Injectable, Sanitizer, SecurityContext} from '@angular/core'; +import {inject, Injectable, Sanitizer, SecurityContext} from '@angular/core'; import dompurify, {DOMPurifyI} from 'dompurify'; import {DOMPURIFY_CONFIG} from './tokens/dompurify-config'; import {DOMPURIFY_HOOKS} from './tokens/dompurify-hooks'; import {SANITIZE_STYLE} from './tokens/sanitize-style'; import {NgDompurifyConfig} from './types/ng-dompurify-config'; -import {NgDompurifyHook} from './types/ng-dompurify-hook'; -import {SanitizeStyle} from './types/sanitize-style'; const createDOMPurify = dompurify; @@ -25,20 +23,14 @@ const createDOMPurify = dompurify; providedIn: 'root', }) export class NgDompurifySanitizer implements Sanitizer { + private readonly config = inject(DOMPURIFY_CONFIG); + private readonly sanitizeStyle = inject(SANITIZE_STYLE); private readonly domPurify: DOMPurifyI; - constructor( - @Inject(DOMPURIFY_CONFIG) - private readonly config: NgDompurifyConfig, - @Inject(SANITIZE_STYLE) - private readonly sanitizeStyle: SanitizeStyle, - @Inject(DOCUMENT) {defaultView}: Document, - @Inject(DOMPURIFY_HOOKS) - hooks: readonly NgDompurifyHook[], - ) { - this.domPurify = createDOMPurify(defaultView as Window); + constructor() { + this.domPurify = createDOMPurify(inject(DOCUMENT).defaultView as Window); - hooks.forEach(({name, hook}) => { + inject(DOMPURIFY_HOOKS).forEach(({name, hook}) => { this.domPurify.addHook(name, hook); }); }