diff --git a/goldens/public-api/platform-browser-dynamic/index.md b/goldens/public-api/platform-browser-dynamic/index.md index 6a3c8bc1446..5c0614c8f81 100644 --- a/goldens/public-api/platform-browser-dynamic/index.md +++ b/goldens/public-api/platform-browser-dynamic/index.md @@ -8,7 +8,6 @@ import { Compiler } from '@angular/core'; import { CompilerFactory } from '@angular/core'; import { CompilerOptions } from '@angular/core'; import { PlatformRef } from '@angular/core'; -import { Provider } from '@angular/core'; import { StaticProvider } from '@angular/core'; import { Version } from '@angular/core'; @@ -21,9 +20,6 @@ export class JitCompilerFactory implements CompilerFactory { // @public (undocumented) export const platformBrowserDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef; -// @public @deprecated (undocumented) -export const RESOURCE_CACHE_PROVIDER: Provider[]; - // @public (undocumented) export const VERSION: Version; diff --git a/packages/platform-browser-dynamic/src/platform-browser-dynamic.ts b/packages/platform-browser-dynamic/src/platform-browser-dynamic.ts index d4116369e45..6152d99f3bc 100644 --- a/packages/platform-browser-dynamic/src/platform-browser-dynamic.ts +++ b/packages/platform-browser-dynamic/src/platform-browser-dynamic.ts @@ -6,27 +6,15 @@ * found in the LICENSE file at https://angular.io/license */ -import {ResourceLoader} from '@angular/compiler'; -import {createPlatformFactory, Provider} from '@angular/core'; +import {createPlatformFactory} from '@angular/core'; import {platformCoreDynamic} from './platform_core_dynamic'; import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers'; -import {CachedResourceLoader} from './resource_loader/resource_loader_cache'; export * from './private_export'; export {VERSION} from './version'; export {JitCompilerFactory} from './compiler_factory'; -/** - * @publicApi - * - * @deprecated This was previously necessary in some cases to test AOT-compiled components with View - * Engine, but is no longer since Ivy. - - */ -export const RESOURCE_CACHE_PROVIDER: Provider[] = - [{provide: ResourceLoader, useClass: CachedResourceLoader, deps: []}]; - /** * @publicApi */ diff --git a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts b/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts deleted file mode 100644 index eea78b76b2a..00000000000 --- a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {ResourceLoader} from '@angular/compiler'; -import {ɵglobal as global} from '@angular/core'; - -/** - * An implementation of ResourceLoader that uses a template cache to avoid doing an actual - * ResourceLoader. - * - * The template cache needs to be built and loaded into window.$templateCache - * via a separate mechanism. - * - * @publicApi - * - * @deprecated This was previously necessary in some cases to test AOT-compiled components with View - * Engine, but is no longer since Ivy. - */ -export class CachedResourceLoader extends ResourceLoader { - private _cache: {[url: string]: string}; - - constructor() { - super(); - this._cache = (global).$templateCache; - if (this._cache == null) { - throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.'); - } - } - - override get(url: string): Promise { - if (this._cache.hasOwnProperty(url)) { - return Promise.resolve(this._cache[url]); - } else { - return >Promise.reject( - 'CachedResourceLoader: Did not find cached template for ' + url); - } - } -} diff --git a/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts b/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts deleted file mode 100644 index a0d6c7d440e..00000000000 --- a/packages/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; -import {fakeAsync, TestBed, tick, waitForAsync} from '@angular/core/testing'; -import {CachedResourceLoader} from '@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache'; -import {expect} from '@angular/platform-browser/testing/src/matchers'; - -if (isBrowser) { - // TODO(alxhub): Resource loading works very differently in Ivy. - xdescribe('CachedResourceLoader', () => { - let resourceLoader: CachedResourceLoader; - - function createCachedResourceLoader(): CachedResourceLoader { - setTemplateCache({'test.html': '
Hello
'}); - return new CachedResourceLoader(); - } - - it('should throw exception if $templateCache is not found', () => { - setTemplateCache(null); - expect(() => { - resourceLoader = new CachedResourceLoader(); - }).toThrowError('CachedResourceLoader: Template cache was not found in $templateCache.'); - }); - - it('should resolve the Promise with the cached file content on success', waitForAsync(() => { - resourceLoader = createCachedResourceLoader(); - resourceLoader.get('test.html').then((text) => { - expect(text).toBe('
Hello
'); - }); - })); - - it('should reject the Promise on failure', waitForAsync(() => { - resourceLoader = createCachedResourceLoader(); - resourceLoader.get('unknown.html').then(() => { - throw new Error('Not expected to succeed.'); - }, () => {/* success */}); - })); - - it('should allow fakeAsync Tests to load components with templateUrl synchronously', - fakeAsync(() => { - const loader = createCachedResourceLoader(); - @Component({selector: 'test-cmp', templateUrl: 'test.html'}) - class TestComponent { - } - - // resolveComponentResources(url => loader.get(url)); - tick(); - - TestBed.configureTestingModule({declarations: [TestComponent]}); - TestBed.compileComponents(); - tick(); - - const fixture = TestBed.createComponent(TestComponent); - - // This should initialize the fixture. - tick(); - - expect(fixture.debugElement.children[0].nativeElement).toHaveText('Hello'); - })); - }); -} - -function setTemplateCache(cache: {}|null): void { - (window).$templateCache = cache; -}