@angular/core
Advanced tools
Comparing version 2.2.0-beta.1 to 2.2.0-rc.0
/** | ||
* @license Angular v2.2.0-beta.1 | ||
* @license Angular v0.0.0-PLACEHOLDER | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
@@ -1042,2 +1042,2 @@ * License: MIT | ||
})); | ||
})); |
{ | ||
"name": "@angular/core", | ||
"version": "2.2.0-beta.1", | ||
"version": "2.2.0-rc.0", | ||
"description": "Angular - the core framework", | ||
@@ -5,0 +5,0 @@ "main": "bundles/core.umd.js", |
@@ -118,3 +118,3 @@ /** | ||
}); | ||
ComponentRef_.prototype.destroy = function () { this._hostElement.parentView.destroy(); }; | ||
ComponentRef_.prototype.destroy = function () { this._hostElement.parentView.detachAndDestroy(); }; | ||
ComponentRef_.prototype.onDestroy = function (callback) { this.hostView.onDestroy(callback); }; | ||
@@ -153,3 +153,10 @@ return ComponentRef_; | ||
var hostView = this._viewFactory(vu, injector, null); | ||
var hostElement = hostView.create(EMPTY_CONTEXT, projectableNodes, rootSelectorOrNode); | ||
hostView.visitProjectableNodesInternal = | ||
function (nodeIndex, ngContentIndex, cb, ctx) { | ||
var nodes = projectableNodes[ngContentIndex] || []; | ||
for (var i = 0; i < nodes.length; i++) { | ||
cb(nodes[i], ctx); | ||
} | ||
}; | ||
var hostElement = hostView.create(EMPTY_CONTEXT, rootSelectorOrNode); | ||
return new ComponentRef_(hostElement, this._componentType); | ||
@@ -156,0 +163,0 @@ }; |
@@ -10,3 +10,2 @@ /** | ||
import { ElementRef } from './element_ref'; | ||
import { QueryList } from './query_list'; | ||
import { AppView } from './view'; | ||
@@ -27,9 +26,11 @@ import { ViewContainerRef_ } from './view_container_ref'; | ||
component: any; | ||
componentConstructorViewQueries: QueryList<any>[]; | ||
constructor(index: number, parentIndex: number, parentView: AppView<any>, nativeElement: any); | ||
elementRef: ElementRef; | ||
vcRef: ViewContainerRef_; | ||
initComponent(component: any, componentConstructorViewQueries: QueryList<any>[], view: AppView<any>): void; | ||
initComponent(component: any, view: AppView<any>): void; | ||
parentInjector: Injector; | ||
injector: Injector; | ||
detectChangesInNestedViews(throwOnChange: boolean): void; | ||
destroyNestedViews(): void; | ||
visitNestedViewRootNodes<C>(cb: (node: any, ctx: C) => void, c: C): void; | ||
mapNestedViews(nestedViewClass: any, callback: Function): any[]; | ||
@@ -36,0 +37,0 @@ moveView(view: AppView<any>, currentIndex: number): void; |
@@ -23,4 +23,2 @@ /** | ||
this.nativeElement = nativeElement; | ||
this.nestedViews = null; | ||
this.componentView = null; | ||
} | ||
@@ -37,5 +35,4 @@ Object.defineProperty(AppElement.prototype, "elementRef", { | ||
}); | ||
AppElement.prototype.initComponent = function (component, componentConstructorViewQueries, view) { | ||
AppElement.prototype.initComponent = function (component, view) { | ||
this.component = component; | ||
this.componentConstructorViewQueries = componentConstructorViewQueries; | ||
this.componentView = view; | ||
@@ -53,2 +50,23 @@ }; | ||
}); | ||
AppElement.prototype.detectChangesInNestedViews = function (throwOnChange) { | ||
if (this.nestedViews) { | ||
for (var i = 0; i < this.nestedViews.length; i++) { | ||
this.nestedViews[i].detectChanges(throwOnChange); | ||
} | ||
} | ||
}; | ||
AppElement.prototype.destroyNestedViews = function () { | ||
if (this.nestedViews) { | ||
for (var i = 0; i < this.nestedViews.length; i++) { | ||
this.nestedViews[i].destroy(); | ||
} | ||
} | ||
}; | ||
AppElement.prototype.visitNestedViewRootNodes = function (cb, c) { | ||
if (this.nestedViews) { | ||
for (var i = 0; i < this.nestedViews.length; i++) { | ||
this.nestedViews[i].visitRootNodesInternal(cb, c); | ||
} | ||
} | ||
}; | ||
AppElement.prototype.mapNestedViews = function (nestedViewClass, callback) { | ||
@@ -55,0 +73,0 @@ var result = []; |
@@ -52,2 +52,7 @@ /** | ||
* See | ||
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) | ||
*/ | ||
find(fn: (item: T, index: number, array: T[]) => boolean): T; | ||
/** | ||
* See | ||
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) | ||
@@ -54,0 +59,0 @@ */ |
@@ -74,2 +74,7 @@ /** | ||
* See | ||
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) | ||
*/ | ||
QueryList.prototype.find = function (fn) { return this._results.find(fn); }; | ||
/** | ||
* See | ||
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) | ||
@@ -76,0 +81,0 @@ */ |
@@ -57,3 +57,3 @@ /** | ||
var view = this._viewFactory(this._appElement.parentView.viewUtils, this._appElement.parentInjector, this._appElement); | ||
view.create(context || {}, null, null); | ||
view.create(context || {}, null); | ||
return view.ref; | ||
@@ -60,0 +60,0 @@ }; |
@@ -138,6 +138,11 @@ /** | ||
}; | ||
ViewRef_.prototype.onDestroy = function (callback) { this._view.disposables.push(callback); }; | ||
ViewRef_.prototype.destroy = function () { this._view.destroy(); }; | ||
ViewRef_.prototype.onDestroy = function (callback) { | ||
if (!this._view.disposables) { | ||
this._view.disposables = []; | ||
} | ||
this._view.disposables.push(callback); | ||
}; | ||
ViewRef_.prototype.destroy = function () { this._view.detachAndDestroy(); }; | ||
return ViewRef_; | ||
}()); | ||
//# sourceMappingURL=view_ref.js.map |
@@ -5,2 +5,3 @@ import { SimpleChange } from '../change_detection/change_detection'; | ||
import { Sanitizer } from '../security'; | ||
import { AppView } from './view'; | ||
export declare class ViewUtils { | ||
@@ -19,4 +20,3 @@ private _renderer; | ||
} | ||
export declare function flattenNestedViewRenderNodes(nodes: any[]): any[]; | ||
export declare function ensureSlotCount(projectableNodes: any[][], expectedSlotCount: number): any[][]; | ||
export declare function addToArray(e: any, array: any[]): void; | ||
export declare const MAX_INTERPOLATION_VALUES: number; | ||
@@ -44,5 +44,8 @@ export declare function interpolate(valueCount: number, c0: string, a1: any, c1: string, a2?: any, c2?: string, a3?: any, c3?: string, a4?: any, c4?: string, a5?: any, c5?: string, a6?: any, c6?: string, a7?: any, c7?: string, a8?: any, c8?: string, a9?: any, c9?: string): string; | ||
export declare function selectOrCreateRenderHostElement(renderer: Renderer, elementName: string, attrs: InlineArray<string>, rootSelectorOrNode: string | any, debugInfo?: RenderDebugInfo): any; | ||
export declare function subscribeToRenderElement(view: AppView<any>, element: any, eventNamesAndTargets: InlineArray<string>, listener: (eventName: string, event: any) => any): any; | ||
export declare function noop(): void; | ||
export interface InlineArray<T> { | ||
length: number; | ||
get(index: number): T; | ||
set(index: number, value: T): void; | ||
} | ||
@@ -55,2 +58,3 @@ export declare class InlineArray2<T> implements InlineArray<T> { | ||
get(index: number): T; | ||
set(index: number, value: T): void; | ||
} | ||
@@ -65,2 +69,3 @@ export declare class InlineArray4<T> implements InlineArray<T> { | ||
get(index: number): T; | ||
set(index: number, value: T): void; | ||
} | ||
@@ -79,2 +84,3 @@ export declare class InlineArray8<T> implements InlineArray<T> { | ||
get(index: number): T; | ||
set(index: number, value: T): void; | ||
} | ||
@@ -101,2 +107,3 @@ export declare class InlineArray16<T> implements InlineArray<T> { | ||
get(index: number): T; | ||
set(index: number, value: T): void; | ||
} | ||
@@ -108,3 +115,4 @@ export declare class InlineArrayDynamic<T> implements InlineArray<T> { | ||
get(index: number): any; | ||
set(index: number, value: T): void; | ||
} | ||
export declare const EMPTY_INLINE_ARRAY: InlineArray<any>; |
@@ -15,3 +15,2 @@ /** | ||
import { Sanitizer } from '../security'; | ||
import { AppElement } from './element'; | ||
import { ExpressionChangedAfterItHasBeenCheckedError } from './errors'; | ||
@@ -47,41 +46,5 @@ export var ViewUtils = (function () { | ||
}()); | ||
export function flattenNestedViewRenderNodes(nodes) { | ||
return _flattenNestedViewRenderNodes(nodes, []); | ||
export function addToArray(e, array) { | ||
array.push(e); | ||
} | ||
function _flattenNestedViewRenderNodes(nodes, renderNodes) { | ||
for (var i = 0; i < nodes.length; i++) { | ||
var node = nodes[i]; | ||
if (node instanceof AppElement) { | ||
var appEl = node; | ||
renderNodes.push(appEl.nativeElement); | ||
if (isPresent(appEl.nestedViews)) { | ||
for (var k = 0; k < appEl.nestedViews.length; k++) { | ||
_flattenNestedViewRenderNodes(appEl.nestedViews[k].rootNodesOrAppElements, renderNodes); | ||
} | ||
} | ||
} | ||
else { | ||
renderNodes.push(node); | ||
} | ||
} | ||
return renderNodes; | ||
} | ||
var EMPTY_ARR = []; | ||
export function ensureSlotCount(projectableNodes, expectedSlotCount) { | ||
var res; | ||
if (!projectableNodes) { | ||
res = EMPTY_ARR; | ||
} | ||
else if (projectableNodes.length < expectedSlotCount) { | ||
var givenSlotCount = projectableNodes.length; | ||
res = new Array(expectedSlotCount); | ||
for (var i = 0; i < expectedSlotCount; i++) { | ||
res[i] = (i < givenSlotCount) ? projectableNodes[i] : EMPTY_ARR; | ||
} | ||
} | ||
else { | ||
res = projectableNodes; | ||
} | ||
return res; | ||
} | ||
export var MAX_INTERPOLATION_VALUES = 9; | ||
@@ -358,2 +321,43 @@ export function interpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) { | ||
} | ||
export function subscribeToRenderElement(view, element, eventNamesAndTargets, listener) { | ||
var disposables = createEmptyInlineArray(eventNamesAndTargets.length / 2); | ||
for (var i = 0; i < eventNamesAndTargets.length; i += 2) { | ||
var eventName = eventNamesAndTargets.get(i); | ||
var eventTarget = eventNamesAndTargets.get(i + 1); | ||
var disposable = void 0; | ||
if (eventTarget) { | ||
disposable = view.renderer.listenGlobal(eventTarget, eventName, listener.bind(view, eventTarget + ":" + eventName)); | ||
} | ||
else { | ||
disposable = view.renderer.listen(element, eventName, listener.bind(view, eventName)); | ||
} | ||
disposables.set(i / 2, disposable); | ||
} | ||
return disposeInlineArray.bind(null, disposables); | ||
} | ||
function disposeInlineArray(disposables) { | ||
for (var i = 0; i < disposables.length; i++) { | ||
disposables.get(i)(); | ||
} | ||
} | ||
export function noop() { } | ||
function createEmptyInlineArray(length) { | ||
var ctor; | ||
if (length <= 2) { | ||
ctor = InlineArray2; | ||
} | ||
else if (length <= 4) { | ||
ctor = InlineArray4; | ||
} | ||
else if (length <= 8) { | ||
ctor = InlineArray8; | ||
} | ||
else if (length <= 16) { | ||
ctor = InlineArray16; | ||
} | ||
else { | ||
ctor = InlineArrayDynamic; | ||
} | ||
return new ctor(length); | ||
} | ||
var InlineArray0 = (function () { | ||
@@ -364,2 +368,3 @@ function InlineArray0() { | ||
InlineArray0.prototype.get = function (index) { return undefined; }; | ||
InlineArray0.prototype.set = function (index, value) { }; | ||
return InlineArray0; | ||
@@ -383,2 +388,12 @@ }()); | ||
}; | ||
InlineArray2.prototype.set = function (index, value) { | ||
switch (index) { | ||
case 0: | ||
this._v0 = value; | ||
break; | ||
case 1: | ||
this._v1 = value; | ||
break; | ||
} | ||
}; | ||
return InlineArray2; | ||
@@ -408,2 +423,18 @@ }()); | ||
}; | ||
InlineArray4.prototype.set = function (index, value) { | ||
switch (index) { | ||
case 0: | ||
this._v0 = value; | ||
break; | ||
case 1: | ||
this._v1 = value; | ||
break; | ||
case 2: | ||
this._v2 = value; | ||
break; | ||
case 3: | ||
this._v3 = value; | ||
break; | ||
} | ||
}; | ||
return InlineArray4; | ||
@@ -445,2 +476,30 @@ }()); | ||
}; | ||
InlineArray8.prototype.set = function (index, value) { | ||
switch (index) { | ||
case 0: | ||
this._v0 = value; | ||
break; | ||
case 1: | ||
this._v1 = value; | ||
break; | ||
case 2: | ||
this._v2 = value; | ||
break; | ||
case 3: | ||
this._v3 = value; | ||
break; | ||
case 4: | ||
this._v4 = value; | ||
break; | ||
case 5: | ||
this._v5 = value; | ||
break; | ||
case 6: | ||
this._v6 = value; | ||
break; | ||
case 7: | ||
this._v7 = value; | ||
break; | ||
} | ||
}; | ||
return InlineArray8; | ||
@@ -506,2 +565,54 @@ }()); | ||
}; | ||
InlineArray16.prototype.set = function (index, value) { | ||
switch (index) { | ||
case 0: | ||
this._v0 = value; | ||
break; | ||
case 1: | ||
this._v1 = value; | ||
break; | ||
case 2: | ||
this._v2 = value; | ||
break; | ||
case 3: | ||
this._v3 = value; | ||
break; | ||
case 4: | ||
this._v4 = value; | ||
break; | ||
case 5: | ||
this._v5 = value; | ||
break; | ||
case 6: | ||
this._v6 = value; | ||
break; | ||
case 7: | ||
this._v7 = value; | ||
break; | ||
case 8: | ||
this._v8 = value; | ||
break; | ||
case 9: | ||
this._v9 = value; | ||
break; | ||
case 10: | ||
this._v10 = value; | ||
break; | ||
case 11: | ||
this._v11 = value; | ||
break; | ||
case 12: | ||
this._v12 = value; | ||
break; | ||
case 13: | ||
this._v13 = value; | ||
break; | ||
case 14: | ||
this._v14 = value; | ||
break; | ||
case 15: | ||
this._v15 = value; | ||
break; | ||
} | ||
}; | ||
return InlineArray16; | ||
@@ -521,2 +632,3 @@ }()); | ||
InlineArrayDynamic.prototype.get = function (index) { return this._values[index]; }; | ||
InlineArrayDynamic.prototype.set = function (index, value) { this._values[index] = value; }; | ||
return InlineArrayDynamic; | ||
@@ -523,0 +635,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"ViewUtils":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../di","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../di","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"../application_tokens","name":"APP_ID"}]}],null],"parameters":[{"__symbolic":"reference","module":"../render/api","name":"RootRenderer"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../security","name":"Sanitizer"}]}],"createRenderComponentType":[{"__symbolic":"method"}],"renderComponent":[{"__symbolic":"method"}]}},"flattenNestedViewRenderNodes":{"__symbolic":"function","parameters":["nodes"],"value":{"__symbolic":"error","message":"Reference to a non-exported function","line":53,"character":9,"context":{"name":"_flattenNestedViewRenderNodes"}}},"MAX_INTERPOLATION_VALUES":9,"castByValue":{"__symbolic":"function","parameters":["input","value"],"value":{"__symbolic":"reference","name":"input"}},"EMPTY_ARRAY":[],"EMPTY_MAP":{},"EMPTY_INLINE_ARRAY":{"__symbolic":"error","message":"Reference to non-exported class","line":407,"character":0,"context":{"className":"InlineArray0"}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"ViewUtils":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../di","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../di","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"../application_tokens","name":"APP_ID"}]}],null],"parameters":[{"__symbolic":"reference","module":"../render/api","name":"RootRenderer"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../security","name":"Sanitizer"}]}],"createRenderComponentType":[{"__symbolic":"method"}],"renderComponent":[{"__symbolic":"method"}]}},"MAX_INTERPOLATION_VALUES":9,"castByValue":{"__symbolic":"function","parameters":["input","value"],"value":{"__symbolic":"reference","name":"input"}},"EMPTY_ARRAY":[],"EMPTY_MAP":{},"EMPTY_INLINE_ARRAY":{"__symbolic":"error","message":"Reference to non-exported class","line":416,"character":0,"context":{"className":"InlineArray0"}}}} |
@@ -30,11 +30,7 @@ /** | ||
ref: ViewRef_<T>; | ||
rootNodesOrAppElements: any[]; | ||
lastRootNode: any; | ||
allNodes: any[]; | ||
disposables: Function[]; | ||
subscriptions: any[]; | ||
contentChildren: AppView<any>[]; | ||
viewChildren: AppView<any>[]; | ||
viewContainerElement: AppElement; | ||
numberOfChecks: number; | ||
projectableNodes: Array<any | any[]>; | ||
renderer: Renderer; | ||
@@ -47,3 +43,3 @@ private _hasExternalHostElement; | ||
destroyed: boolean; | ||
create(context: T, givenProjectableNodes: Array<any | any[]>, rootSelectorOrNode: string | any): AppElement; | ||
create(context: T, rootSelectorOrNode: string | any): AppElement; | ||
/** | ||
@@ -54,3 +50,3 @@ * Overwritten by implementations. | ||
createInternal(rootSelectorOrNode: string | any): AppElement; | ||
init(rootNodesOrAppElements: any[], allNodes: any[], disposables: Function[], subscriptions: any[]): void; | ||
init(lastRootNode: any, allNodes: any[], disposables: Function[]): void; | ||
injectorGet(token: any, nodeIndex: number, notFoundResult: any): any; | ||
@@ -62,5 +58,4 @@ /** | ||
injector(nodeIndex: number): Injector; | ||
detachAndDestroy(): void; | ||
destroy(): void; | ||
private _destroyRecurse(); | ||
destroyLocal(): void; | ||
/** | ||
@@ -78,6 +73,15 @@ * Overwritten by implementations | ||
flatRootNodes: any[]; | ||
lastRootNode: any; | ||
projectedNodes(ngContentIndex: number): any[]; | ||
visitProjectedNodes<C>(ngContentIndex: number, cb: (node: any, ctx: C) => void, c: C): void; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
visitRootNodesInternal<C>(cb: (node: any, ctx: C) => void, c: C): void; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
visitProjectableNodesInternal<C>(nodeIndex: number, ngContentIndex: number, cb: (node: any, ctx: C) => void, c: C): void; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
dirtyParentQueriesInternal(): void; | ||
@@ -89,4 +93,2 @@ detectChanges(throwOnChange: boolean): void; | ||
detectChangesInternal(throwOnChange: boolean): void; | ||
detectContentChildrenChanges(throwOnChange: boolean): void; | ||
detectViewChildrenChanges(throwOnChange: boolean): void; | ||
markContentChildAsMoved(renderAppElement: AppElement): void; | ||
@@ -97,3 +99,3 @@ addToContentChildren(renderAppElement: AppElement): void; | ||
markPathToRootAsCheckOnce(): void; | ||
eventHandler<E, R>(cb: (event?: E) => R): (event?: E) => R; | ||
eventHandler<E, R>(cb: (eventName: string, event?: E) => R): (eventName: string, event?: E) => R; | ||
throwDestroyedError(details: string): void; | ||
@@ -105,6 +107,6 @@ } | ||
constructor(clazz: any, componentType: RenderComponentType, type: ViewType, viewUtils: ViewUtils, parentInjector: Injector, declarationAppElement: AppElement, cdMode: ChangeDetectorStatus, staticNodeDebugInfos: StaticNodeDebugInfo[]); | ||
create(context: T, givenProjectableNodes: Array<any | any[]>, rootSelectorOrNode: string | any): AppElement; | ||
create(context: T, rootSelectorOrNode: string | any): AppElement; | ||
injectorGet(token: any, nodeIndex: number, notFoundResult: any): any; | ||
detach(): void; | ||
destroyLocal(): void; | ||
destroy(): void; | ||
detectChanges(throwOnChange: boolean): void; | ||
@@ -114,3 +116,3 @@ private _resetDebug(); | ||
private _rethrowWithContext(e); | ||
eventHandler<E, R>(cb: (event?: E) => R): (event?: E) => R; | ||
eventHandler<E, R>(cb: (eventName: string, event?: E) => R): (eventName: string, event?: E) => R; | ||
} |
@@ -14,3 +14,2 @@ /** | ||
import { ChangeDetectorStatus } from '../change_detection/change_detection'; | ||
import { ListWrapper } from '../facade/collection'; | ||
import { isPresent } from '../facade/lang'; | ||
@@ -20,3 +19,2 @@ import { wtfCreateScope, wtfLeave } from '../profile/profile'; | ||
import { DebugContext } from './debug_context'; | ||
import { AppElement } from './element'; | ||
import { ElementInjector } from './element_injector'; | ||
@@ -26,3 +24,3 @@ import { ExpressionChangedAfterItHasBeenCheckedError, ViewDestroyedError, ViewWrappedError } from './errors'; | ||
import { ViewType } from './view_type'; | ||
import { ensureSlotCount, flattenNestedViewRenderNodes } from './view_utils'; | ||
import { addToArray } from './view_utils'; | ||
var _scope_check = wtfCreateScope("AppView#check(ascii id)"); | ||
@@ -42,4 +40,2 @@ /** | ||
this.cdMode = cdMode; | ||
this.contentChildren = []; | ||
this.viewChildren = []; | ||
this.viewContainerElement = null; | ||
@@ -70,20 +66,5 @@ this.numberOfChecks = 0; | ||
}); | ||
AppView.prototype.create = function (context, givenProjectableNodes, rootSelectorOrNode) { | ||
AppView.prototype.create = function (context, rootSelectorOrNode) { | ||
this.context = context; | ||
var projectableNodes; | ||
switch (this.type) { | ||
case ViewType.COMPONENT: | ||
projectableNodes = ensureSlotCount(givenProjectableNodes, this.componentType.slotCount); | ||
break; | ||
case ViewType.EMBEDDED: | ||
projectableNodes = this.declarationAppElement.parentView.projectableNodes; | ||
break; | ||
case ViewType.HOST: | ||
// Note: Don't ensure the slot count for the projectableNodes as we store | ||
// them only for the contained component view (which will later check the slot count...) | ||
projectableNodes = givenProjectableNodes; | ||
break; | ||
} | ||
this._hasExternalHostElement = isPresent(rootSelectorOrNode); | ||
this.projectableNodes = projectableNodes; | ||
return this.createInternal(rootSelectorOrNode); | ||
@@ -96,11 +77,7 @@ }; | ||
AppView.prototype.createInternal = function (rootSelectorOrNode) { return null; }; | ||
AppView.prototype.init = function (rootNodesOrAppElements, allNodes, disposables, subscriptions) { | ||
this.rootNodesOrAppElements = rootNodesOrAppElements; | ||
AppView.prototype.init = function (lastRootNode, allNodes, disposables) { | ||
this.lastRootNode = lastRootNode; | ||
this.allNodes = allNodes; | ||
this.disposables = disposables; | ||
this.subscriptions = subscriptions; | ||
if (this.type === ViewType.COMPONENT) { | ||
// Note: the render nodes have been attached to their host element | ||
// in the ViewFactory already. | ||
this.declarationAppElement.parentView.viewChildren.push(this); | ||
this.dirtyParentQueriesInternal(); | ||
@@ -126,3 +103,3 @@ } | ||
}; | ||
AppView.prototype.destroy = function () { | ||
AppView.prototype.detachAndDestroy = function () { | ||
if (this._hasExternalHostElement) { | ||
@@ -134,28 +111,15 @@ this.renderer.detachView(this.flatRootNodes); | ||
} | ||
this._destroyRecurse(); | ||
this.destroy(); | ||
}; | ||
AppView.prototype._destroyRecurse = function () { | ||
AppView.prototype.destroy = function () { | ||
var _this = this; | ||
if (this.cdMode === ChangeDetectorStatus.Destroyed) { | ||
return; | ||
} | ||
var children = this.contentChildren; | ||
for (var i = 0; i < children.length; i++) { | ||
children[i]._destroyRecurse(); | ||
} | ||
children = this.viewChildren; | ||
for (var i = 0; i < children.length; i++) { | ||
children[i]._destroyRecurse(); | ||
} | ||
this.destroyLocal(); | ||
this.cdMode = ChangeDetectorStatus.Destroyed; | ||
}; | ||
AppView.prototype.destroyLocal = function () { | ||
var _this = this; | ||
var hostElement = this.type === ViewType.COMPONENT ? this.declarationAppElement.nativeElement : null; | ||
for (var i = 0; i < this.disposables.length; i++) { | ||
this.disposables[i](); | ||
if (this.disposables) { | ||
for (var i = 0; i < this.disposables.length; i++) { | ||
this.disposables[i](); | ||
} | ||
} | ||
for (var i = 0; i < this.subscriptions.length; i++) { | ||
this.subscriptions[i].unsubscribe(); | ||
} | ||
this.destroyInternal(); | ||
@@ -169,2 +133,3 @@ this.dirtyParentQueriesInternal(); | ||
} | ||
this.cdMode = ChangeDetectorStatus.Destroyed; | ||
}; | ||
@@ -202,12 +167,6 @@ /** | ||
Object.defineProperty(AppView.prototype, "flatRootNodes", { | ||
get: function () { return flattenNestedViewRenderNodes(this.rootNodesOrAppElements); }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(AppView.prototype, "lastRootNode", { | ||
get: function () { | ||
var lastNode = this.rootNodesOrAppElements.length > 0 ? | ||
this.rootNodesOrAppElements[this.rootNodesOrAppElements.length - 1] : | ||
null; | ||
return _findLastRenderNode(lastNode); | ||
var nodes = []; | ||
this.visitRootNodesInternal(addToArray, nodes); | ||
return nodes; | ||
}, | ||
@@ -217,5 +176,29 @@ enumerable: true, | ||
}); | ||
AppView.prototype.projectedNodes = function (ngContentIndex) { | ||
var nodes = []; | ||
this.visitProjectedNodes(ngContentIndex, addToArray, nodes); | ||
return nodes; | ||
}; | ||
AppView.prototype.visitProjectedNodes = function (ngContentIndex, cb, c) { | ||
var appEl = this.declarationAppElement; | ||
switch (this.type) { | ||
case ViewType.EMBEDDED: | ||
appEl.parentView.visitProjectedNodes(ngContentIndex, cb, c); | ||
break; | ||
case ViewType.COMPONENT: | ||
appEl.parentView.visitProjectableNodesInternal(appEl.index, ngContentIndex, cb, c); | ||
break; | ||
} | ||
}; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
AppView.prototype.visitRootNodesInternal = function (cb, c) { }; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
AppView.prototype.visitProjectableNodesInternal = function (nodeIndex, ngContentIndex, cb, c) { }; | ||
/** | ||
* Overwritten by implementations | ||
*/ | ||
AppView.prototype.dirtyParentQueriesInternal = function () { }; | ||
@@ -225,3 +208,4 @@ AppView.prototype.detectChanges = function (throwOnChange) { | ||
if (this.cdMode === ChangeDetectorStatus.Checked || | ||
this.cdMode === ChangeDetectorStatus.Errored) | ||
this.cdMode === ChangeDetectorStatus.Errored || | ||
this.cdMode === ChangeDetectorStatus.Detached) | ||
return; | ||
@@ -240,25 +224,5 @@ if (this.cdMode === ChangeDetectorStatus.Destroyed) { | ||
*/ | ||
AppView.prototype.detectChangesInternal = function (throwOnChange) { | ||
this.detectContentChildrenChanges(throwOnChange); | ||
this.detectViewChildrenChanges(throwOnChange); | ||
}; | ||
AppView.prototype.detectContentChildrenChanges = function (throwOnChange) { | ||
for (var i = 0; i < this.contentChildren.length; ++i) { | ||
var child = this.contentChildren[i]; | ||
if (child.cdMode === ChangeDetectorStatus.Detached) | ||
continue; | ||
child.detectChanges(throwOnChange); | ||
} | ||
}; | ||
AppView.prototype.detectViewChildrenChanges = function (throwOnChange) { | ||
for (var i = 0; i < this.viewChildren.length; ++i) { | ||
var child = this.viewChildren[i]; | ||
if (child.cdMode === ChangeDetectorStatus.Detached) | ||
continue; | ||
child.detectChanges(throwOnChange); | ||
} | ||
}; | ||
AppView.prototype.detectChangesInternal = function (throwOnChange) { }; | ||
AppView.prototype.markContentChildAsMoved = function (renderAppElement) { this.dirtyParentQueriesInternal(); }; | ||
AppView.prototype.addToContentChildren = function (renderAppElement) { | ||
renderAppElement.parentView.contentChildren.push(this); | ||
this.viewContainerElement = renderAppElement; | ||
@@ -268,3 +232,2 @@ this.dirtyParentQueriesInternal(); | ||
AppView.prototype.removeFromContentChildren = function (renderAppElement) { | ||
ListWrapper.remove(renderAppElement.parentView.contentChildren, this); | ||
this.dirtyParentQueriesInternal(); | ||
@@ -284,3 +247,5 @@ this.viewContainerElement = null; | ||
}; | ||
AppView.prototype.eventHandler = function (cb) { return cb; }; | ||
AppView.prototype.eventHandler = function (cb) { | ||
return cb; | ||
}; | ||
AppView.prototype.throwDestroyedError = function (details) { throw new ViewDestroyedError(details); }; | ||
@@ -296,6 +261,6 @@ return AppView; | ||
} | ||
DebugAppView.prototype.create = function (context, givenProjectableNodes, rootSelectorOrNode) { | ||
DebugAppView.prototype.create = function (context, rootSelectorOrNode) { | ||
this._resetDebug(); | ||
try { | ||
return _super.prototype.create.call(this, context, givenProjectableNodes, rootSelectorOrNode); | ||
return _super.prototype.create.call(this, context, rootSelectorOrNode); | ||
} | ||
@@ -327,6 +292,6 @@ catch (e) { | ||
}; | ||
DebugAppView.prototype.destroyLocal = function () { | ||
DebugAppView.prototype.destroy = function () { | ||
this._resetDebug(); | ||
try { | ||
_super.prototype.destroyLocal.call(this); | ||
_super.prototype.destroy.call(this); | ||
} | ||
@@ -365,6 +330,6 @@ catch (e) { | ||
var superHandler = _super.prototype.eventHandler.call(this, cb); | ||
return function (event) { | ||
return function (eventName, event) { | ||
_this._resetDebug(); | ||
try { | ||
return superHandler(event); | ||
return superHandler.call(_this, eventName, event); | ||
} | ||
@@ -379,22 +344,2 @@ catch (e) { | ||
}(AppView)); | ||
function _findLastRenderNode(node) { | ||
var lastNode; | ||
if (node instanceof AppElement) { | ||
var appEl = node; | ||
lastNode = appEl.nativeElement; | ||
if (isPresent(appEl.nestedViews)) { | ||
// Note: Views might have no root nodes at all! | ||
for (var i = appEl.nestedViews.length - 1; i >= 0; i--) { | ||
var nestedView = appEl.nestedViews[i]; | ||
if (nestedView.rootNodesOrAppElements.length > 0) { | ||
lastNode = _findLastRenderNode(nestedView.rootNodesOrAppElements[nestedView.rootNodesOrAppElements.length - 1]); | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
lastNode = node; | ||
} | ||
return lastNode; | ||
} | ||
//# sourceMappingURL=view.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2087874
30347