From 787d1f955f4f52be2f47d96111ce0299581a3900 Mon Sep 17 00:00:00 2001 From: Jason Teplitz Date: Fri, 11 Sep 2015 13:45:31 -0700 Subject: [PATCH] fix(Typings): Remove public exports added in 1926335b85af6c1fe56f4e36d0b95dcc92bb5c42 Closes #4147 --- docs/typescript-definition-package/index.js | 16 +- modules/angular2/angular2.ts | 2 +- modules/angular2/core.ts | 5 - modules/angular2/http.ts | 1 - modules/angular2/router.ts | 37 -- modules/angular2/src/core/change_detection.ts | 13 +- .../core/change_detection/change_detection.ts | 10 +- modules/angular2/src/core/compiler.ts | 10 - .../angular2/src/core/debug/debug_element.ts | 9 +- modules/angular2/src/core/pipes.ts | 2 - modules/angular2/src/core/render.ts | 9 +- .../src/core/render/dom/dom_renderer.ts | 3 + modules/angular2/src/core/render/render.ts | 3 - .../src/http/backends/jsonp_backend.ts | 6 + modules/angular2/src/router/instruction.ts | 3 + modules/angular2/src/router/router_outlet.ts | 3 + .../src/test_lib/test_component_builder.ts | 8 +- .../shared/client_message_broker.ts | 6 + .../shared/service_message_broker.ts | 6 + .../compiler/dynamic_component_loader_spec.ts | 204 ++++++----- .../core/compiler/integration_dart_spec.dart | 18 +- .../test/core/compiler/integration_spec.ts | 334 ++++++++++-------- .../compiler/projection_integration_spec.ts | 107 +++--- .../core/compiler/query_integration_spec.ts | 87 +++-- .../test/core/debug/debug_element_spec.ts | 43 +-- .../debug/debug_element_view_listener_spec.ts | 15 +- .../test/core/directives/ng_class_spec.ts | 72 ++-- .../test/core/directives/ng_for_spec.ts | 88 ++--- .../test/core/directives/ng_if_spec.ts | 112 +++--- .../test/core/directives/ng_style_spec.ts | 55 +-- .../test/core/directives/ng_switch_spec.ts | 55 +-- .../test/core/directives/non_bindable_spec.ts | 6 +- .../test/core/forms/integration_spec.ts | 209 +++++------ .../test/core/forward_ref_integration_spec.ts | 3 +- .../core/render/dom/compiler/selector_spec.ts | 1 + .../dom/compiler/style_encapsulator_spec.ts | 1 + .../text_interpolation_parser_spec.ts | 1 + .../render/dom/compiler/view_loader_spec.ts | 1 + .../dom/dom_renderer_integration_spec.ts | 1 + .../router/integration/lifecycle_hook_spec.ts | 34 +- .../router/integration/navigation_spec.ts | 39 +- .../integration/router_integration_spec.ts | 30 +- .../router/integration/router_link_spec.ts | 44 ++- .../test/router/route_recognizer_spec.ts | 2 + .../angular2/test/router/router_link_spec.ts | 4 +- .../test_lib/test_component_builder_spec.ts | 36 +- modules/angular2/test_lib.ts | 6 - modules/angular2/web_worker/ui.ts | 14 +- modules/angular2/web_worker/worker.ts | 24 +- .../src/web_workers/message_broker/index.ts | 10 +- .../common/directive_metadata_reader.dart | 3 +- 51 files changed, 943 insertions(+), 868 deletions(-) diff --git a/docs/typescript-definition-package/index.js b/docs/typescript-definition-package/index.js index a0b73f08ef..decc921625 100644 --- a/docs/typescript-definition-package/index.js +++ b/docs/typescript-definition-package/index.js @@ -60,27 +60,21 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, { id: 'angular2/router', references: ['./angular2.d.ts'], - remapTypes: {Type: 'ng.Type'}, + remapTypes: {Type: 'ng.Type', InjectableReference: 'ng.InjectableReference'}, modules: {'angular2/router': {namespace: 'ngRouter', id: 'angular2/router'}} }, { id: 'angular2/http', references: ['./angular2.d.ts'], - remapTypes: {Type: 'ng.Type', Observable: 'ng.Observable', EventEmitter: 'ng.EventEmitter'}, + remapTypes: {Type: 'ng.Type', Observable: 'ng.Observable', EventEmitter: 'ng.EventEmitter', InjectableReference: 'ng.InjectableReference' }, modules: {'angular2/http': {namespace: 'ngHttp', id: 'angular2/http'}} }, { id: 'angular2/test_lib', references: ['./angular2.d.ts', '../jasmine/jasmine.d.ts'], - remapTypes: { - Type: 'ng.Type', - Binding: 'ng.Binding', - ViewMetadata: 'ng.ViewMetadata', - Injector: 'ng.Injector', - Predicate: 'ng.Predicate', - ElementRef: 'ng.ElementRef', - DebugElement: 'ng.DebugElement' - }, + remapTypes: { Type: 'ng.Type', Binding: 'ng.Binding', ViewMetadata: 'ng.ViewMetadata', Injector: 'ng.Injector', + Predicate: 'ng.Predicate', ElementRef: 'ng.ElementRef', DebugElement: 'ng.DebugElement', + InjectableReference: 'ng.InjectableReference' }, modules: {'angular2/test_lib': {namespace: 'ngTestLib', id: 'angular2/test_lib'}} } ]; diff --git a/modules/angular2/angular2.ts b/modules/angular2/angular2.ts index 2f2a1ebc4c..6cf3a5f6de 100644 --- a/modules/angular2/angular2.ts +++ b/modules/angular2/angular2.ts @@ -1,4 +1,4 @@ export * from './core'; export * from './profile'; export * from './lifecycle_hooks'; -export * from './bootstrap'; +export * from './bootstrap'; \ No newline at end of file diff --git a/modules/angular2/core.ts b/modules/angular2/core.ts index 92a826586d..39ae69ae8e 100644 --- a/modules/angular2/core.ts +++ b/modules/angular2/core.ts @@ -19,8 +19,3 @@ export * from './src/core/directives'; export * from './src/core/forms'; export * from './src/core/debug'; export * from './src/core/change_detection'; -export {Reflector, ReflectionInfo} from './src/core/reflection/reflection'; -export { - PlatformReflectionCapabilities -} from './src/core/reflection/platform_reflection_capabilities'; -export {SetterFn, GetterFn, MethodFn} from './src/core/reflection/types'; diff --git a/modules/angular2/http.ts b/modules/angular2/http.ts index f88c6d7c18..6bb008b357 100644 --- a/modules/angular2/http.ts +++ b/modules/angular2/http.ts @@ -30,7 +30,6 @@ export {BaseRequestOptions, RequestOptions} from './src/http/base_request_option export {BaseResponseOptions, ResponseOptions} from './src/http/base_response_options'; export {XHRBackend, XHRConnection} from './src/http/backends/xhr_backend'; export {JSONPBackend, JSONPConnection} from './src/http/backends/jsonp_backend'; -export {BrowserJsonp} from './src/http/backends/browser_jsonp'; export {Http, Jsonp} from './src/http/http'; export {Headers} from './src/http/headers'; diff --git a/modules/angular2/router.ts b/modules/angular2/router.ts index c448616e8a..7beb32465c 100644 --- a/modules/angular2/router.ts +++ b/modules/angular2/router.ts @@ -7,47 +7,12 @@ export {Router, RootRouter} from './src/router/router'; export {RouterOutlet} from './src/router/router_outlet'; -export { - DynamicComponentLoader, - ComponentRef, - ElementRef, - Compiler, - AppViewManager, - ViewRef, - HostViewRef, - ProtoViewRef, - ViewContainerRef, - TemplateRef -} from './core'; -export { - Renderer, - RenderElementRef, - RenderViewRef, - RenderProtoViewRef, - RenderEventDispatcher, - RenderFragmentRef, - RenderViewWithFragments -} from './render'; -export { - Binding, - Injector, - ResolvedBinding, - Key, - Dependency, - ProtoInjector, - DependencyProvider, - BindingWithVisibility, - Visibility, - ResolvedFactory -} from './src/core/di'; export {RouterLink} from './src/router/router_link'; export {RouteParams} from './src/router/instruction'; export {RouteRegistry} from './src/router/route_registry'; export {LocationStrategy} from './src/router/location_strategy'; export {HashLocationStrategy} from './src/router/hash_location_strategy'; export {PathLocationStrategy} from './src/router/path_location_strategy'; -export {PathRecognizer, PathMatch} from './src/router/path_recognizer'; -export {RouteHandler} from './src/router/route_handler'; export {Location, APP_BASE_HREF} from './src/router/location'; export {Pipeline} from './src/router/pipeline'; export * from './src/router/route_config_decorator'; @@ -108,8 +73,6 @@ export const ROUTER_BINDINGS: any[] = CONST_EXPR([ })) ]); -export interface InjectableReference {} - function routerFactory(registry, pipeline, location, appRoot) { return new RootRouter(registry, pipeline, location, appRoot); } diff --git a/modules/angular2/src/core/change_detection.ts b/modules/angular2/src/core/change_detection.ts index 2107bcedcd..b131dcfb66 100644 --- a/modules/angular2/src/core/change_detection.ts +++ b/modules/angular2/src/core/change_detection.ts @@ -22,13 +22,6 @@ export { IterableDifferFactory, KeyValueDiffers, KeyValueDiffer, - KeyValueDifferFactory, - Lexer, - Parser, - ChangeDispatcher, - BindingTarget, - DirectiveIndex, - DebugContext, - ProtoChangeDetector -} from 'angular2/src/core/change_detection/change_detection'; -export * from 'angular2/src/core/change_detection/parser/ast'; + KeyValueDifferFactory + +} from './change_detection/change_detection'; diff --git a/modules/angular2/src/core/change_detection/change_detection.ts b/modules/angular2/src/core/change_detection/change_detection.ts index 25ebafd691..e079ffea7b 100644 --- a/modules/angular2/src/core/change_detection/change_detection.ts +++ b/modules/angular2/src/core/change_detection/change_detection.ts @@ -14,7 +14,15 @@ import { import {Injector, Inject, Injectable, OpaqueToken, Optional, Binding} from 'angular2/src/core/di'; import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {CONST, CONST_EXPR, isPresent, assertionsEnabled} from 'angular2/src/core/facade/lang'; -export * from './parser/ast'; + +export { + ASTWithSource, + AST, + AstTransformer, + PropertyRead, + LiteralArray, + ImplicitReceiver +} from './parser/ast'; export {Lexer} from './parser/lexer'; export {Parser} from './parser/parser'; diff --git a/modules/angular2/src/core/compiler.ts b/modules/angular2/src/core/compiler.ts index 2892b411eb..11be5c9879 100644 --- a/modules/angular2/src/core/compiler.ts +++ b/modules/angular2/src/core/compiler.ts @@ -19,14 +19,4 @@ export {ElementRef} from './compiler/element_ref'; export {TemplateRef} from './compiler/template_ref'; export {ViewRef, HostViewRef, ProtoViewRef} from './compiler/view_ref'; export {ViewContainerRef} from './compiler/view_container_ref'; -export {AppView, AppProtoView, AppProtoViewMergeMapping, AppViewContainer} from './compiler/view'; export {ComponentRef} from './compiler/dynamic_component_loader'; -export { - ElementInjector, - PreBuiltObjects, - TreeNode, - ProtoElementInjector, - DirectiveBinding, - EventEmitterAccessor -} from './compiler/element_injector'; -export {ElementBinder} from './compiler/element_binder'; diff --git a/modules/angular2/src/core/debug/debug_element.ts b/modules/angular2/src/core/debug/debug_element.ts index b7908b8577..db2655f622 100644 --- a/modules/angular2/src/core/debug/debug_element.ts +++ b/modules/angular2/src/core/debug/debug_element.ts @@ -16,14 +16,13 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref'; export class DebugElement { _elementInjector: ElementInjector; + /** + * @private + */ constructor(private _parentView: AppView, private _boundElementIndex: number) { this._elementInjector = this._parentView.elementInjectors[this._boundElementIndex]; } - static create(elementRef: ElementRef): DebugElement { - return new DebugElement(internalView(elementRef.parentView), elementRef.boundElementIndex); - } - get componentInstance(): any { if (!isPresent(this._elementInjector)) { return null; @@ -144,7 +143,7 @@ export class DebugElement { * @return {DebugElement} */ export function inspectElement(elementRef: ElementRef): DebugElement { - return DebugElement.create(elementRef); + return new DebugElement(internalView(elementRef.parentView), elementRef.boundElementIndex); } export function asNativeElements(arr: DebugElement[]): any[] { diff --git a/modules/angular2/src/core/pipes.ts b/modules/angular2/src/core/pipes.ts index 04845d61f3..2b918fe845 100644 --- a/modules/angular2/src/core/pipes.ts +++ b/modules/angular2/src/core/pipes.ts @@ -12,5 +12,3 @@ export {LimitToPipe} from './pipes/limit_to_pipe'; export {LowerCasePipe} from './pipes/lowercase_pipe'; export {NumberPipe, DecimalPipe, PercentPipe, CurrencyPipe} from './pipes/number_pipe'; export {UpperCasePipe} from './pipes/uppercase_pipe'; -export {ProtoPipes} from './pipes/pipes'; -export {PipeBinding} from './pipes/pipe_binding'; diff --git a/modules/angular2/src/core/render.ts b/modules/angular2/src/core/render.ts index 79c2ce5a82..1aaa3c872d 100644 --- a/modules/angular2/src/core/render.ts +++ b/modules/angular2/src/core/render.ts @@ -12,12 +12,5 @@ export { ViewDefinition, DOCUMENT, APP_ID, - MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE, - EventManager, - SharedStylesHost, - DomSharedStylesHost, - TemplateCloner, - ViewType, - RenderProtoViewMergeMapping, - EventManagerPlugin + MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE } from './render/render'; diff --git a/modules/angular2/src/core/render/dom/dom_renderer.ts b/modules/angular2/src/core/render/dom/dom_renderer.ts index a282484a6e..276ab5edea 100644 --- a/modules/angular2/src/core/render/dom/dom_renderer.ts +++ b/modules/angular2/src/core/render/dom/dom_renderer.ts @@ -38,6 +38,9 @@ const REFLECT_PREFIX: string = 'ng-reflect-'; export class DomRenderer extends Renderer { _document; + /** + * @private + */ constructor(private _eventManager: EventManager, private _domSharedStylesHost: DomSharedStylesHost, private _templateCloner: TemplateCloner, @Inject(DOCUMENT) document) { diff --git a/modules/angular2/src/core/render/render.ts b/modules/angular2/src/core/render/render.ts index c41358e15d..f15db9027c 100644 --- a/modules/angular2/src/core/render/render.ts +++ b/modules/angular2/src/core/render/render.ts @@ -10,7 +10,4 @@ export * from './dom/compiler/compiler'; export * from './dom/dom_renderer'; export * from './dom/dom_tokens'; export * from './dom/template_cloner'; -export * from './dom/events/event_manager'; -export * from './dom/view/shared_styles_host'; -export * from './dom/template_cloner'; export * from './api'; diff --git a/modules/angular2/src/http/backends/jsonp_backend.ts b/modules/angular2/src/http/backends/jsonp_backend.ts index c9b4d00563..57cfe58297 100644 --- a/modules/angular2/src/http/backends/jsonp_backend.ts +++ b/modules/angular2/src/http/backends/jsonp_backend.ts @@ -18,6 +18,9 @@ export class JSONPConnection implements Connection { private _responseData: any; private _finished: boolean = false; + /** + * @private + */ constructor(req: Request, private _dom: BrowserJsonp, private baseResponseOptions?: ResponseOptions) { if (req.method !== RequestMethods.Get) { @@ -91,6 +94,9 @@ export class JSONPConnection implements Connection { @Injectable() export class JSONPBackend implements ConnectionBackend { + /** + * @private + */ constructor(private _browserJSONP: BrowserJsonp, private _baseResponseOptions: ResponseOptions) {} createConnection(request: Request): JSONPConnection { return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions); diff --git a/modules/angular2/src/router/instruction.ts b/modules/angular2/src/router/instruction.ts index 101d67e716..ec25c9b81e 100644 --- a/modules/angular2/src/router/instruction.ts +++ b/modules/angular2/src/router/instruction.ts @@ -92,6 +92,9 @@ function stringifyAux(instruction: Instruction): string { export class ComponentInstruction { reuse: boolean = false; + /** + * @private + */ constructor(public urlPath: string, public urlParams: string[], private _recognizer: PathRecognizer, public params: StringMap = null) {} diff --git a/modules/angular2/src/router/router_outlet.ts b/modules/angular2/src/router/router_outlet.ts index 7602ac0f9b..d8ca4cf0c3 100644 --- a/modules/angular2/src/router/router_outlet.ts +++ b/modules/angular2/src/router/router_outlet.ts @@ -31,6 +31,9 @@ export class RouterOutlet { private _componentRef: ComponentRef = null; private _currentInstruction: ComponentInstruction = null; + /** + * @private + */ constructor(private _elementRef: ElementRef, private _loader: DynamicComponentLoader, private _parentRouter: routerMod.Router, @Attribute('name') nameAttr: string) { if (isPresent(nameAttr)) { diff --git a/modules/angular2/src/test_lib/test_component_builder.ts b/modules/angular2/src/test_lib/test_component_builder.ts index bc51c01935..53974958e1 100644 --- a/modules/angular2/src/test_lib/test_component_builder.ts +++ b/modules/angular2/src/test_lib/test_component_builder.ts @@ -22,12 +22,16 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DebugElement} from 'angular2/src/core/debug/debug_element'; -export class RootTestComponent extends DebugElement { +export class RootTestComponent { _componentRef: ComponentRef; _componentParentView: AppView; + debugElement: DebugElement; + /** + * @private + */ constructor(componentRef: ComponentRef) { - super(internalView(componentRef.hostView), 0); + this.debugElement = new DebugElement(internalView(componentRef.hostView), 0); this._componentParentView = internalView(componentRef.hostView); this._componentRef = componentRef; diff --git a/modules/angular2/src/web_workers/shared/client_message_broker.ts b/modules/angular2/src/web_workers/shared/client_message_broker.ts index 16c25c540b..a1e911c4b8 100644 --- a/modules/angular2/src/web_workers/shared/client_message_broker.ts +++ b/modules/angular2/src/web_workers/shared/client_message_broker.ts @@ -16,6 +16,9 @@ export {Type} from "angular2/src/core/facade/lang"; @Injectable() export class ClientMessageBrokerFactory { + /** + * @private + */ constructor(private _messageBus: MessageBus, protected _serializer: Serializer) {} /** @@ -31,6 +34,9 @@ export class ClientMessageBroker { private _pending: Map> = new Map>(); private _sink: EventEmitter; + /** + * @private + */ constructor(messageBus: MessageBus, protected _serializer: Serializer, public channel) { this._sink = messageBus.to(channel); var source = messageBus.from(channel); diff --git a/modules/angular2/src/web_workers/shared/service_message_broker.ts b/modules/angular2/src/web_workers/shared/service_message_broker.ts index 381e95b78e..427529d9df 100644 --- a/modules/angular2/src/web_workers/shared/service_message_broker.ts +++ b/modules/angular2/src/web_workers/shared/service_message_broker.ts @@ -12,6 +12,9 @@ import { @Injectable() export class ServiceMessageBrokerFactory { + /** + * @private + */ constructor(private _messageBus: MessageBus, protected _serializer: Serializer) {} /** @@ -33,6 +36,9 @@ export class ServiceMessageBroker { private _sink: EventEmitter; private _methods: Map = new Map(); + /** + * @private + */ constructor(messageBus: MessageBus, private _serializer: Serializer, public channel) { this._sink = messageBus.to(channel); var source = messageBus.from(channel); diff --git a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts index 6751715202..4d5a7df4f6 100644 --- a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts +++ b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts @@ -29,41 +29,42 @@ export function main() { describe('DynamicComponentLoader', function() { describe("loading into a location", () => { it('should work', - inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], - (loader, tcb: TestComponentBuilder, async) => { - tcb.overrideView( - MyComp, - new ViewMetadata( - {template: '', directives: [Location]})) - .createAsync(MyComp) - .then((tc) => { + inject( + [DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], + (loader, tcb: TestComponentBuilder, async) => { + tcb.overrideView( + MyComp, new ViewMetadata( + {template: '', directives: [Location]})) + .createAsync(MyComp) + .then((tc) => { - loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc') - .then(ref => { - expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;"); - async.done(); - }); - }); - })); + loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc') + .then(ref => { + expect(tc.debugElement.nativeElement) + .toHaveText("Location;DynamicallyLoaded;"); + async.done(); + }); + }); + })); it('should return a disposable component ref', - inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], - (loader, tcb: TestComponentBuilder, async) => { - tcb.overrideView( - MyComp, - new ViewMetadata( - {template: '', directives: [Location]})) - .createAsync(MyComp) - .then((tc) => { + inject( + [DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], + (loader, tcb: TestComponentBuilder, async) => { + tcb.overrideView( + MyComp, new ViewMetadata( + {template: '', directives: [Location]})) + .createAsync(MyComp) + .then((tc) => { - loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc') - .then(ref => { - ref.dispose(); - expect(tc.nativeElement).toHaveText("Location;"); - async.done(); - }); - }); - })); + loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc') + .then(ref => { + ref.dispose(); + expect(tc.debugElement.nativeElement).toHaveText("Location;"); + async.done(); + }); + }); + })); it('should allow to dispose even if the location has been removed', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], @@ -78,45 +79,48 @@ export function main() { {template: '', directives: [Location]})) .createAsync(MyComp) .then((tc) => { - tc.componentInstance.ctxBoolProp = true; + tc.debugElement.componentInstance.ctxBoolProp = true; tc.detectChanges(); - var childCompEl = tc.query(By.css('child-cmp')); + var childCompEl = tc.debugElement.query(By.css('child-cmp')); loader.loadIntoLocation(DynamicallyLoaded, childCompEl.elementRef, 'loc') .then(ref => { - expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;"); + expect(tc.debugElement.nativeElement) + .toHaveText("Location;DynamicallyLoaded;"); - tc.componentInstance.ctxBoolProp = false; + tc.debugElement.componentInstance.ctxBoolProp = false; tc.detectChanges(); - expect(tc.nativeElement).toHaveText(""); + expect(tc.debugElement.nativeElement).toHaveText(""); ref.dispose(); - expect(tc.nativeElement).toHaveText(""); + expect(tc.debugElement.nativeElement).toHaveText(""); async.done(); }); }); })); it('should update host properties', - inject( - [DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], - (loader, tcb: TestComponentBuilder, async) => { - tcb.overrideView( - MyComp, new ViewMetadata( - {template: '', directives: [Location]})) - .createAsync(MyComp) - .then((tc) => { - loader.loadIntoLocation(DynamicallyLoadedWithHostProps, tc.elementRef, 'loc') - .then(ref => { - ref.instance.id = "new value"; + inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], + (loader, tcb: TestComponentBuilder, async) => { + tcb.overrideView( + MyComp, + new ViewMetadata( + {template: '', directives: [Location]})) + .createAsync(MyComp) + .then((tc) => { + loader.loadIntoLocation(DynamicallyLoadedWithHostProps, + tc.debugElement.elementRef, 'loc') + .then(ref => { + ref.instance.id = "new value"; - tc.detectChanges(); + tc.detectChanges(); - var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1]; - expect((newlyInsertedElement).id).toEqual("new value"); - async.done(); - }); - }); - })); + var newlyInsertedElement = + DOM.childNodes(tc.debugElement.nativeElement)[1]; + expect((newlyInsertedElement).id).toEqual("new value"); + async.done(); + }); + }); + })); it('should throw if the variable does not exist', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], @@ -128,7 +132,8 @@ export function main() { .createAsync(MyComp) .then((tc) => { expect(() => loader.loadIntoLocation(DynamicallyLoadedWithHostProps, - tc.elementRef, 'someUnknownVariable')) + tc.debugElement.elementRef, + 'someUnknownVariable')) .toThrowError('Could not find variable someUnknownVariable'); async.done(); }); @@ -136,59 +141,60 @@ export function main() { }); describe("loading next to a location", () => { - it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], - (loader, tcb: TestComponentBuilder, async) => { - tcb.overrideView( - MyComp, new ViewMetadata({ - template: '
', - directives: [Location] - })) - .createAsync(MyComp) - .then((tc) => { - loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef) - .then(ref => { - expect(tc.nativeElement).toHaveText("Location;"); - expect(DOM.nextSibling(tc.nativeElement)) - .toHaveText('DynamicallyLoaded;'); - - async.done(); - }); - }); - })); - - it('should return a disposable component ref', + it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], (loader, tcb: TestComponentBuilder, async) => { tcb.overrideView(MyComp, new ViewMetadata({ template: '
', directives: [Location] })) - . - - createAsync(MyComp) + .createAsync(MyComp) .then((tc) => { - loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef) + loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef) .then(ref => { - loader.loadNextToLocation(DynamicallyLoaded2, tc.elementRef) - .then(ref2 => { - var firstSibling = DOM.nextSibling(tc.nativeElement); - var secondSibling = DOM.nextSibling(firstSibling); - expect(tc.nativeElement).toHaveText("Location;"); - expect(firstSibling).toHaveText("DynamicallyLoaded;"); - expect(secondSibling).toHaveText("DynamicallyLoaded2;"); + expect(tc.debugElement.nativeElement).toHaveText("Location;"); + expect(DOM.nextSibling(tc.debugElement.nativeElement)) + .toHaveText('DynamicallyLoaded;'); - ref2.dispose(); - - firstSibling = DOM.nextSibling(tc.nativeElement); - secondSibling = DOM.nextSibling(firstSibling); - expect(secondSibling).toBeNull(); - - async.done(); - }); + async.done(); }); }); })); + it('should return a disposable component ref', + inject( + [DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], + (loader, tcb: TestComponentBuilder, async) => { + tcb.overrideView(MyComp, new ViewMetadata({ + template: '
', + directives: [Location] + })) + . + + createAsync(MyComp) + .then((tc) => { + loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef) + .then(ref => { + loader.loadNextToLocation(DynamicallyLoaded2, tc.debugElement.elementRef) + .then(ref2 => { + var firstSibling = DOM.nextSibling(tc.debugElement.nativeElement); + var secondSibling = DOM.nextSibling(firstSibling); + expect(tc.debugElement.nativeElement).toHaveText("Location;"); + expect(firstSibling).toHaveText("DynamicallyLoaded;"); + expect(secondSibling).toHaveText("DynamicallyLoaded2;"); + + ref2.dispose(); + + firstSibling = DOM.nextSibling(tc.debugElement.nativeElement); + secondSibling = DOM.nextSibling(firstSibling); + expect(secondSibling).toBeNull(); + + async.done(); + }); + }); + }); + })); + it('should update host properties', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter], (loader, tcb: TestComponentBuilder, async) => { @@ -200,13 +206,15 @@ export function main() { .createAsync(MyComp) .then((tc) => { - loader.loadNextToLocation(DynamicallyLoadedWithHostProps, tc.elementRef) + loader.loadNextToLocation(DynamicallyLoadedWithHostProps, + tc.debugElement.elementRef) .then(ref => { ref.instance.id = "new value"; tc.detectChanges(); - var newlyInsertedElement = DOM.nextSibling(tc.nativeElement); + var newlyInsertedElement = + DOM.nextSibling(tc.debugElement.nativeElement); expect((newlyInsertedElement).id).toEqual("new value"); async.done(); diff --git a/modules/angular2/test/core/compiler/integration_dart_spec.dart b/modules/angular2/test/core/compiler/integration_dart_spec.dart index cfd9ff3950..9916e370f4 100644 --- a/modules/angular2/test/core/compiler/integration_dart_spec.dart +++ b/modules/angular2/test/core/compiler/integration_dart_spec.dart @@ -56,7 +56,7 @@ main() { .createAsync(Dummy) .then((tc) { tc.detectChanges(); - expect(asNativeElements(tc.componentViewChildren)) + expect(asNativeElements(tc.debugElement.componentViewChildren)) .toHaveText('[Hello, World]'); async.done(); }); @@ -112,7 +112,7 @@ main() { .createAsync(Dummy) .then((tc) { tc.detectChanges(); - expect(asNativeElements(tc.componentViewChildren)) + expect(asNativeElements(tc.debugElement.componentViewChildren)) .toHaveText('prop:foo-prop;map:foo-map'); async.done(); }); @@ -149,7 +149,7 @@ main() { .createAsync(Dummy) .then((tc) { tc.detectChanges(); - var cmp = tc.componentViewChildren[0].inject(OnChangeComponent); + var cmp = tc.debugElement.componentViewChildren[0].inject(OnChangeComponent); expect(cmp.prop).toEqual('hello'); expect(cmp.changes.containsKey('prop')).toEqual(true); async.done(); @@ -171,19 +171,19 @@ main() { directives: [ComponentWithObservableList])) .createAsync(Dummy) .then((tc) { - tc.componentInstance.value = new ObservableList.from([1, 2]); + tc.debugElement.componentInstance.value = new ObservableList.from([1, 2]); tc.detectChanges(); expect(log.result()).toEqual("check"); - expect(asNativeElements(tc.componentViewChildren)).toHaveText('12'); + expect(asNativeElements(tc.debugElement.componentViewChildren)).toHaveText('12'); tc.detectChanges(); // we did not change the list => no checks expect(log.result()).toEqual("check"); - tc.componentInstance.value.add(3); + tc.debugElement.componentInstance.value.add(3); flushMicrotasks(); @@ -191,16 +191,16 @@ main() { // we changed the list => a check expect(log.result()).toEqual("check; check"); - expect(asNativeElements(tc.componentViewChildren)) + expect(asNativeElements(tc.debugElement.componentViewChildren)) .toHaveText('123'); // we replaced the list => a check - tc.componentInstance.value = new ObservableList.from([5, 6, 7]); + tc.debugElement.componentInstance.value = new ObservableList.from([5, 6, 7]); tc.detectChanges(); expect(log.result()).toEqual("check; check; check"); - expect(asNativeElements(tc.componentViewChildren)) + expect(asNativeElements(tc.debugElement.componentViewChildren)) .toHaveText('567'); }); }))); diff --git a/modules/angular2/test/core/compiler/integration_spec.ts b/modules/angular2/test/core/compiler/integration_spec.ts index cd7db0044e..f08c0dfe84 100644 --- a/modules/angular2/test/core/compiler/integration_spec.ts +++ b/modules/angular2/test/core/compiler/integration_spec.ts @@ -17,7 +17,8 @@ import { TestComponentBuilder, fakeAsync, tick, - clearPendingTimers + clearPendingTimers, + RootTestComponent } from 'angular2/test_lib'; @@ -105,10 +106,10 @@ export function main() { tcb.overrideView(MyComp, new ViewMetadata({template: '
{{ctxProp}}
'})) .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Hello World!'; + rootTC.debugElement.componentInstance.ctxProp = 'Hello World!'; rootTC.detectChanges(); - expect(rootTC.nativeElement).toHaveText('Hello World!'); + expect(rootTC.debugElement.nativeElement).toHaveText('Hello World!'); async.done(); }); @@ -119,10 +120,10 @@ export function main() { tcb.overrideView(MyComp, new ViewMetadata({template: '
{{null}}{{ctxProp}}
'})) .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = null; + rootTC.debugElement.componentInstance.ctxProp = null; rootTC.detectChanges(); - expect(rootTC.nativeElement).toHaveText(''); + expect(rootTC.debugElement.nativeElement).toHaveText(''); async.done(); }); })); @@ -133,10 +134,11 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Hello World!'; + rootTC.debugElement.componentInstance.ctxProp = 'Hello World!'; rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].nativeElement.id).toEqual('Hello World!'); + expect(rootTC.debugElement.componentViewChildren[0].nativeElement.id) + .toEqual('Hello World!'); async.done(); }); })); @@ -149,16 +151,16 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Initial aria label'; + rootTC.debugElement.componentInstance.ctxProp = 'Initial aria label'; rootTC.detectChanges(); - expect( - DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label')) + expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement, + 'aria-label')) .toEqual('Initial aria label'); - rootTC.componentInstance.ctxProp = 'Changed aria label'; + rootTC.debugElement.componentInstance.ctxProp = 'Changed aria label'; rootTC.detectChanges(); - expect( - DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label')) + expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement, + 'aria-label')) .toEqual('Changed aria label'); async.done(); @@ -174,11 +176,13 @@ export function main() { .then((rootTC) => { rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(0); + expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex) + .toEqual(0); - rootTC.componentInstance.ctxNumProp = 5; + rootTC.debugElement.componentInstance.ctxNumProp = 5; rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(5); + expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex) + .toEqual(5); async.done(); }); @@ -193,11 +197,13 @@ export function main() { .then((rootTC) => { rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeFalsy(); + expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly) + .toBeFalsy(); - rootTC.componentInstance.ctxBoolProp = true; + rootTC.debugElement.componentInstance.ctxBoolProp = true; rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeTruthy(); + expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly) + .toBeTruthy(); async.done(); }); @@ -211,14 +217,16 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Some HTML'; + rootTC.debugElement.componentInstance.ctxProp = 'Some HTML'; rootTC.detectChanges(); - expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement)) + expect( + DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement)) .toEqual('Some HTML'); - rootTC.componentInstance.ctxProp = 'Some other
HTML
'; + rootTC.debugElement.componentInstance.ctxProp = 'Some other
HTML
'; rootTC.detectChanges(); - expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement)) + expect( + DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement)) .toEqual('Some other
HTML
'); async.done(); @@ -233,8 +241,8 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - var nativeEl = rootTC.componentViewChildren[0].nativeElement; - rootTC.componentInstance.ctxProp = 'foo bar'; + var nativeEl = rootTC.debugElement.componentViewChildren[0].nativeElement; + rootTC.debugElement.componentInstance.ctxProp = 'foo bar'; rootTC.detectChanges(); expect(nativeEl).toHaveCssClass('foo'); @@ -258,14 +266,16 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Hello World!'; + rootTC.debugElement.componentInstance.ctxProp = 'Hello World!'; rootTC.detectChanges(); - expect(rootTC.componentViewChildren[0].inject(MyDir).dirProp) + expect(rootTC.debugElement.componentViewChildren[0].inject(MyDir).dirProp) .toEqual('Hello World!'); - expect(rootTC.componentViewChildren[1].inject(MyDir).dirProp).toEqual('Hi there!'); - expect(rootTC.componentViewChildren[2].inject(MyDir).dirProp).toEqual('Hi there!'); - expect(rootTC.componentViewChildren[3].inject(MyDir).dirProp) + expect(rootTC.debugElement.componentViewChildren[1].inject(MyDir).dirProp) + .toEqual('Hi there!'); + expect(rootTC.debugElement.componentViewChildren[2].inject(MyDir).dirProp) + .toEqual('Hi there!'); + expect(rootTC.debugElement.componentViewChildren[3].inject(MyDir).dirProp) .toEqual('One more Hello World!'); async.done(); }); @@ -284,10 +294,10 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'a'; + rootTC.debugElement.componentInstance.ctxProp = 'a'; rootTC.detectChanges(); - var dir = rootTC.componentViewChildren[0].getLocal('dir'); + var dir = rootTC.debugElement.componentViewChildren[0].getLocal('dir'); expect(dir.dirProp).toEqual('aa'); async.done(); }); @@ -305,7 +315,7 @@ export function main() { rootTC.detectChanges(); - expect(rootTC.nativeElement).toHaveText('hello'); + expect(rootTC.debugElement.nativeElement).toHaveText('hello'); async.done(); }); })); @@ -321,10 +331,10 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'Hello World!'; + rootTC.debugElement.componentInstance.ctxProp = 'Hello World!'; rootTC.detectChanges(); - var tc = rootTC.componentViewChildren[0]; + var tc = rootTC.debugElement.componentViewChildren[0]; expect(tc.inject(MyDir).dirProp).toEqual('Hello World!'); expect(tc.inject(ChildComp).dirProp).toEqual(null); @@ -358,7 +368,7 @@ export function main() { })) .createAsync(MyComp) .then((rootTC) => { - expect(rootTC.nativeElement).toHaveText('noduplicate'); + expect(rootTC.debugElement.nativeElement).toHaveText('noduplicate'); async.done(); }); })); @@ -375,7 +385,7 @@ export function main() { })) .createAsync(MyComp) .then((rootTC) => { - expect(rootTC.nativeElement).toHaveText('othernoduplicate'); + expect(rootTC.debugElement.nativeElement).toHaveText('othernoduplicate'); async.done(); }); })); @@ -387,14 +397,14 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - var tc = rootTC.componentViewChildren[0]; + var tc = rootTC.debugElement.componentViewChildren[0]; var idDir = tc.inject(IdDir); - rootTC.componentInstance.ctxProp = 'some_id'; + rootTC.debugElement.componentInstance.ctxProp = 'some_id'; rootTC.detectChanges(); expect(idDir.id).toEqual('some_id'); - rootTC.componentInstance.ctxProp = 'other_id'; + rootTC.debugElement.componentInstance.ctxProp = 'other_id'; rootTC.detectChanges(); expect(idDir.id).toEqual('other_id'); @@ -413,7 +423,7 @@ export function main() { .then((rootTC) => { rootTC.detectChanges(); - expect(rootTC.nativeElement).toHaveText('hello'); + expect(rootTC.debugElement.nativeElement).toHaveText('hello'); async.done(); }); })); @@ -443,7 +453,7 @@ export function main() { rootTC.detectChanges(); - var childNodesOfWrapper = rootTC.componentViewChildren; + var childNodesOfWrapper = rootTC.debugElement.componentViewChildren; // 1 template + 2 copies. expect(childNodesOfWrapper.length).toBe(3); expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello'); @@ -465,7 +475,7 @@ export function main() { .then((rootTC) => { rootTC.detectChanges(); - var childNodesOfWrapper = rootTC.componentViewChildren; + var childNodesOfWrapper = rootTC.debugElement.componentViewChildren; // 1 template + 2 copies. expect(childNodesOfWrapper.length).toBe(3); expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello'); @@ -484,10 +494,10 @@ export function main() { })) .createAsync(MyComp) .then((rootTC) => { - rootTC.componentInstance.ctxProp = 'From myComp'; + rootTC.debugElement.componentInstance.ctxProp = 'From myComp'; rootTC.detectChanges(); - expect(rootTC.nativeElement) + expect(rootTC.debugElement.nativeElement) .toHaveText( 'TOOLBAR(From myComp,From toolbar,Component with an injected host)'); @@ -506,7 +516,7 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - expect(rootTC.componentViewChildren[0].getLocal('alice')) + expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice')) .toBeAnInstanceOf(ChildComp); async.done(); @@ -522,7 +532,7 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - expect(rootTC.componentViewChildren[0].getLocal('localdir')) + expect(rootTC.debugElement.componentViewChildren[0].getLocal('localdir')) .toBeAnInstanceOf(ExportDir); async.done(); @@ -543,7 +553,7 @@ export function main() { .then((rootTC) => { rootTC.detectChanges(); - expect(rootTC.nativeElement) + expect(rootTC.debugElement.nativeElement) .toHaveText('hellohello'); // this first one is the // component, the second one is // the text binding @@ -563,32 +573,33 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - expect(rootTC.componentViewChildren[0].getLocal('alice')) + expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice')) .toBeAnInstanceOf(ChildComp); - expect(rootTC.componentViewChildren[0].getLocal('bob')) + expect(rootTC.debugElement.componentViewChildren[0].getLocal('bob')) .toBeAnInstanceOf(ChildComp); - expect(rootTC.componentViewChildren[0].getLocal('alice')) - .not.toBe(rootTC.componentViewChildren[0].getLocal('bob')); + expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice')) + .not.toBe( + rootTC.debugElement.componentViewChildren[0].getLocal('bob')); async.done(); })})); it('should assign the component instance to a var- with shorthand syntax', inject([TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, - async) => {tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [ChildComp] - })) + (tcb: TestComponentBuilder, async) => { + tcb.overrideView(MyComp, new ViewMetadata({ + template: '', + directives: [ChildComp] + })) - .createAsync(MyComp) - .then((rootTC) => { + .createAsync(MyComp) + .then((rootTC) => { - expect(rootTC.componentViewChildren[0].getLocal('alice')) - .toBeAnInstanceOf(ChildComp); + expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice')) + .toBeAnInstanceOf(ChildComp); - async.done(); - })})); + async.done(); + })})); it('should assign the element instance to a user-defined variable', inject([TestComponentBuilder, AsyncTestCompleter], @@ -600,7 +611,8 @@ export function main() { .createAsync(MyComp) .then((rootTC) => { - var value = rootTC.componentViewChildren[0].getLocal('alice'); + var value = + rootTC.debugElement.componentViewChildren[0].getLocal('alice'); expect(value).not.toBe(null); expect(value.tagName.toLowerCase()).toEqual('div'); @@ -608,21 +620,21 @@ export function main() { })})); it('should change dash-case to camel-case', - inject([TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '

', - directives: [ChildComp] - })) + inject( + [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { + tcb.overrideView(MyComp, new ViewMetadata({ + template: '

', + directives: [ChildComp] + })) - .createAsync(MyComp) - .then((rootTC) => { - expect(rootTC.componentViewChildren[0].getLocal('superAlice')) - .toBeAnInstanceOf(ChildComp); + .createAsync(MyComp) + .then((rootTC) => { + expect(rootTC.debugElement.componentViewChildren[0].getLocal('superAlice')) + .toBeAnInstanceOf(ChildComp); - async.done(); - }); - })); + async.done(); + }); + })); it('should allow to use variables in a for loop', inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, @@ -639,7 +651,8 @@ export function main() { rootTC.detectChanges(); // Get the element at index 1, since index 0 is the