parent
ecb5dc03f9
commit
85106375ac
|
@ -123,7 +123,6 @@ export function renderComponent<T>(
|
|||
// Create directive instance with factory() and store at index 0 in directives array
|
||||
component = baseDirectiveCreate(0, componentDef.factory() as T, componentDef);
|
||||
rootContext.components.push(component);
|
||||
|
||||
(elementNode.data as LViewData)[CONTEXT] = component;
|
||||
initChangeDetectorIfExisting(elementNode.nodeInjector, component, elementNode.data !);
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import {Type} from '../type';
|
|||
import {BaseDef, ComponentDefFeature, ComponentDefInternal, ComponentQuery, ComponentTemplate, ComponentType, DirectiveDefFeature, DirectiveDefInternal, DirectiveType, DirectiveTypesOrFactory, PipeDefInternal, PipeType, PipeTypesOrFactory} from './interfaces/definition';
|
||||
import {CssSelectorList, SelectorFlags} from './interfaces/projection';
|
||||
|
||||
|
||||
const EMPTY: {} = {};
|
||||
const EMPTY_ARRAY: any[] = [];
|
||||
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* it will be easy to implement such API.
|
||||
*/
|
||||
|
||||
import {ViewEncapsulation} from '../../metadata/view';
|
||||
import {RendererStyleFlags2, RendererType2} from '../../render/api';
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ export function patchComponentDefWithScope<C, M>(
|
|||
* on modules with components that have not fully compiled yet, but the result should not be used
|
||||
* until they have.
|
||||
*/
|
||||
export function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveScopes {
|
||||
function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveScopes {
|
||||
if (!isNgModule(moduleType)) {
|
||||
throw new Error(`${moduleType.name} does not have an ngModuleDef`);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ export function transitiveScopesFor<T>(moduleType: Type<T>): NgModuleTransitiveS
|
|||
});
|
||||
|
||||
def.imports.forEach(<I>(imported: Type<I>) => {
|
||||
let importedTyped = imported as Type<I>& {
|
||||
const importedTyped = imported as Type<I>& {
|
||||
// If imported is an @NgModule:
|
||||
ngModuleDef?: NgModuleDefInternal<I>;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ import {isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './err
|
|||
import {resolveDep} from './provider';
|
||||
import {dirtyParentQueries, getQueryValue} from './query';
|
||||
import {createInjector, createNgModuleRef, getComponentViewDefinitionFactory} from './refs';
|
||||
import {ArgumentType, BindingFlags, CheckType, DebugContext, DepDef, ElementData, NgModuleDefinition, NgModuleProviderDef, NodeDef, NodeFlags, NodeLogger, ProviderOverride, RootData, Services, ViewData, ViewDefinition, ViewState, asElementData, asPureExpressionData} from './types';
|
||||
import {ArgumentType, BindingFlags, CheckType, DebugContext, ElementData, NgModuleDefinition, NodeDef, NodeFlags, NodeLogger, ProviderOverride, RootData, Services, ViewData, ViewDefinition, ViewState, asElementData, asPureExpressionData} from './types';
|
||||
import {NOOP, isComponentView, renderNode, resolveDefinition, splitDepsDsl, viewParentEl} from './util';
|
||||
import {checkAndUpdateNode, checkAndUpdateView, checkNoChangesNode, checkNoChangesView, createComponentView, createEmbeddedView, createRootView, destroyView} from './view';
|
||||
|
||||
|
@ -509,6 +509,7 @@ class DebugContext_ implements DebugContext {
|
|||
private nodeDef: NodeDef;
|
||||
private elView: ViewData;
|
||||
private elDef: NodeDef;
|
||||
|
||||
constructor(public view: ViewData, public nodeIndex: number|null) {
|
||||
if (nodeIndex == null) {
|
||||
this.nodeIndex = nodeIndex = 0;
|
||||
|
@ -528,13 +529,18 @@ class DebugContext_ implements DebugContext {
|
|||
this.elDef = elDef;
|
||||
this.elView = elView;
|
||||
}
|
||||
|
||||
private get elOrCompView() {
|
||||
// Has to be done lazily as we use the DebugContext also during creation of elements...
|
||||
return asElementData(this.elView, this.elDef.nodeIndex).componentView || this.view;
|
||||
}
|
||||
|
||||
get injector(): Injector { return createInjector(this.elView, this.elDef); }
|
||||
|
||||
get component(): any { return this.elOrCompView.component; }
|
||||
|
||||
get context(): any { return this.elOrCompView.context; }
|
||||
|
||||
get providerTokens(): any[] {
|
||||
const tokens: any[] = [];
|
||||
if (this.elDef) {
|
||||
|
@ -549,6 +555,7 @@ class DebugContext_ implements DebugContext {
|
|||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
get references(): {[key: string]: any} {
|
||||
const references: {[key: string]: any} = {};
|
||||
if (this.elDef) {
|
||||
|
@ -565,14 +572,17 @@ class DebugContext_ implements DebugContext {
|
|||
}
|
||||
return references;
|
||||
}
|
||||
|
||||
get componentRenderElement() {
|
||||
const elData = findHostElement(this.elOrCompView);
|
||||
return elData ? elData.renderElement : undefined;
|
||||
}
|
||||
|
||||
get renderNode(): any {
|
||||
return this.nodeDef.flags & NodeFlags.TypeText ? renderNode(this.view, this.nodeDef) :
|
||||
renderNode(this.elView, this.elDef);
|
||||
}
|
||||
|
||||
logError(console: Console, ...values: any[]) {
|
||||
let logViewDef: ViewDefinition;
|
||||
let logNodeIndex: number;
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
import {ɵAnimationEngine, ɵNoopAnimationStyleNormalizer} from '@angular/animations/browser';
|
||||
import {MockAnimationDriver} from '@angular/animations/browser/testing';
|
||||
import {NgZone, RendererFactory2} from '@angular/core';
|
||||
import {NoopNgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {EventManager, ɵDomRendererFactory2, ɵDomSharedStylesHost} from '@angular/platform-browser';
|
||||
import {ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {EventManagerPlugin} from '@angular/platform-browser/src/dom/events/event_manager';
|
||||
|
||||
import {NoopNgZone} from '../../src/zone/ng_zone';
|
||||
|
||||
export class SimpleDomEventsPlugin extends EventManagerPlugin {
|
||||
constructor(doc: any) { super(doc); }
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import {CreateComponentOptions} from '../../src/render3/component';
|
|||
import {extractDirectiveDef, extractPipeDef} from '../../src/render3/definition';
|
||||
import {ComponentTemplate, ComponentType, DirectiveDefInternal, DirectiveType, PublicFeature, RenderFlags, defineComponent, defineDirective, renderComponent as _renderComponent, tick} from '../../src/render3/index';
|
||||
import {NG_HOST_SYMBOL, renderTemplate} from '../../src/render3/instructions';
|
||||
import {DirectiveDefList, DirectiveDefListOrFactory, DirectiveTypesOrFactory, PipeDefInternal, PipeDefList, PipeDefListOrFactory, PipeTypesOrFactory} from '../../src/render3/interfaces/definition';
|
||||
import {DirectiveDefList, DirectiveTypesOrFactory, PipeDefInternal, PipeDefList, PipeTypesOrFactory} from '../../src/render3/interfaces/definition';
|
||||
import {LElementNode} from '../../src/render3/interfaces/node';
|
||||
import {RElement, RText, Renderer3, RendererFactory3, domRendererFactory3} from '../../src/render3/interfaces/renderer';
|
||||
import {Sanitizer} from '../../src/sanitization/security';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵAPP_ROOT as APP_ROOT, ɵDepFlags as DepFlags, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵAPP_ROOT as APP_ROOT, ɵDepFlags as DepFlags, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||
|
||||
import {AsyncTestCompleter} from './async_test_completer';
|
||||
import {ComponentFixture} from './component_fixture';
|
||||
|
@ -54,8 +54,6 @@ export type TestModuleMetadata = {
|
|||
* creating components and services in unit tests.
|
||||
*
|
||||
* TestBed is the primary api for writing unit tests for Angular applications and libraries.
|
||||
*
|
||||
*
|
||||
*/
|
||||
export class TestBed implements Injector {
|
||||
/**
|
||||
|
@ -581,7 +579,7 @@ let _testBed: TestBed = null !;
|
|||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export function getTestBed() {
|
||||
export function getTestBed(): TestBed {
|
||||
return _testBed = _testBed || new TestBed();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export const MODULE_SUFFIX = '';
|
|||
const builtinExternalReferences = createBuiltinExternalReferencesMap();
|
||||
|
||||
export class JitReflector implements CompileReflector {
|
||||
private reflectionCapabilities: ReflectionCapabilities = new ReflectionCapabilities();
|
||||
private reflectionCapabilities = new ReflectionCapabilities();
|
||||
|
||||
componentModuleUrl(type: any, cmpMetadata: Component): string {
|
||||
const moduleId = cmpMetadata.moduleId;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
import {CompileReflector, DirectiveResolver, ERROR_COMPONENT_TYPE, NgModuleResolver, PipeResolver} from '@angular/compiler';
|
||||
import {MockDirectiveResolver, MockNgModuleResolver, MockPipeResolver} from '@angular/compiler/testing';
|
||||
import {Compiler, CompilerFactory, CompilerOptions, Component, ComponentFactory, Directive, Injectable, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, Pipe, PlatformRef, StaticProvider, Type, createPlatformFactory, ɵstringify} from '@angular/core';
|
||||
import {CompilerFactory, CompilerOptions, Component, ComponentFactory, Directive, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, Pipe, StaticProvider, Type, ɵstringify as stringify} from '@angular/core';
|
||||
import {MetadataOverride, ɵTestingCompiler as TestingCompiler, ɵTestingCompilerFactory as TestingCompilerFactory} from '@angular/core/testing';
|
||||
import {ɵCompilerImpl as CompilerImpl, ɵplatformCoreDynamic as platformCoreDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {ɵCompilerImpl as CompilerImpl} from '@angular/platform-browser-dynamic';
|
||||
|
||||
import {MetadataOverrider} from './metadata_overrider';
|
||||
|
||||
|
@ -63,7 +63,7 @@ export class TestingCompilerImpl implements TestingCompiler {
|
|||
|
||||
checkOverrideAllowed(type: Type<any>) {
|
||||
if (this._compiler.hasAotSummary(type)) {
|
||||
throw new Error(`${ɵstringify(type)} was AOT compiled, so its metadata cannot be changed.`);
|
||||
throw new Error(`${stringify(type)} was AOT compiled, so its metadata cannot be changed.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
|||
*/
|
||||
@Injectable()
|
||||
export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||
constructor(@Inject(DOCUMENT) private _doc: any /** TODO #9100 */) { super(); }
|
||||
constructor(@Inject(DOCUMENT) private _doc: any) { super(); }
|
||||
|
||||
insertRootElement(rootElId: string) {
|
||||
const rootEl = <HTMLElement>getDOM().firstChild(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgModule, PlatformRef, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||
import {NgModule, createPlatformFactory} from '@angular/core';
|
||||
import {TestComponentRenderer} from '@angular/core/testing';
|
||||
import {ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
||||
|
|
Loading…
Reference in New Issue