Skip to content

Commit

Permalink
chore(deps): update taiga-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Feb 27, 2024
1 parent da8cc10 commit 8304575
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const config: Config = {
coverageReporters: ['html', 'lcov', 'json', 'text', 'lcov'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `<rootDir>/${compilerOptions.baseUrl}/`
.replace(/\.\//g, '/')
.replace(/\/\/+/g, '/'),
.replaceAll('./', '/')
.replaceAll(/\/\/+/g, '/'),
}),
verbose: true,
};
Expand Down
6 changes: 3 additions & 3 deletions projects/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -13,11 +13,11 @@ const svg = `<svg width="56" height="56">
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) || '';
}
Expand Down
8 changes: 3 additions & 5 deletions projects/ng-dompurify/lib/ng-dompurify.pipe.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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, string> | string | null,
Expand Down
20 changes: 6 additions & 14 deletions projects/ng-dompurify/lib/ng-dompurify.service.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
});
}
Expand Down

0 comments on commit 8304575

Please sign in to comment.