diff --git a/modules/benchmarks/src/tree/ng2_ftl/ftl_util.ts b/modules/benchmarks/src/tree/ng2_ftl/ftl_util.ts index 5b495a50a0..8a128daf0a 100644 --- a/modules/benchmarks/src/tree/ng2_ftl/ftl_util.ts +++ b/modules/benchmarks/src/tree/ng2_ftl/ftl_util.ts @@ -7,6 +7,9 @@ */ import {ComponentFactory, ComponentRef, ElementRef, Injector, TemplateRef, ViewContainerRef, ViewRef} from '@angular/core'; +import {devModeEqual, looseIdentical} from '@angular/core/src/change_detection/change_detection_util'; +import {ExpressionChangedAfterItHasBeenCheckedError} from '@angular/core/src/linker/errors'; + export function unimplemented(): any { throw new Error('unimplemented'); @@ -205,3 +208,14 @@ export function createAnchorAndAppend(parent: any) { parent.appendChild(txt); return txt; } + +export function checkBinding(throwOnChange: boolean, oldValue: any, newValue: any): boolean { + if (throwOnChange) { + if (!devModeEqual(oldValue, newValue)) { + throw new ExpressionChangedAfterItHasBeenCheckedError(oldValue, newValue, false); + } + return false; + } else { + return !looseIdentical(oldValue, newValue); + } +} \ No newline at end of file diff --git a/modules/benchmarks/src/tree/ng2_ftl/ng_if.ngfactory.ts b/modules/benchmarks/src/tree/ng2_ftl/ng_if.ngfactory.ts index b3ff2b141f..eda72134de 100644 --- a/modules/benchmarks/src/tree/ng2_ftl/ng_if.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_ftl/ng_if.ngfactory.ts @@ -2,17 +2,17 @@ import {NgIf} from '@angular/common'; import {TemplateRef, ViewContainerRef} from '@angular/core'; import * as import7 from '@angular/core/src/change_detection/change_detection'; import * as import4 from '@angular/core/src/linker/view_utils'; +import {checkBinding} from './ftl_util'; export class NgIfWrapper { directive: NgIf; _expr_0: any; constructor(viewContainerRef: ViewContainerRef, templateRef: TemplateRef) { this.directive = new NgIf(viewContainerRef, templateRef); - this._expr_0 = import7.UNINITIALIZED; } updateNgIf(throwOnChange: boolean, currVal: any) { - if (import4.checkBinding(throwOnChange, this._expr_0, currVal)) { + if (checkBinding(throwOnChange, this._expr_0, currVal)) { this.directive.ngIf = currVal; this._expr_0 = currVal; } diff --git a/modules/benchmarks/src/tree/ng2_ftl/tree.ngfactory.ts b/modules/benchmarks/src/tree/ng2_ftl/tree.ngfactory.ts index 12b1a31e6f..d8d097e3d2 100644 --- a/modules/benchmarks/src/tree/ng2_ftl/tree.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_ftl/tree.ngfactory.ts @@ -18,7 +18,7 @@ import * as import8 from '@angular/core/src/metadata/view'; import * as import0 from '@angular/core/src/render/api'; import * as import12 from '@angular/core/src/security'; -import {FtlEmbeddedView, FtlTemplateRef, FtlView, FtlViewContainerRef, createAnchorAndAppend, createElementAndAppend, createTextAndAppend} from './ftl_util'; +import {FtlEmbeddedView, FtlTemplateRef, FtlView, FtlViewContainerRef, checkBinding, createAnchorAndAppend, createElementAndAppend, createTextAndAppend} from './ftl_util'; import {NgIfWrapper} from './ng_if.ngfactory'; import * as import3 from './tree'; @@ -50,9 +50,8 @@ export class _View_TreeComponent0 implements FtlView { this._TemplateRef_3_5 = new FtlTemplateRef(3, this); this._vc_3 = new FtlViewContainerRef(this._anchor_3); this._NgIf_3_6 = new NgIfWrapper(this._vc_3, this._TemplateRef_3_5); - this._expr_0 = import7.UNINITIALIZED; - this._expr_1 = import7.UNINITIALIZED; - this._expr_2 = import7.UNINITIALIZED; + this._expr_0 = undefined; + this._expr_1 = undefined; } detectChangesInternal(throwOnChange: boolean): void { this._NgIf_2_6.updateNgIf(throwOnChange, (this.context.data.right != (null as any))); @@ -60,12 +59,12 @@ export class _View_TreeComponent0 implements FtlView { this._vc_2.detectChangesInternal(throwOnChange); this._vc_3.detectChangesInternal(throwOnChange); const currVal_0: any = ((this.context.data.depth % 2) ? '' : 'grey'); - if (import4.checkBinding(throwOnChange, this._expr_0, currVal_0)) { + if (checkBinding(throwOnChange, this._expr_0, currVal_0)) { this._el_0.style.backgroundColor = currVal_0; this._expr_0 = currVal_0; } const currVal_1: any = import4.inlineInterpolate(1, ' ', this.context.data.value, ' '); - if (import4.checkBinding(throwOnChange, this._expr_1, currVal_1)) { + if (checkBinding(throwOnChange, this._expr_1, currVal_1)) { this._text_1.nodeValue = currVal_1; this._expr_1 = currVal_1; } @@ -75,7 +74,7 @@ export class _View_TreeComponent0 implements FtlView { this._vc_3.destroyInternal(); } updateData(throwOnChange: boolean, currVal: any) { - if (import4.checkBinding(throwOnChange, this._expr_2, currVal)) { + if (checkBinding(throwOnChange, this._expr_2, currVal)) { this.context.data = currVal; this._expr_2 = currVal; } diff --git a/modules/benchmarks/src/tree/ng2_static_ftl/ftl_util.ts b/modules/benchmarks/src/tree/ng2_static_ftl/ftl_util.ts index 8a7cc1d0f4..53b7a0ca2b 100644 --- a/modules/benchmarks/src/tree/ng2_static_ftl/ftl_util.ts +++ b/modules/benchmarks/src/tree/ng2_static_ftl/ftl_util.ts @@ -5,6 +5,8 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ +import {devModeEqual, looseIdentical} from '@angular/core/src/change_detection/change_detection_util'; +import {ExpressionChangedAfterItHasBeenCheckedError} from '@angular/core/src/linker/errors'; export function createElementAndAppend(parent: any, name: string) { const el = document.createElement(name); @@ -23,3 +25,14 @@ export function createAnchorAndAppend(parent: any) { parent.appendChild(txt); return txt; } + +export function checkBinding(throwOnChange: boolean, oldValue: any, newValue: any): boolean { + if (throwOnChange) { + if (!devModeEqual(oldValue, newValue)) { + throw new ExpressionChangedAfterItHasBeenCheckedError(oldValue, newValue, false); + } + return false; + } else { + return !looseIdentical(oldValue, newValue); + } +} \ No newline at end of file diff --git a/modules/benchmarks/src/tree/ng2_static_ftl/tree_branch.ngfactory.ts b/modules/benchmarks/src/tree/ng2_static_ftl/tree_branch.ngfactory.ts index c04d9b70f4..f6588c2090 100644 --- a/modules/benchmarks/src/tree/ng2_static_ftl/tree_branch.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_static_ftl/tree_branch.ngfactory.ts @@ -16,7 +16,7 @@ import * as import8 from '@angular/core/src/metadata/view'; import * as import0 from '@angular/core/src/render/api'; import * as import12 from '@angular/core/src/security'; -import {createAnchorAndAppend, createElementAndAppend, createTextAndAppend} from './ftl_util'; +import {checkBinding, createAnchorAndAppend, createElementAndAppend, createTextAndAppend} from './ftl_util'; import * as import3 from './tree'; import * as import11 from './tree_leaf.ngfactory'; @@ -42,16 +42,15 @@ export class View_TreeTreeComponent { this._el_3 = createElementAndAppend(parentRenderNode, 'tree'); this._TreeComponent20_3_4View = depth > 0 ? new View_TreeTreeComponent(depth - 1, this._el_3) : new import11.View_TreeLeafComponent(this._el_3); - this._expr_0 = import7.UNINITIALIZED; - this._expr_1 = import7.UNINITIALIZED; - this._expr_2 = import7.UNINITIALIZED; + this._expr_1 = undefined; + this._expr_2 = undefined; } destroyInternal() { this._TreeComponent20_2_4View.destroyInternal(); this._TreeComponent20_3_4View.destroyInternal(); } updateData(currVal_2: any) { - if (import4.checkBinding(false, this._expr_2, currVal_2)) { + if (checkBinding(false, this._expr_2, currVal_2)) { this.context.data = currVal_2; this._expr_2 = currVal_2; } @@ -61,12 +60,12 @@ export class View_TreeTreeComponent { this._TreeComponent20_3_4View.updateData(this.context.data.left); const currVal_0: any = ((this.context.data.depth % 2) ? '' : 'grey'); - if (import4.checkBinding(throwOnChange, this._expr_0, currVal_0)) { + if (checkBinding(throwOnChange, this._expr_0, currVal_0)) { this._el_0.style.backgroundColor = currVal_0; this._expr_0 = currVal_0; } const currVal_1: any = import4.inlineInterpolate(1, ' ', this.context.data.value, ' '); - if (import4.checkBinding(throwOnChange, this._expr_1, currVal_1)) { + if (checkBinding(throwOnChange, this._expr_1, currVal_1)) { this._text_1.nodeValue = currVal_1; this._expr_1 = currVal_1; } diff --git a/modules/benchmarks/src/tree/ng2_static_ftl/tree_leaf.ngfactory.ts b/modules/benchmarks/src/tree/ng2_static_ftl/tree_leaf.ngfactory.ts index 812e935828..ca4838546b 100644 --- a/modules/benchmarks/src/tree/ng2_static_ftl/tree_leaf.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_static_ftl/tree_leaf.ngfactory.ts @@ -16,6 +16,7 @@ import * as import8 from '@angular/core/src/metadata/view'; import * as import0 from '@angular/core/src/render/api'; import * as import10 from '@angular/core/src/security'; +import {checkBinding} from './ftl_util'; import * as import3 from './tree'; export class View_TreeLeafComponent { @@ -31,11 +32,9 @@ export class View_TreeLeafComponent { parentRenderNode.appendChild(this._el_0); this._text_1 = document.createTextNode(''); this._el_0.appendChild(this._text_1); - this._expr_0 = import7.UNINITIALIZED; - this._expr_1 = import7.UNINITIALIZED; } updateData(currVal_2: any) { - if (import4.checkBinding(false, this._expr_2, currVal_2)) { + if (checkBinding(false, this._expr_2, currVal_2)) { this.context.data = currVal_2; this._expr_2 = currVal_2; } @@ -43,12 +42,12 @@ export class View_TreeLeafComponent { destroyInternal() {} detectChangesInternal(throwOnChange: boolean): void { const currVal_0: any = ((this.context.data.depth % 2) ? '' : 'grey'); - if (import4.checkBinding(throwOnChange, this._expr_0, currVal_0)) { + if (checkBinding(throwOnChange, this._expr_0, currVal_0)) { this._el_0.style.backgroundColor = currVal_0; this._expr_0 = currVal_0; } const currVal_1: any = import4.inlineInterpolate(1, ' ', this.context.data.value, ' '); - if (import4.checkBinding(throwOnChange, this._expr_1, currVal_1)) { + if (checkBinding(throwOnChange, this._expr_1, currVal_1)) { this._text_1.nodeValue = currVal_1; this._expr_1 = currVal_1; } diff --git a/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts b/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts index 2f30f4a92b..e1833ddef7 100644 --- a/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts +++ b/modules/benchmarks/src/tree/ng2_static_ftl/tree_root.ngfactory.ts @@ -18,6 +18,7 @@ import * as import0 from '@angular/core/src/render/api'; import {maxDepth} from '../util'; +import {checkBinding} from './ftl_util'; import * as import3 from './tree'; import * as import12 from './tree'; import * as import13 from './tree_branch.ngfactory'; @@ -86,7 +87,6 @@ class _View_TreeRootComponent0 extends import1.AppView