diff --git a/modules/angular2/render.ts b/modules/angular2/render.ts index d846b129b1..22f1de953a 100644 --- a/modules/angular2/render.ts +++ b/modules/angular2/render.ts @@ -5,7 +5,7 @@ * This module provides advanced support for extending dom strategy. */ -export * from './src/render/dom/compiler/template_loader'; +export * from './src/render/dom/compiler/view_loader'; export * from './src/render/dom/shadow_dom/shadow_dom_strategy'; export * from './src/render/dom/shadow_dom/native_shadow_dom_strategy'; export * from './src/render/dom/shadow_dom/emulated_scoped_shadow_dom_strategy'; diff --git a/modules/angular2/src/core/application.ts b/modules/angular2/src/core/application.ts index 7202e9d061..f260c58b6e 100644 --- a/modules/angular2/src/core/application.ts +++ b/modules/angular2/src/core/application.ts @@ -24,7 +24,7 @@ import { defaultPipeRegistry } from 'angular2/change_detection'; import {ExceptionHandler} from './exception_handler'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver'; import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner'; import {TemplateResolver} from './compiler/template_resolver'; @@ -121,7 +121,7 @@ function _injectorBindings(appComponentType): List> { TemplateResolver, bind(PipeRegistry).toValue(defaultPipeRegistry), bind(ChangeDetection).toClass(bestChangeDetection), - TemplateLoader, + ViewLoader, DirectiveResolver, Parser, Lexer, diff --git a/modules/angular2/src/render/dom/compiler/compiler.ts b/modules/angular2/src/render/dom/compiler/compiler.ts index ca774deb8f..c5a69e8025 100644 --- a/modules/angular2/src/render/dom/compiler/compiler.ts +++ b/modules/angular2/src/render/dom/compiler/compiler.ts @@ -13,7 +13,7 @@ import { RenderProtoViewRef } from '../../api'; import {CompilePipeline} from './compile_pipeline'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {CompileStepFactory, DefaultStepFactory} from './compile_step_factory'; import {Parser} from 'angular2/change_detection'; import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy'; @@ -24,12 +24,10 @@ import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy'; * the CompilePipeline and the CompileSteps. */ export class DomCompiler extends RenderCompiler { - constructor(public _stepFactory: CompileStepFactory, public _templateLoader: TemplateLoader) { - super(); - } + constructor(public _stepFactory: CompileStepFactory, public _viewLoader: ViewLoader) { super(); } compile(view: ViewDefinition): Promise { - var tplPromise = this._templateLoader.load(view); + var tplPromise = this._viewLoader.load(view); return PromiseWrapper.then( tplPromise, (el) => this._compileTemplate(view, el, ViewType.COMPONENT), (e) => { throw new BaseException(`Failed to load the template for "${view.componentId}" : ${e}`); @@ -59,8 +57,7 @@ export class DomCompiler extends RenderCompiler { @Injectable() export class DefaultDomCompiler extends DomCompiler { - constructor(parser: Parser, shadowDomStrategy: ShadowDomStrategy, - templateLoader: TemplateLoader) { - super(new DefaultStepFactory(parser, shadowDomStrategy), templateLoader); + constructor(parser: Parser, shadowDomStrategy: ShadowDomStrategy, viewLoader: ViewLoader) { + super(new DefaultStepFactory(parser, shadowDomStrategy), viewLoader); } } diff --git a/modules/angular2/src/render/dom/compiler/template_loader.ts b/modules/angular2/src/render/dom/compiler/view_loader.ts similarity index 99% rename from modules/angular2/src/render/dom/compiler/template_loader.ts rename to modules/angular2/src/render/dom/compiler/view_loader.ts index 5e0c5b8c7a..ead6756125 100644 --- a/modules/angular2/src/render/dom/compiler/template_loader.ts +++ b/modules/angular2/src/render/dom/compiler/view_loader.ts @@ -16,7 +16,7 @@ import {StyleUrlResolver} from './style_url_resolver'; * TODO: Make public API once we are more confident in this approach. */ @Injectable() -export class TemplateLoader { +export class ViewLoader { _cache: Map> = new Map(); constructor(private _xhr: XHR, private _styleInliner: StyleInliner, diff --git a/modules/angular2/src/test_lib/test_injector.ts b/modules/angular2/src/test_lib/test_injector.ts index eba8ab9bc4..42dff5b564 100644 --- a/modules/angular2/src/test_lib/test_injector.ts +++ b/modules/angular2/src/test_lib/test_injector.ts @@ -11,7 +11,7 @@ import { defaultPipeRegistry } from 'angular2/change_detection'; import {ExceptionHandler} from 'angular2/src/core/exception_handler'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver'; import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader'; @@ -104,7 +104,7 @@ function _getAppBindings() { bind(TemplateResolver).toClass(MockTemplateResolver), bind(PipeRegistry).toValue(defaultPipeRegistry), bind(ChangeDetection).toClass(DynamicChangeDetection), - TemplateLoader, + ViewLoader, DynamicComponentLoader, DirectiveResolver, Parser, diff --git a/modules/angular2/src/transform/template_compiler/generator.dart b/modules/angular2/src/transform/template_compiler/generator.dart index e91835d1f4..41cd4a6be8 100644 --- a/modules/angular2/src/transform/template_compiler/generator.dart +++ b/modules/angular2/src/transform/template_compiler/generator.dart @@ -9,7 +9,7 @@ import 'package:angular2/src/render/api.dart'; import 'package:angular2/src/render/dom/compiler/compile_pipeline.dart'; import 'package:angular2/src/render/dom/compiler/style_inliner.dart'; import 'package:angular2/src/render/dom/compiler/style_url_resolver.dart'; -import 'package:angular2/src/render/dom/compiler/template_loader.dart'; +import 'package:angular2/src/render/dom/compiler/view_loader.dart'; import 'package:angular2/src/render/xhr.dart' show XHR; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/services/url_resolver.dart'; @@ -81,7 +81,7 @@ Future processTemplates(AssetReader reader, AssetId entryPoint, /// reflectively accessed from that template. class _TemplateExtractor { final CompileStepFactory _factory; - TemplateLoader _loader; + ViewLoader _loader; _TemplateExtractor(XHR xhr) : _factory = new CompileStepFactory(new ng.Parser(new ng.Lexer())) { @@ -90,7 +90,7 @@ class _TemplateExtractor { var styleUrlResolver = new StyleUrlResolver(urlResolver); var styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver); - _loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver); + _loader = new ViewLoader(xhr, styleInliner, styleUrlResolver); } Future<_ExtractResult> extractTemplates(ViewDefinition viewDef) async { diff --git a/modules/angular2/test/core/compiler/compiler_spec.ts b/modules/angular2/test/core/compiler/compiler_spec.ts index d06fabb633..35c010c46b 100644 --- a/modules/angular2/test/core/compiler/compiler_spec.ts +++ b/modules/angular2/test/core/compiler/compiler_spec.ts @@ -133,8 +133,7 @@ export function main() { cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js'); captureTemplate(new viewAnn.View({templateUrl: 'tpl/main.html'})) .then((renderTpl) => { - expect(renderTpl.templateAbsUrl) - .toEqual('http://www.app.com/cmp/tpl/main.html'); + expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/tpl/main.html'); async.done(); }); })); @@ -144,10 +143,8 @@ export function main() { captureTemplate(new viewAnn.View({styleUrls: ['css/1.css', 'css/2.css']})) .then((renderTpl) => { expect(renderTpl.styleAbsUrls) - .toEqual([ - 'http://www.app.com/cmp/css/1.css', - 'http://www.app.com/cmp/css/2.css' - ]); + .toEqual( + ['http://www.app.com/cmp/css/1.css', 'http://www.app.com/cmp/css/2.css']); async.done(); }); })); diff --git a/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts b/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts index db99e2f97c..fc4808d2cf 100644 --- a/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts +++ b/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts @@ -22,7 +22,7 @@ import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element'; import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step'; import {CompileStepFactory} from 'angular2/src/render/dom/compiler/compile_step_factory'; import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {resolveInternalDomProtoView} from 'angular2/src/render/dom/view/proto_view'; @@ -34,7 +34,7 @@ export function runCompilerCommonTests() { if (isBlank(urlData)) { urlData = new Map(); } - var tplLoader = new FakeTemplateLoader(urlData); + var tplLoader = new FakeViewLoader(urlData); mockStepFactory = new MockStepFactory([new MockStep(processClosure)]); return new DomCompiler(mockStepFactory, tplLoader); } @@ -168,7 +168,7 @@ var EMPTY_STEP = (parent, current, control) => { } }; -class FakeTemplateLoader extends TemplateLoader { +class FakeViewLoader extends ViewLoader { _urlData: Map; constructor(urlData) { super(null, null, null); diff --git a/modules/angular2/test/render/dom/compiler/style_url_resolver_spec.ts b/modules/angular2/test/render/dom/compiler/style_url_resolver_spec.ts index 43529642a7..1bfcdd5d61 100644 --- a/modules/angular2/test/render/dom/compiler/style_url_resolver_spec.ts +++ b/modules/angular2/test/render/dom/compiler/style_url_resolver_spec.ts @@ -7,9 +7,7 @@ export function main() { describe('StyleUrlResolver', () => { let styleUrlResolver; - beforeEach(() => { - styleUrlResolver = new StyleUrlResolver(new UrlResolver()); - }); + beforeEach(() => { styleUrlResolver = new StyleUrlResolver(new UrlResolver()); }); it('should resolve "url()" urls', () => { var css = ` diff --git a/modules/angular2/test/render/dom/compiler/template_loader_spec.ts b/modules/angular2/test/render/dom/compiler/view_loader_spec.ts similarity index 95% rename from modules/angular2/test/render/dom/compiler/template_loader_spec.ts rename to modules/angular2/test/render/dom/compiler/view_loader_spec.ts index fa1b34ec27..eb059d135e 100644 --- a/modules/angular2/test/render/dom/compiler/template_loader_spec.ts +++ b/modules/angular2/test/render/dom/compiler/view_loader_spec.ts @@ -11,7 +11,7 @@ import { xit, } from 'angular2/test_lib'; import {DOM} from 'angular2/src/dom/dom_adapter'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner'; import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver'; import {UrlResolver} from 'angular2/src/services/url_resolver'; @@ -23,7 +23,7 @@ import {XHR} from 'angular2/src/render/xhr'; import {MockXHR} from 'angular2/src/render/xhr_mock'; export function main() { - describe('TemplateLoader', () => { + describe('ViewLoader', () => { var loader, xhr, styleUrlResolver, urlResolver; beforeEach(() => { @@ -31,7 +31,7 @@ export function main() { urlResolver = new UrlResolver(); styleUrlResolver = new StyleUrlResolver(urlResolver); let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver); - loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver); + loader = new ViewLoader(xhr, styleInliner, styleUrlResolver); }); describe('html', () => { @@ -71,7 +71,7 @@ export function main() { xhr.reply('http://ng.io/foo.css', '/* foo.css */'); let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver); - let loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver); + let loader = new ViewLoader(xhr, styleInliner, styleUrlResolver); var view = new ViewDefinition({templateAbsUrl: 'http://ng.io/foo.html'}); loader.load(view).then((el) => { @@ -168,7 +168,7 @@ export function main() { xhr.reply('http://ng.io/foo.css', '/* foo.css */'); let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver); - let loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver); + let loader = new ViewLoader(xhr, styleInliner, styleUrlResolver); var view = new ViewDefinition( {templateAbsUrl: 'http://ng.io/foo.html', styles: ['@import "foo.css";']}); diff --git a/modules/benchmarks/src/compiler/compiler_benchmark.ts b/modules/benchmarks/src/compiler/compiler_benchmark.ts index 17b85032e0..a003e2defb 100644 --- a/modules/benchmarks/src/compiler/compiler_benchmark.ts +++ b/modules/benchmarks/src/compiler/compiler_benchmark.ts @@ -13,7 +13,7 @@ import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver'; import * as viewModule from 'angular2/src/core/annotations_impl/view'; import {Component, Directive, View} from 'angular2/angular2'; -import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {AppRootUrl} from 'angular2/src/services/app_root_url'; @@ -38,7 +38,7 @@ export function main() { var urlResolver = new UrlResolver(); var shadowDomStrategy = new NativeShadowDomStrategy(); var renderCompiler = new rc.DefaultDomCompiler(new Parser(new Lexer()), shadowDomStrategy, - new TemplateLoader(null, null, null)); + new ViewLoader(null, null, null)); var compiler = new Compiler( reader, cache, templateResolver, new ComponentUrlMapper(), urlResolver, renderCompiler, new ProtoViewFactory(new DynamicChangeDetection(null)), new FakeAppRootUrl());