From bfea2634d16a950acb3e6c4929135e90dffa1e60 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 16 Aug 2017 00:03:29 +0200 Subject: [PATCH] chore: remove change detection toggle from demo app (#6444) Removes the toggle that changes the change detection in the demo app. It's not needed anymore since all components use OnPush. --- src/demo-app/demo-app/demo-app.html | 13 ++--------- src/demo-app/demo-app/demo-app.ts | 33 +--------------------------- src/demo-app/demo-app/demo-module.ts | 3 +-- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/src/demo-app/demo-app/demo-app.html b/src/demo-app/demo-app/demo-app.html index ec6d69db5d3..7138842d1a4 100644 --- a/src/demo-app/demo-app/demo-app.html +++ b/src/demo-app/demo-app/demo-app.html @@ -30,9 +30,6 @@

Angular Material Demos

- @@ -44,14 +41,8 @@
-
-
- -
- - - - +
+
diff --git a/src/demo-app/demo-app/demo-app.ts b/src/demo-app/demo-app/demo-app.ts index d87a27830ea..2938c6fe540 100644 --- a/src/demo-app/demo-app/demo-app.ts +++ b/src/demo-app/demo-app/demo-app.ts @@ -2,13 +2,10 @@ import { Component, ViewEncapsulation, ElementRef, - ChangeDetectionStrategy, Renderer2, } from '@angular/core'; import {OverlayContainer} from '@angular/material'; -const changeDetectionKey = 'mdDemoChangeDetection'; - /** * The entry app for demo site. Routes under `accessibility` will use AccessibilityDemo component, * while other demos will use `DemoApp` component. Since DemoApp and AccessibilityDemo use @@ -35,15 +32,6 @@ export class EntryApp {} }) export class Home {} -@Component({ - moduleId: module.id, - selector: 'demo-app-on-push', - template: '', - changeDetection: ChangeDetectionStrategy.OnPush, - encapsulation: ViewEncapsulation.None, -}) -export class DemoAppOnPush {} - /** * DemoApp with toolbar and sidenav. */ @@ -56,7 +44,6 @@ export class DemoAppOnPush {} }) export class DemoApp { dark = false; - changeDetectionStrategy: string; navItems = [ {name: 'Autocomplete', route: '/autocomplete'}, {name: 'Button', route: '/button'}, @@ -97,14 +84,7 @@ export class DemoApp { constructor( private _element: ElementRef, private _renderer: Renderer2, - private _overlayContainer: OverlayContainer) { - // Some browsers will throw when trying to access localStorage in incognito. - try { - this.changeDetectionStrategy = window.localStorage.getItem(changeDetectionKey) || 'Default'; - } catch (error) { - console.error(error); - } - } + private _overlayContainer: OverlayContainer) {} toggleFullscreen() { let elem = this._element.nativeElement.querySelector('.demo-content'); @@ -119,17 +99,6 @@ export class DemoApp { } } - toggleChangeDetection() { - try { - this.changeDetectionStrategy = this.changeDetectionStrategy === 'Default' ? - 'OnPush' : 'Default'; - window.localStorage.setItem(changeDetectionKey, this.changeDetectionStrategy); - window.location.reload(); - } catch (error) { - console.error(error); - } - } - toggleTheme() { const darkThemeClass = 'unicorn-dark-theme'; diff --git a/src/demo-app/demo-app/demo-module.ts b/src/demo-app/demo-app/demo-module.ts index 10ff909d15a..7b5165b3fa3 100644 --- a/src/demo-app/demo-app/demo-module.ts +++ b/src/demo-app/demo-app/demo-module.ts @@ -2,7 +2,7 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; -import {DemoApp, DemoAppOnPush, Home} from './demo-app'; +import {DemoApp, Home} from './demo-app'; import {DEMO_APP_ROUTES} from './routes'; import {ProgressBarDemo} from '../progress-bar/progress-bar-demo'; import {ContentElementDialog, DialogDemo, IFrameDialog, JazzDialog} from '../dialog/dialog-demo'; @@ -65,7 +65,6 @@ import {TableHeaderDemo} from '../table/table-header-demo'; CheckboxDemo, DatepickerDemo, DemoApp, - DemoAppOnPush, DialogDemo, GesturesDemo, GridListDemo,