refactor(aio): rename `CustomMdIconRegistry` to `CustomIconRegistry` (#19702)

The change of Angular Material version means that the `md` prefix is
no longer appropriate.

PR Close #19702
This commit is contained in:
Peter Bacon Darwin 2017-10-29 14:01:00 +00:00 committed by Matias Niemelä
parent 4038b42396
commit 215d373ebd
3 changed files with 8 additions and 8 deletions

View File

@ -29,7 +29,7 @@ import { SwUpdatesModule } from 'app/sw-updates/sw-updates.module';
import { AppComponent } from 'app/app.component'; import { AppComponent } from 'app/app.component';
import { ApiService } from 'app/embedded/api/api.service'; import { ApiService } from 'app/embedded/api/api.service';
import { CustomMdIconRegistry, SVG_ICONS } from 'app/shared/custom-md-icon-registry'; import { CustomIconRegistry, SVG_ICONS } from 'app/shared/custom-icon-registry';
import { Deployment } from 'app/shared/deployment.service'; import { Deployment } from 'app/shared/deployment.service';
import { DocViewerComponent } from 'app/layout/doc-viewer/doc-viewer.component'; import { DocViewerComponent } from 'app/layout/doc-viewer/doc-viewer.component';
import { DtComponent } from 'app/layout/doc-viewer/dt.component'; import { DtComponent } from 'app/layout/doc-viewer/dt.component';
@ -111,7 +111,7 @@ export const svgIconProviders = [
Location, Location,
{ provide: LocationStrategy, useClass: PathLocationStrategy }, { provide: LocationStrategy, useClass: PathLocationStrategy },
LocationService, LocationService,
{ provide: MatIconRegistry, useClass: CustomMdIconRegistry }, { provide: MatIconRegistry, useClass: CustomIconRegistry },
NavigationService, NavigationService,
Platform, Platform,
ScrollService, ScrollService,

View File

@ -1,7 +1,7 @@
import { MatIconRegistry } from '@angular/material'; import { MatIconRegistry } from '@angular/material';
import { CustomMdIconRegistry, SvgIconInfo } from './custom-md-icon-registry'; import { CustomIconRegistry, SvgIconInfo } from './custom-icon-registry';
describe('CustomMdIconRegistry', () => { describe('CustomIconRegistry', () => {
it('should get the SVG element for a preloaded icon from the cache', () => { it('should get the SVG element for a preloaded icon from the cache', () => {
const mockHttp: any = {}; const mockHttp: any = {};
const mockSanitizer: any = {}; const mockSanitizer: any = {};
@ -10,7 +10,7 @@ describe('CustomMdIconRegistry', () => {
const svgIcons: SvgIconInfo[] = [ const svgIcons: SvgIconInfo[] = [
{ name: 'test_icon', svgSource: svgSrc } { name: 'test_icon', svgSource: svgSrc }
]; ];
const registry = new CustomMdIconRegistry(mockHttp, mockSanitizer, svgIcons); const registry = new CustomIconRegistry(mockHttp, mockSanitizer, svgIcons);
let svgElement: SVGElement; let svgElement: SVGElement;
registry.getNamedSvgIcon('test_icon').subscribe(el => svgElement = el); registry.getNamedSvgIcon('test_icon').subscribe(el => svgElement = el);
expect(svgElement).toEqual(createSvg(svgSrc)); expect(svgElement).toEqual(createSvg(svgSrc));
@ -26,7 +26,7 @@ describe('CustomMdIconRegistry', () => {
]; ];
spyOn(MatIconRegistry.prototype, 'getNamedSvgIcon'); spyOn(MatIconRegistry.prototype, 'getNamedSvgIcon');
const registry = new CustomMdIconRegistry(mockHttp, mockSanitizer, svgIcons); const registry = new CustomIconRegistry(mockHttp, mockSanitizer, svgIcons);
registry.getNamedSvgIcon('other_icon'); registry.getNamedSvgIcon('other_icon');
expect(MatIconRegistry.prototype.getNamedSvgIcon).toHaveBeenCalledWith('other_icon', undefined); expect(MatIconRegistry.prototype.getNamedSvgIcon).toHaveBeenCalledWith('other_icon', undefined);

View File

@ -6,7 +6,7 @@ import { DomSanitizer } from '@angular/platform-browser';
/** /**
* Use SVG_ICONS (and SvgIconInfo) as "multi" providers to provide the SVG source * Use SVG_ICONS (and SvgIconInfo) as "multi" providers to provide the SVG source
* code for the icons that you wish to have preloaded in the `CustomMdIconRegistry` * code for the icons that you wish to have preloaded in the `CustomIconRegistry`
* For compatibility with the MdIconComponent, please ensure that the SVG source has * For compatibility with the MdIconComponent, please ensure that the SVG source has
* the following attributes: * the following attributes:
* *
@ -45,7 +45,7 @@ function createFakeHttp(http: HttpClient): any {
* us to provide preloaded icon SVG sources. * us to provide preloaded icon SVG sources.
*/ */
@Injectable() @Injectable()
export class CustomMdIconRegistry extends MatIconRegistry { export class CustomIconRegistry extends MatIconRegistry {
private preloadedSvgElements: SvgIconMap = {}; private preloadedSvgElements: SvgIconMap = {};
constructor(http: HttpClient, sanitizer: DomSanitizer, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) { constructor(http: HttpClient, sanitizer: DomSanitizer, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {