refactor(facade): Inline isBlank called with object-type argument (#11992)
This commit is contained in:

committed by
Chuck Jazdzewski

parent
a4af1561b7
commit
b39d3a173e
@ -722,7 +722,7 @@ class _DuplicateMap {
|
||||
var key = getMapKey(trackById);
|
||||
|
||||
var recordList = this.map.get(key);
|
||||
return isBlank(recordList) ? null : recordList.get(trackById, afterIndex);
|
||||
return recordList ? recordList.get(trackById, afterIndex) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {Optional, Provider, SkipSelf} from '../../di';
|
||||
import {ListWrapper} from '../../facade/collection';
|
||||
import {getTypeNameForDebugging, isBlank, isPresent} from '../../facade/lang';
|
||||
import {getTypeNameForDebugging, isPresent} from '../../facade/lang';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ export class IterableDiffers {
|
||||
return {
|
||||
provide: IterableDiffers,
|
||||
useFactory: (parent: IterableDiffers) => {
|
||||
if (isBlank(parent)) {
|
||||
if (!parent) {
|
||||
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed
|
||||
// to
|
||||
// bootstrap(), which would override default pipes instead of extending them.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {Optional, Provider, SkipSelf} from '../../di';
|
||||
import {ListWrapper} from '../../facade/collection';
|
||||
import {isBlank, isPresent} from '../../facade/lang';
|
||||
import {isPresent} from '../../facade/lang';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ export class KeyValueDiffers {
|
||||
return {
|
||||
provide: KeyValueDiffers,
|
||||
useFactory: (parent: KeyValueDiffers) => {
|
||||
if (isBlank(parent)) {
|
||||
if (!parent) {
|
||||
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
|
||||
// to
|
||||
// bootstrap(), which would override default pipes instead of extending them.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {BaseError, WrappedError} from '../facade/errors';
|
||||
import {isBlank, stringify} from '../facade/lang';
|
||||
import {stringify} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {ReflectiveInjector} from './reflective_injector';
|
||||
@ -229,7 +229,7 @@ export class NoAnnotationError extends BaseError {
|
||||
var signature: string[] = [];
|
||||
for (var i = 0, ii = params.length; i < ii; i++) {
|
||||
var parameter = params[i];
|
||||
if (isBlank(parameter) || parameter.length == 0) {
|
||||
if (!parameter || parameter.length == 0) {
|
||||
signature.push('?');
|
||||
} else {
|
||||
signature.push(parameter.map(stringify).join(' '));
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isBlank, stringify} from '../facade/lang';
|
||||
import {stringify} from '../facade/lang';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
|
||||
@ -32,7 +32,7 @@ export class ReflectiveKey {
|
||||
* Private
|
||||
*/
|
||||
constructor(public token: Object, public id: number) {
|
||||
if (isBlank(token)) {
|
||||
if (!token) {
|
||||
throw new Error('Token must be defined!');
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ function _normalizeProviders(providers: Provider[], res: Provider[]): Provider[]
|
||||
|
||||
export function constructDependencies(
|
||||
typeOrFunc: any, dependencies: any[]): ReflectiveDependency[] {
|
||||
if (isBlank(dependencies)) {
|
||||
if (!dependencies) {
|
||||
return _dependenciesFor(typeOrFunc);
|
||||
} else {
|
||||
var params: any[][] = dependencies.map(t => [t]);
|
||||
@ -211,7 +211,7 @@ export function constructDependencies(
|
||||
|
||||
function _dependenciesFor(typeOrFunc: any): ReflectiveDependency[] {
|
||||
var params = reflector.parameters(typeOrFunc);
|
||||
if (isBlank(params)) return [];
|
||||
if (!params) return [];
|
||||
if (params.some(isBlank)) {
|
||||
throw new NoAnnotationError(typeOrFunc, params);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
import {ChangeDetectorRef} from '../change_detection/change_detection';
|
||||
import {Injector} from '../di/injector';
|
||||
import {unimplemented} from '../facade/errors';
|
||||
import {isBlank} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
import {AppElement} from './element';
|
||||
import {ElementRef} from './element_ref';
|
||||
@ -101,7 +100,7 @@ export class ComponentFactory<C> {
|
||||
injector: Injector, projectableNodes: any[][] = null,
|
||||
rootSelectorOrNode: string|any = null): ComponentRef<C> {
|
||||
var vu: ViewUtils = injector.get(ViewUtils);
|
||||
if (isBlank(projectableNodes)) {
|
||||
if (!projectableNodes) {
|
||||
projectableNodes = [];
|
||||
}
|
||||
// Note: Host views don't need a declarationAppElement!
|
||||
|
@ -10,7 +10,7 @@ import {APP_ID} from '../application_tokens';
|
||||
import {devModeEqual} from '../change_detection/change_detection';
|
||||
import {UNINITIALIZED} from '../change_detection/change_detection_util';
|
||||
import {Inject, Injectable} from '../di';
|
||||
import {isBlank, isPresent, looseIdentical} from '../facade/lang';
|
||||
import {isPresent, looseIdentical} from '../facade/lang';
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {RenderComponentType, Renderer, RootRenderer} from '../render/api';
|
||||
import {Sanitizer} from '../security';
|
||||
@ -72,7 +72,7 @@ const EMPTY_ARR: any[] = [];
|
||||
|
||||
export function ensureSlotCount(projectableNodes: any[][], expectedSlotCount: number): any[][] {
|
||||
var res: any[][];
|
||||
if (isBlank(projectableNodes)) {
|
||||
if (!projectableNodes) {
|
||||
res = EMPTY_ARR;
|
||||
} else if (projectableNodes.length < expectedSlotCount) {
|
||||
var givenSlotCount = projectableNodes.length;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isBlank} from '../../src/facade/lang';
|
||||
|
||||
|
||||
export function iterableChangesAsString(
|
||||
{collection = [] as any, previous = [] as any, additions = [] as any, moves = [] as any,
|
||||
@ -23,11 +23,11 @@ export function kvChangesAsString(
|
||||
{map, previous, additions, changes, removals}:
|
||||
{map?: any[], previous?: any[], additions?: any[], changes?: any[], removals?: any[]}):
|
||||
string {
|
||||
if (isBlank(map)) map = [];
|
||||
if (isBlank(previous)) previous = [];
|
||||
if (isBlank(additions)) additions = [];
|
||||
if (isBlank(changes)) changes = [];
|
||||
if (isBlank(removals)) removals = [];
|
||||
if (!map) map = [];
|
||||
if (!previous) previous = [];
|
||||
if (!additions) additions = [];
|
||||
if (!changes) changes = [];
|
||||
if (!removals) removals = [];
|
||||
|
||||
return 'map: ' + map.join(', ') + '\n' +
|
||||
'previous: ' + previous.join(', ') + '\n' +
|
||||
|
@ -11,7 +11,7 @@ import {ReflectiveInjectorDynamicStrategy, ReflectiveInjectorInlineStrategy, Ref
|
||||
import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {isBlank, isPresent, stringify} from '../../src/facade/lang';
|
||||
import {isPresent, stringify} from '../../src/facade/lang';
|
||||
|
||||
class Engine {}
|
||||
|
||||
@ -458,7 +458,7 @@ export function main() {
|
||||
it('should resolve and flatten', () => {
|
||||
var providers = ReflectiveInjector.resolve([Engine, [BrokenEngine]]);
|
||||
providers.forEach(function(b) {
|
||||
if (isBlank(b)) return; // the result is a sparse array
|
||||
if (!b) return; // the result is a sparse array
|
||||
expect(b instanceof ResolvedReflectiveProvider_).toBe(true);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user