refactor: remove facade/browser (#14837)

This commit is contained in:
Miško Hevery 2017-03-01 10:54:24 -08:00 committed by Chuck Jazdzewski
parent 928c5657c8
commit 4fe0b90948
2 changed files with 7 additions and 32 deletions

View File

@ -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 || <any>{};
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'];

View File

@ -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 || <any>{};
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
(<any>window.console.profileEnd)(profileName);
(<any>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);
}