Skip to content

Commit

Permalink
refactor(platform-browser): remove non necessary factories (#52439)
Browse files Browse the repository at this point in the history
Let's keep the code a simple as necessary

PR Close #52439
  • Loading branch information
JeanMeche authored and thePunderWoman committed Jan 26, 2024
1 parent 983968d commit 8a1f1c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
11 changes: 2 additions & 9 deletions packages/platform-browser/src/browser/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {DOCUMENT, ɵDomAdapter as DomAdapter, ɵgetDOM as getDOM} from '@angular/common';
import {Inject, Injectable, ɵɵinject} from '@angular/core';
import {Inject, Injectable} from '@angular/core';

/**
* Represents the attributes of an HTML `<meta>` element. The element itself is
Expand All @@ -33,13 +33,6 @@ export type MetaDefinition = {
[prop: string]: string;
};

/**
* Factory to create a `Meta` service instance for the current DOM document.
*/
export function createMeta() {
return new Meta(ɵɵinject(DOCUMENT));
}

/**
* A service for managing HTML `<meta>` tags.
*
Expand All @@ -62,7 +55,7 @@ export function createMeta() {
*
* @publicApi
*/
@Injectable({providedIn: 'root', useFactory: createMeta, deps: []})
@Injectable({providedIn: 'root'})
export class Meta {
private _dom: DomAdapter;
constructor(@Inject(DOCUMENT) private _doc: any) {
Expand Down
14 changes: 3 additions & 11 deletions packages/platform-browser/src/browser/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/

import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/common';
import {Inject, Injectable, ɵɵinject} from '@angular/core';


/**
* Factory to create Title service.
*/
export function createTitle() {
return new Title(ɵɵinject(DOCUMENT));
}
import {DOCUMENT} from '@angular/common';
import {Inject, Injectable} from '@angular/core';

/**
* A service that can be used to get and set the title of a current HTML document.
Expand All @@ -27,7 +19,7 @@ export function createTitle() {
*
* @publicApi
*/
@Injectable({providedIn: 'root', useFactory: createTitle, deps: []})
@Injectable({providedIn: 'root'})
export class Title {
constructor(@Inject(DOCUMENT) private _doc: any) {}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {DOCUMENT} from '@angular/common';
import {forwardRef, Inject, Injectable, Injector, Sanitizer, SecurityContext, ɵ_sanitizeHtml as _sanitizeHtml, ɵ_sanitizeUrl as _sanitizeUrl, ɵallowSanitizationBypassAndThrow as allowSanitizationBypassOrThrow, ɵbypassSanitizationTrustHtml as bypassSanitizationTrustHtml, ɵbypassSanitizationTrustResourceUrl as bypassSanitizationTrustResourceUrl, ɵbypassSanitizationTrustScript as bypassSanitizationTrustScript, ɵbypassSanitizationTrustStyle as bypassSanitizationTrustStyle, ɵbypassSanitizationTrustUrl as bypassSanitizationTrustUrl, ɵBypassType as BypassType, ɵRuntimeError as RuntimeError, ɵunwrapSafeValue as unwrapSafeValue, ɵXSS_SECURITY_URL as XSS_SECURITY_URL} from '@angular/core';
import {forwardRef, Inject, Injectable, Sanitizer, SecurityContext, ɵ_sanitizeHtml as _sanitizeHtml, ɵ_sanitizeUrl as _sanitizeUrl, ɵallowSanitizationBypassAndThrow as allowSanitizationBypassOrThrow, ɵbypassSanitizationTrustHtml as bypassSanitizationTrustHtml, ɵbypassSanitizationTrustResourceUrl as bypassSanitizationTrustResourceUrl, ɵbypassSanitizationTrustScript as bypassSanitizationTrustScript, ɵbypassSanitizationTrustStyle as bypassSanitizationTrustStyle, ɵbypassSanitizationTrustUrl as bypassSanitizationTrustUrl, ɵBypassType as BypassType, ɵRuntimeError as RuntimeError, ɵunwrapSafeValue as unwrapSafeValue, ɵXSS_SECURITY_URL as XSS_SECURITY_URL} from '@angular/core';

import {RuntimeErrorCode} from '../errors';

Expand Down Expand Up @@ -144,11 +144,7 @@ export abstract class DomSanitizer implements Sanitizer {
abstract bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl;
}

export function domSanitizerImplFactory(injector: Injector) {
return new DomSanitizerImpl(injector.get(DOCUMENT));
}

@Injectable({providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [Injector]})
@Injectable({providedIn: 'root'})
export class DomSanitizerImpl extends DomSanitizer {
constructor(@Inject(DOCUMENT) private _doc: any) {
super();
Expand Down

0 comments on commit 8a1f1c0

Please sign in to comment.