refactor: remove some facades (#12335)
This commit is contained in:

committed by
Alex Rickabaugh

parent
0ecd9b2df0
commit
76dd026447
@ -53,20 +53,20 @@ export class AngularProfiler {
|
||||
* ```
|
||||
*/
|
||||
timeChangeDetection(config: any): ChangeDetectionPerfRecord {
|
||||
var record = isPresent(config) && config['record'];
|
||||
var record = config && config['record'];
|
||||
var profileName = 'Change Detection';
|
||||
// Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
|
||||
var isProfilerAvailable = isPresent(window.console.profile);
|
||||
if (record && isProfilerAvailable) {
|
||||
window.console.profile(profileName);
|
||||
}
|
||||
var start = getDOM().performanceNow();
|
||||
const start = getDOM().performanceNow();
|
||||
var numTicks = 0;
|
||||
while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
|
||||
this.appRef.tick();
|
||||
numTicks++;
|
||||
}
|
||||
var end = getDOM().performanceNow();
|
||||
const end = getDOM().performanceNow();
|
||||
if (record && isProfilerAvailable) {
|
||||
// need to cast to <any> because type checker thinks there's no argument
|
||||
// while in fact there is:
|
||||
@ -74,9 +74,9 @@ export class AngularProfiler {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
|
||||
(<any>window.console.profileEnd)(profileName);
|
||||
}
|
||||
var msPerTick = (end - start) / numTicks;
|
||||
const msPerTick = (end - start) / numTicks;
|
||||
window.console.log(`ran ${numTicks} change detection cycles`);
|
||||
window.console.log(`${NumberWrapper.toFixed(msPerTick, 2)} ms per check`);
|
||||
window.console.log(`${msPerTick.toFixed(2)} ms per check`);
|
||||
|
||||
return new ChangeDetectionPerfRecord(msPerTick, numTicks);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Inject, Injectable, RenderComponentType, Renderer, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
import {Json, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
|
||||
import {isBlank, isPresent, stringify} from '../facade/lang';
|
||||
import {AnimationKeyframe, AnimationPlayer, AnimationStyles, RenderDebugInfo} from '../private_import_core';
|
||||
|
||||
import {AnimationDriver} from './animation_driver';
|
||||
@ -74,7 +74,7 @@ export class DomRenderer implements Renderer {
|
||||
|
||||
selectRootElement(selectorOrNode: string|any, debugInfo: RenderDebugInfo): Element {
|
||||
var el: any /** TODO #9100 */;
|
||||
if (isString(selectorOrNode)) {
|
||||
if (typeof selectorOrNode === 'string') {
|
||||
el = getDOM().querySelector(this._rootRenderer.document, selectorOrNode);
|
||||
if (isBlank(el)) {
|
||||
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
|
||||
@ -194,10 +194,11 @@ export class DomRenderer implements Renderer {
|
||||
if (getDOM().isCommentNode(renderElement)) {
|
||||
const existingBindings =
|
||||
getDOM().getText(renderElement).replace(/\n/g, '').match(TEMPLATE_BINDINGS_EXP);
|
||||
var parsedBindings = Json.parse(existingBindings[1]);
|
||||
var parsedBindings = JSON.parse(existingBindings[1]);
|
||||
(parsedBindings as any /** TODO #9100 */)[dashCasedPropertyName] = propertyValue;
|
||||
getDOM().setText(
|
||||
renderElement, TEMPLATE_COMMENT_TEXT.replace('{}', Json.stringify(parsedBindings)));
|
||||
renderElement,
|
||||
TEMPLATE_COMMENT_TEXT.replace('{}', JSON.stringify(parsedBindings, null, 2)));
|
||||
} else {
|
||||
this.setElementAttribute(renderElement, propertyName, propertyValue);
|
||||
}
|
||||
@ -279,9 +280,10 @@ function _shimHostAttribute(componentShortId: string): string {
|
||||
}
|
||||
|
||||
function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string[]): string[] {
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var style = styles[i];
|
||||
if (isArray(style)) {
|
||||
for (let i = 0; i < styles.length; i++) {
|
||||
let style = styles[i];
|
||||
|
||||
if (Array.isArray(style)) {
|
||||
_flattenStyles(compId, style, target);
|
||||
} else {
|
||||
style = style.replace(COMPONENT_REGEX, compId);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {AUTO_STYLE} from '@angular/core';
|
||||
|
||||
import {isNumber, isPresent} from '../facade/lang';
|
||||
import {isPresent} from '../facade/lang';
|
||||
import {AnimationKeyframe, AnimationStyles} from '../private_import_core';
|
||||
|
||||
import {AnimationDriver} from './animation_driver';
|
||||
@ -83,7 +83,7 @@ function _resolveStyleUnit(
|
||||
val: string | number, userProvidedProp: string, formattedProp: string): string {
|
||||
var unit = '';
|
||||
if (_isPixelDimensionStyle(formattedProp) && val != 0 && val != '0') {
|
||||
if (isNumber(val)) {
|
||||
if (typeof val === 'number') {
|
||||
unit = 'px';
|
||||
} else if (_findDimensionalSuffix(val.toString()).length == 0) {
|
||||
throw new Error('Please provide a CSS unit value for ' + userProvidedProp + ':' + val);
|
||||
|
Reference in New Issue
Block a user