chore: add ChangeDetectionStrategy.OnPush strategy

Close #5885
This commit is contained in:
Adam Bradley
2016-04-10 00:28:50 -05:00
parent 2348b51be7
commit 4e8ecae83c
12 changed files with 41 additions and 27 deletions

View File

@ -1,4 +1,4 @@
import {Component, Renderer, ElementRef, HostListener} from 'angular2/core'; import {Component, Renderer, ElementRef, HostListener, ChangeDetectionStrategy} from 'angular2/core';
import {NgFor, NgIf} from 'angular2/common'; import {NgFor, NgIf} from 'angular2/common';
import {Animation} from '../../animations/animation'; import {Animation} from '../../animations/animation';
@ -186,7 +186,8 @@ export class ActionSheet extends ViewController {
'[attr.aria-labelledby]': 'hdrId', '[attr.aria-labelledby]': 'hdrId',
'[attr.aria-describedby]': 'descId' '[attr.aria-describedby]': 'descId'
}, },
directives: [NgFor, NgIf, Icon] directives: [NgFor, NgIf, Icon],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
class ActionSheetCmp { class ActionSheetCmp {
private d: any; private d: any;

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Renderer, HostListener} from 'angular2/core'; import {Component, ElementRef, Renderer, HostListener, ChangeDetectionStrategy} from 'angular2/core';
import {NgClass, NgSwitch, NgIf, NgFor} from 'angular2/common'; import {NgClass, NgSwitch, NgIf, NgFor} from 'angular2/common';
import {Animation} from '../../animations/animation'; import {Animation} from '../../animations/animation';
@ -308,7 +308,8 @@ export class Alert extends ViewController {
'[attr.aria-labelledby]': 'hdrId', '[attr.aria-labelledby]': 'hdrId',
'[attr.aria-describedby]': 'descId' '[attr.aria-describedby]': 'descId'
}, },
directives: [NgClass, NgSwitch, NgIf, NgFor] directives: [NgClass, NgSwitch, NgIf, NgFor],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
class AlertCmp { class AlertCmp {
private activeId: string; private activeId: string;

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Renderer, Attribute, Optional, Input} from 'angular2/core'; import {Component, ElementRef, Renderer, Attribute, Optional, Input, ChangeDetectionStrategy} from 'angular2/core';
import {Config} from '../../config/config'; import {Config} from '../../config/config';
import {Toolbar} from '../toolbar/toolbar'; import {Toolbar} from '../toolbar/toolbar';
@ -38,7 +38,8 @@ import {isTrueProperty} from '../../util/util';
'<span class="button-inner">' + '<span class="button-inner">' +
'<ng-content></ng-content>' + '<ng-content></ng-content>' +
'</span>' + '</span>' +
'<ion-button-effect></ion-button-effect>' '<ion-button-effect></ion-button-effect>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Button { export class Button {
private _role: string = 'button'; // bar-button/item-button private _role: string = 'button'; // bar-button/item-button

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Optional, NgZone} from 'angular2/core'; import {Component, ElementRef, Optional, NgZone, ChangeDetectionStrategy} from 'angular2/core';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {IonicApp} from '../app/app'; import {IonicApp} from '../app/app';
@ -32,7 +32,8 @@ import {ScrollView} from '../../util/scroll-view';
'<ng-content></ng-content>' + '<ng-content></ng-content>' +
'</scroll-content>' + '</scroll-content>' +
'<ng-content select="ion-fixed"></ng-content>' + '<ng-content select="ion-fixed"></ng-content>' +
'<ng-content select="ion-refresher"></ng-content>' '<ng-content select="ion-refresher"></ng-content>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Content extends Ion { export class Content extends Ion {
private _padding: number = 0; private _padding: number = 0;

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Optional} from 'angular2/core'; import {Component, ElementRef, Optional, ChangeDetectionStrategy} from 'angular2/core';
import {List} from '../list/list'; import {List} from '../list/list';
@ -23,7 +23,7 @@ import {List} from '../list/list';
* </ion-item-sliding> * </ion-item-sliding>
* </ion-list> * </ion-list>
* ``` * ```
* @demo /docs/v2/demos/item-sliding/ * @demo /docs/v2/demos/item-sliding/
* @see {@link /docs/v2/components#lists List Component Docs} * @see {@link /docs/v2/components#lists List Component Docs}
* @see {@link ../../list/List List API Docs} * @see {@link ../../list/List List API Docs}
*/ */
@ -31,7 +31,8 @@ import {List} from '../list/list';
selector: 'ion-item-sliding', selector: 'ion-item-sliding',
template: template:
'<ng-content select="ion-item,[ion-item]"></ng-content>' + '<ng-content select="ion-item,[ion-item]"></ng-content>' +
'<ng-content select="ion-item-options"></ng-content>' '<ng-content select="ion-item-options"></ng-content>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class ItemSliding { export class ItemSliding {

View File

@ -1,4 +1,4 @@
import {Component, ContentChildren, forwardRef, ViewChild, ContentChild, Renderer, ElementRef} from 'angular2/core'; import {Component, ContentChildren, forwardRef, ViewChild, ContentChild, Renderer, ElementRef, ChangeDetectionStrategy} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {Button} from '../button/button'; import {Button} from '../button/button';
@ -57,7 +57,8 @@ import {Label} from '../label/label';
host: { host: {
'class': 'item' 'class': 'item'
}, },
directives: [NgIf, Label] directives: [NgIf, Label],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Item { export class Item {
private _ids: number = -1; private _ids: number = -1;

View File

@ -1,4 +1,4 @@
import {Component, Renderer, ElementRef, HostListener} from 'angular2/core'; import {Component, Renderer, ElementRef, HostListener, ChangeDetectionStrategy} from 'angular2/core';
import {NgFor, NgIf} from 'angular2/common'; import {NgFor, NgIf} from 'angular2/common';
import {Animation} from '../../animations/animation'; import {Animation} from '../../animations/animation';
@ -157,7 +157,8 @@ export class Loading extends ViewController {
host: { host: {
'role': 'dialog' 'role': 'dialog'
}, },
directives: [NgIf, Spinner] directives: [NgIf, Spinner],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
class LoadingCmp { class LoadingCmp {
private d: any; private d: any;

View File

@ -1,4 +1,4 @@
import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef, NgZone, Input, Output, Renderer} from 'angular2/core'; import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef, NgZone, Input, Output, Renderer, ChangeDetectionStrategy} from 'angular2/core';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {Config} from '../../config/config'; import {Config} from '../../config/config';
@ -21,7 +21,8 @@ import {isTrueProperty} from '../../util/util';
template: template:
'<ng-content></ng-content>' + '<ng-content></ng-content>' +
'<div tappable disable-activated class="backdrop"></div>', '<div tappable disable-activated class="backdrop"></div>',
directives: [forwardRef(() => MenuBackdrop)] directives: [forwardRef(() => MenuBackdrop)],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Menu extends Ion { export class Menu extends Ion {
private _preventTime: number = 0; private _preventTime: number = 0;

View File

@ -1,4 +1,4 @@
import {Component, ElementRef} from 'angular2/core'; import {Component, ElementRef, ChangeDetectionStrategy} from 'angular2/core';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {Gesture} from '../../gestures/gesture'; import {Gesture} from '../../gestures/gesture';
@ -42,7 +42,8 @@ import * as util from '../../util';
'<div class="scroll-zoom-wrapper">' + '<div class="scroll-zoom-wrapper">' +
'<ng-content></ng-content>' + '<ng-content></ng-content>' +
'</div>' + '</div>' +
'</scroll-content>' '</scroll-content>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Scroll extends Ion { export class Scroll extends Ion {
/** /**

View File

@ -1,4 +1,4 @@
import {Directive, Component, ElementRef, Host, EventEmitter, Input, Output} from 'angular2/core'; import {Directive, Component, ElementRef, Host, EventEmitter, Input, Output, ChangeDetectionStrategy} from 'angular2/core';
import {NgClass} from 'angular2/common'; import {NgClass} from 'angular2/common';
import {Ion} from '../ion'; import {Ion} from '../ion';
@ -71,7 +71,8 @@ import {Scroll} from '../scroll/scroll';
'</div>' + '</div>' +
'<div [class.hide]="!showPager" class="swiper-pagination"></div>' + '<div [class.hide]="!showPager" class="swiper-pagination"></div>' +
'</div>', '</div>',
directives: [NgClass] directives: [NgClass],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Slides extends Ion { export class Slides extends Ion {
@ -666,7 +667,8 @@ export class Slides extends Ion {
*/ */
@Component({ @Component({
selector: 'ion-slide', selector: 'ion-slide',
template: '<div class="slide-zoom"><ng-content></ng-content></div>' template: '<div class="slide-zoom"><ng-content></ng-content></div>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Slide { export class Slide {

View File

@ -1,4 +1,4 @@
import {Component, Input} from 'angular2/core'; import {Component, Input, ChangeDetectionStrategy} from 'angular2/core';
import {NgStyle} from 'angular2/common'; import {NgStyle} from 'angular2/common';
import {Config} from '../../config/config'; import {Config} from '../../config/config';
@ -110,7 +110,8 @@ import {Config} from '../../config/config';
host: { host: {
'[class]': '_applied', '[class]': '_applied',
'[class.spinner-paused]': 'paused' '[class.spinner-paused]': 'paused'
} },
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Spinner { export class Spinner {
private _c: any[]; private _c: any[];

View File

@ -1,4 +1,4 @@
import {Component, Directive, Host, ElementRef, Optional, forwardRef, Inject, ContentChildren, ContentChild, QueryList} from 'angular2/core'; import {Component, Directive, Host, ElementRef, Optional, forwardRef, Inject, ContentChildren, ContentChild, QueryList, ChangeDetectionStrategy} from 'angular2/core';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {MenuToggle} from '../menu/menu-toggle'; import {MenuToggle} from '../menu/menu-toggle';
@ -109,7 +109,8 @@ export class ToolbarBase extends Ion {
'</div>', '</div>',
host: { host: {
'class': 'toolbar' 'class': 'toolbar'
} },
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Toolbar extends ToolbarBase { export class Toolbar extends ToolbarBase {
@ -144,7 +145,8 @@ export class Toolbar extends ToolbarBase {
template: template:
'<div class="toolbar-title">' + '<div class="toolbar-title">' +
'<ng-content></ng-content>' + '<ng-content></ng-content>' +
'</div>' '</div>',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class ToolbarTitle extends Ion { export class ToolbarTitle extends Ion {
constructor( constructor(