refactor(facade): Remove most of StringMapWrapper facade. (#12022)
This change mostly automated by
12012b07a2
with some manual fixes.
This commit is contained in:

committed by
Chuck Jazdzewski

parent
adb17fed98
commit
1bd8ba80a7
@ -17,11 +17,12 @@ export function prepareFinalAnimationStyles(
|
||||
nullValue: string = null): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
|
||||
StringMapWrapper.forEach(newStyles, (value: string, prop: string) => {
|
||||
Object.keys(newStyles).forEach(prop => {
|
||||
const value = newStyles[prop];
|
||||
finalStyles[prop] = value == AUTO_STYLE ? nullValue : value.toString();
|
||||
});
|
||||
|
||||
StringMapWrapper.forEach(previousStyles, (value: string, prop: string) => {
|
||||
Object.keys(previousStyles).forEach(prop => {
|
||||
if (!isPresent(finalStyles[prop])) {
|
||||
finalStyles[prop] = nullValue;
|
||||
}
|
||||
@ -41,7 +42,8 @@ export function balanceAnimationKeyframes(
|
||||
|
||||
var extraFirstKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFirstStyles = false;
|
||||
StringMapWrapper.forEach(collectedStyles, (value: string, prop: string) => {
|
||||
Object.keys(collectedStyles).forEach(prop => {
|
||||
const value = collectedStyles[prop] as string;
|
||||
// if the style is already defined in the first keyframe then
|
||||
// we do not replace it.
|
||||
if (!flatenedFirstKeyframeStyles[prop]) {
|
||||
@ -60,7 +62,7 @@ export function balanceAnimationKeyframes(
|
||||
var flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
||||
var extraFinalKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFinalStyles = false;
|
||||
StringMapWrapper.forEach(keyframeCollectedStyles, (value: string, prop: string) => {
|
||||
Object.keys(keyframeCollectedStyles).forEach(prop => {
|
||||
if (!isPresent(flatenedFinalKeyframeStyles[prop])) {
|
||||
extraFinalKeyframeStyles[prop] = AUTO_STYLE;
|
||||
hasExtraFinalStyles = true;
|
||||
@ -71,7 +73,7 @@ export function balanceAnimationKeyframes(
|
||||
finalKeyframe.styles.styles.push(extraFinalKeyframeStyles);
|
||||
}
|
||||
|
||||
StringMapWrapper.forEach(flatenedFinalKeyframeStyles, (value: string, prop: string) => {
|
||||
Object.keys(flatenedFinalKeyframeStyles).forEach(prop => {
|
||||
if (!isPresent(flatenedFirstKeyframeStyles[prop])) {
|
||||
extraFirstKeyframeStyles[prop] = AUTO_STYLE;
|
||||
hasExtraFirstStyles = true;
|
||||
@ -87,7 +89,7 @@ export function balanceAnimationKeyframes(
|
||||
|
||||
export function clearStyles(styles: {[key: string]: string | number}): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
StringMapWrapper.keys(styles).forEach(key => { finalStyles[key] = null; });
|
||||
Object.keys(styles).forEach(key => { finalStyles[key] = null; });
|
||||
return finalStyles;
|
||||
}
|
||||
|
||||
@ -95,7 +97,8 @@ export function collectAndResolveStyles(
|
||||
collection: {[key: string]: string | number}, styles: {[key: string]: string | number}[]) {
|
||||
return styles.map(entry => {
|
||||
var stylesObj: {[key: string]: string | number} = {};
|
||||
StringMapWrapper.forEach(entry, (value: string | number, prop: string) => {
|
||||
Object.keys(entry).forEach(prop => {
|
||||
let value = entry[prop];
|
||||
if (value == FILL_STYLE_FLAG) {
|
||||
value = collection[prop];
|
||||
if (!isPresent(value)) {
|
||||
@ -111,15 +114,13 @@ export function collectAndResolveStyles(
|
||||
|
||||
export function renderStyles(
|
||||
element: any, renderer: any, styles: {[key: string]: string | number}): void {
|
||||
StringMapWrapper.forEach(
|
||||
styles, (value: string, prop: string) => { renderer.setElementStyle(element, prop, value); });
|
||||
Object.keys(styles).forEach(prop => { renderer.setElementStyle(element, prop, styles[prop]); });
|
||||
}
|
||||
|
||||
export function flattenStyles(styles: {[key: string]: string | number}[]): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
styles.forEach(entry => {
|
||||
StringMapWrapper.forEach(
|
||||
entry, (value: string, prop: string) => { finalStyles[prop] = value; });
|
||||
Object.keys(entry).forEach(prop => { finalStyles[prop] = entry[prop] as string; });
|
||||
});
|
||||
return finalStyles;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {StringMapWrapper} from '../facade/collection';
|
||||
|
||||
import {isPresent} from '../facade/lang';
|
||||
|
||||
import {AnimationPlayer} from './animation_player';
|
||||
@ -27,7 +27,7 @@ export class ViewAnimationMap {
|
||||
findAllPlayersByElement(element: any): AnimationPlayer[] {
|
||||
const el = this._map.get(element);
|
||||
|
||||
return el ? StringMapWrapper.values(el) : [];
|
||||
return el ? Object.keys(el).map(k => el[k]) : [];
|
||||
}
|
||||
|
||||
set(element: any, animationName: string, player: AnimationPlayer): void {
|
||||
@ -54,7 +54,7 @@ export class ViewAnimationMap {
|
||||
const index = this._allPlayers.indexOf(player);
|
||||
this._allPlayers.splice(index, 1);
|
||||
|
||||
if (StringMapWrapper.isEmpty(playersByAnimation)) {
|
||||
if (Object.keys(playersByAnimation).length === 0) {
|
||||
this._map.delete(element);
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
|
||||
if (obj instanceof Map) {
|
||||
obj.forEach(fn);
|
||||
} else {
|
||||
StringMapWrapper.forEach(obj, fn);
|
||||
Object.keys(obj).forEach(k => fn(obj[k], k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
import {Injector} from '../di';
|
||||
import {StringMapWrapper} from '../facade/collection';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {RenderDebugInfo} from '../render/api';
|
||||
|
||||
@ -68,7 +67,8 @@ export class DebugContext implements RenderDebugInfo {
|
||||
var staticNodeInfo = this._staticNodeInfo;
|
||||
if (isPresent(staticNodeInfo)) {
|
||||
var refs = staticNodeInfo.refTokens;
|
||||
StringMapWrapper.forEach(refs, (refToken: any, refName: string) => {
|
||||
Object.keys(refs).forEach(refName => {
|
||||
const refToken = refs[refName];
|
||||
let varValue: any;
|
||||
if (isBlank(refToken)) {
|
||||
varValue = this._view.allNodes ? this._view.allNodes[this._nodeIndex] : null;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {MapWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {MapWrapper} from '../facade/collection';
|
||||
import {isPresent} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
|
||||
@ -181,5 +181,5 @@ export class Reflector extends ReflectorReader {
|
||||
}
|
||||
|
||||
function _mergeMaps(target: Map<string, Function>, config: {[key: string]: Function}): void {
|
||||
StringMapWrapper.forEach(config, (v: Function, k: string) => target.set(k, v));
|
||||
Object.keys(config).forEach(k => { target.set(k, config[k]); });
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import {DomRootRenderer} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
|
||||
import {MockSchemaRegistry} from '../../../compiler/testing/index';
|
||||
import {EventEmitter} from '../../src/facade/async';
|
||||
import {StringMapWrapper} from '../../src/facade/collection';
|
||||
import {NumberWrapper} from '../../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
@ -1348,7 +1347,7 @@ class TestDirective implements OnInit, DoCheck, OnChanges, AfterContentInit, Aft
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
this.log.add(this.name, 'ngOnChanges');
|
||||
const r: {[k: string]: string} = {};
|
||||
StringMapWrapper.forEach(changes, (c: SimpleChange, key: string) => r[key] = c.currentValue);
|
||||
Object.keys(changes).forEach(key => { r[key] = changes[key].currentValue; });
|
||||
this.changes = r;
|
||||
if (this.throwOn == 'ngOnChanges') {
|
||||
throw new Error('Boom!');
|
||||
|
@ -224,9 +224,7 @@ export class SpyObject {
|
||||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
StringMapWrapper.forEach(m, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => {
|
||||
object.spy(key).andReturn(value);
|
||||
});
|
||||
Object.keys(m).forEach(key => { object.spy(key).andReturn(m[key]); });
|
||||
return object;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user