refactor: misc cleanup (#11654)
This commit is contained in:

committed by
Igor Minar

parent
51d73d3e4e
commit
fdb22bd185
@ -9,18 +9,12 @@
|
||||
import {NgModuleResolver} from '@angular/compiler';
|
||||
import {Compiler, Injectable, Injector, NgModule, Type} from '@angular/core';
|
||||
|
||||
import {Map} from './facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockNgModuleResolver extends NgModuleResolver {
|
||||
private _ngModules = new Map<Type<any>, NgModule>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link NgModule} for a module.
|
||||
*/
|
||||
@ -36,10 +30,10 @@ export class MockNgModuleResolver extends NgModuleResolver {
|
||||
* `NgModuleResolver`, see `setNgModule`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModule {
|
||||
var metadata = this._ngModules.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
}
|
||||
return metadata;
|
||||
return this._ngModules.get(type) || super.resolve(type, throwIfNotFound);
|
||||
}
|
||||
|
||||
private get _compiler(): Compiler { return this._injector.get(Compiler); }
|
||||
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user