From 4fe0b909485647cd8eceb502db9df7dcfda88030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Wed, 1 Mar 2017 10:54:24 -0800 Subject: [PATCH] refactor: remove facade/browser (#14837) --- modules/@angular/facade/src/browser.ts | 25 ------------------- .../src/browser/tools/common_tools.ts | 14 +++++------ 2 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 modules/@angular/facade/src/browser.ts diff --git a/modules/@angular/facade/src/browser.ts b/modules/@angular/facade/src/browser.ts deleted file mode 100644 index c7fd16ee43..0000000000 --- a/modules/@angular/facade/src/browser.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * 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 - */ - -/** - * JS version of browser APIs. This library can only run in the browser. - */ -const win = typeof window !== 'undefined' && window || {}; - -export {win as window}; -export const document = win.document; -export const location = win.location; -export const gc = win['gc'] ? () => win['gc']() : (): any => null; -export const performance = win['performance'] ? win['performance'] : null; -export const Event = win['Event']; -export const MouseEvent = win['MouseEvent']; -export const KeyboardEvent = win['KeyboardEvent']; -export const EventTarget = win['EventTarget']; -export const History = win['History']; -export const Location = win['Location']; -export const EventListener = win['EventListener']; diff --git a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts index d35147adcf..1d184bb9a0 100644 --- a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts +++ b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts @@ -9,9 +9,9 @@ import {ApplicationRef, ComponentRef} from '@angular/core'; import {getDOM} from '../../dom/dom_adapter'; -import {window} from '../../facade/browser'; -import {NumberWrapper, isPresent} from '../../facade/lang'; +import {isPresent} from '../../facade/lang'; +const win = typeof window !== 'undefined' && window || {}; export class ChangeDetectionPerfRecord { constructor(public msPerTick: number, public numTicks: number) {} @@ -47,9 +47,9 @@ export class AngularProfiler { const record = config && config['record']; const profileName = 'Change Detection'; // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened - const isProfilerAvailable = isPresent(window.console.profile); + const isProfilerAvailable = isPresent(win.console.profile); if (record && isProfilerAvailable) { - window.console.profile(profileName); + win.console.profile(profileName); } const start = getDOM().performanceNow(); let numTicks = 0; @@ -63,11 +63,11 @@ export class AngularProfiler { // while in fact there is: // // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd - (window.console.profileEnd)(profileName); + (win.console.profileEnd)(profileName); } const msPerTick = (end - start) / numTicks; - window.console.log(`ran ${numTicks} change detection cycles`); - window.console.log(`${msPerTick.toFixed(2)} ms per check`); + win.console.log(`ran ${numTicks} change detection cycles`); + win.console.log(`${msPerTick.toFixed(2)} ms per check`); return new ChangeDetectionPerfRecord(msPerTick, numTicks); }