refactor(facade): Remove most of StringMapWrapper facade. (#12022)

This change mostly automated by
12012b07a2
with some manual fixes.
This commit is contained in:
Alex Eagle 2016-10-03 16:46:05 -07:00 committed by Chuck Jazdzewski
parent ed9c2b6281
commit b64b5ece65
36 changed files with 140 additions and 205 deletions

View File

@ -7,7 +7,6 @@
*/ */
import {Injector, OpaqueToken} from '@angular/core'; import {Injector, OpaqueToken} from '@angular/core';
import {StringMapWrapper} from '../facade/collection';
import {Metric} from '../metric'; import {Metric} from '../metric';
@ -57,8 +56,7 @@ export class MultiMetric extends Metric {
function mergeStringMaps(maps: {[key: string]: string}[]): {[key: string]: string} { function mergeStringMaps(maps: {[key: string]: string}[]): {[key: string]: string} {
var result: {[key: string]: string} = {}; var result: {[key: string]: string} = {};
maps.forEach( maps.forEach(map => { Object.keys(map).forEach(prop => { result[prop] = map[prop]; }); });
map => { StringMapWrapper.forEach(map, (value, prop) => { result[prop] = value; }); });
return result; return result;
} }

View File

@ -9,7 +9,6 @@
import {Inject, Injectable} from '@angular/core'; import {Inject, Injectable} from '@angular/core';
import {Options} from '../common_options'; import {Options} from '../common_options';
import {StringMapWrapper} from '../facade/collection';
import {isNumber} from '../facade/lang'; import {isNumber} from '../facade/lang';
import {Metric} from '../metric'; import {Metric} from '../metric';
import {WebDriverAdapter} from '../web_driver_adapter'; import {WebDriverAdapter} from '../web_driver_adapter';
@ -40,7 +39,7 @@ export class UserMetric extends Metric {
reject = rej; reject = rej;
}); });
let adapter = this._wdAdapter; let adapter = this._wdAdapter;
let names = StringMapWrapper.keys(this._userMetrics); let names = Object.keys(this._userMetrics);
function getAndClearValues() { function getAndClearValues() {
Promise.all(names.map(name => adapter.executeScript(`return window.${name}`))) Promise.all(names.map(name => adapter.executeScript(`return window.${name}`)))

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {StringMapWrapper} from '../facade/collection';
import {NumberWrapper} from '../facade/lang'; import {NumberWrapper} from '../facade/lang';
import {MeasureValues} from '../measure_values'; import {MeasureValues} from '../measure_values';
import {Statistic} from '../statistic'; import {Statistic} from '../statistic';
@ -17,7 +17,7 @@ export function formatNum(n: number) {
export function sortedProps(obj: {[key: string]: any}) { export function sortedProps(obj: {[key: string]: any}) {
var props: string[] = []; var props: string[] = [];
StringMapWrapper.forEach(obj, (value, prop) => props.push(prop)); props.push(...Object.keys(obj));
props.sort(); props.sort();
return props; return props;
} }
@ -30,4 +30,4 @@ export function formatStats(validSamples: MeasureValues[], metricName: string):
// Note: Don't use the unicode character for +- as it might cause // Note: Don't use the unicode character for +- as it might cause
// hickups for consoles... // hickups for consoles...
return NumberWrapper.isNaN(cv) ? formattedMean : `${formattedMean}+-${Math.floor(cv)}%`; return NumberWrapper.isNaN(cv) ? formattedMean : `${formattedMean}+-${Math.floor(cv)}%`;
} }

View File

@ -9,7 +9,6 @@
import {OpaqueToken} from '@angular/core'; import {OpaqueToken} from '@angular/core';
import {Options} from './common_options'; import {Options} from './common_options';
import {StringMapWrapper} from './facade/collection';
import {Metric} from './metric'; import {Metric} from './metric';
import {Validator} from './validator'; import {Validator} from './validator';
@ -42,7 +41,7 @@ export class SampleDescription {
public metrics: {[key: string]: any}) { public metrics: {[key: string]: any}) {
this.description = {}; this.description = {};
descriptions.forEach(description => { descriptions.forEach(description => {
StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value); Object.keys(description).forEach(prop => { this.description[prop] = description[prop]; });
}); });
} }

View File

@ -10,7 +10,6 @@ import {Provider} from '@angular/core';
import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
import {Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, ReflectiveInjector, WebDriverExtension} from '../../index'; import {Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, ReflectiveInjector, WebDriverExtension} from '../../index';
import {StringMapWrapper} from '../../src/facade/collection';
import {isPresent} from '../../src/facade/lang'; import {isPresent} from '../../src/facade/lang';
import {TraceEventFactory} from '../trace_event_factory'; import {TraceEventFactory} from '../trace_event_factory';
@ -68,7 +67,7 @@ export function main() {
function sortedKeys(stringMap: {[key: string]: any}) { function sortedKeys(stringMap: {[key: string]: any}) {
var res: string[] = []; var res: string[] = [];
StringMapWrapper.forEach(stringMap, (_, key) => { res.push(key); }); res.push(...Object.keys(stringMap));
res.sort(); res.sort();
return res; return res;
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing/testing_internal'; import {beforeEach, describe, expect, it} from '@angular/core/testing/testing_internal';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ReflectorHost} from '../src/reflector_host'; import {ReflectorHost} from '../src/reflector_host';

View File

@ -9,7 +9,6 @@
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector'; import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector';
import {HostListener, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core'; import {HostListener, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
import {ListWrapper} from '@angular/facade/src/collection'; import {ListWrapper} from '@angular/facade/src/collection';
import {isBlank} from '@angular/facade/src/lang';
import {MetadataCollector} from '@angular/tsc-wrapped'; import {MetadataCollector} from '@angular/tsc-wrapped';
import * as ts from 'typescript'; import * as ts from 'typescript';

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {StringMapWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang'; import {isPresent} from '../facade/lang';
import {Identifiers, resolveIdentifier} from '../identifiers'; import {Identifiers, resolveIdentifier} from '../identifiers';
import * as o from '../output/output_ast'; import * as o from '../output/output_ast';
@ -61,8 +61,7 @@ class _AnimationBuilder implements AnimationAstVisitor {
} }
ast.styles.forEach(entry => { ast.styles.forEach(entry => {
stylesArr.push( stylesArr.push(o.literalMap(Object.keys(entry).map(key => [key, o.literal(entry[key])])));
o.literalMap(StringMapWrapper.keys(entry).map(key => [key, o.literal(entry[key])])));
}); });
return o.importExpr(resolveIdentifier(Identifiers.AnimationStyles)).instantiate([ return o.importExpr(resolveIdentifier(Identifiers.AnimationStyles)).instantiate([
@ -133,9 +132,8 @@ class _AnimationBuilder implements AnimationAstVisitor {
visitAnimationStateDeclaration( visitAnimationStateDeclaration(
ast: AnimationStateDeclarationAst, context: _AnimationBuilderContext): void { ast: AnimationStateDeclarationAst, context: _AnimationBuilderContext): void {
var flatStyles: {[key: string]: string | number} = {}; var flatStyles: {[key: string]: string | number} = {};
_getStylesArray(ast).forEach(entry => { _getStylesArray(ast).forEach(
StringMapWrapper.forEach(entry, (value: string, key: string) => { flatStyles[key] = value; }); entry => { Object.keys(entry).forEach(key => { flatStyles[key] = entry[key]; }); });
});
context.stateMap.registerState(ast.stateName, flatStyles); context.stateMap.registerState(ast.stateName, flatStyles);
} }
@ -291,18 +289,16 @@ class _AnimationBuilder implements AnimationAstVisitor {
var fnVariable = o.variable(this._fnVarName); var fnVariable = o.variable(this._fnVarName);
var lookupMap: any[] = []; var lookupMap: any[] = [];
StringMapWrapper.forEach( Object.keys(context.stateMap.states).forEach(stateName => {
context.stateMap.states, (value: {[key: string]: string}, stateName: string) => { const value = context.stateMap.states[stateName];
var variableValue = EMPTY_MAP; var variableValue = EMPTY_MAP;
if (isPresent(value)) { if (isPresent(value)) {
let styleMap: any[] = []; let styleMap: any[] = [];
StringMapWrapper.forEach(value, (value: string, key: string) => { Object.keys(value).forEach(key => { styleMap.push([key, o.literal(value[key])]); });
styleMap.push([key, o.literal(value)]); variableValue = o.literalMap(styleMap);
}); }
variableValue = o.literalMap(styleMap); lookupMap.push([stateName, variableValue]);
} });
lookupMap.push([stateName, variableValue]);
});
const compiledStatesMapStmt = this._statesMapVar.set(o.literalMap(lookupMap)).toDeclStmt(); const compiledStatesMapStmt = this._statesMapVar.set(o.literalMap(lookupMap)).toDeclStmt();
const statements: o.Statement[] = [compiledStatesMapStmt, fnStatement]; const statements: o.Statement[] = [compiledStatesMapStmt, fnStatement];
@ -349,7 +345,7 @@ function _isEndStateAnimateStep(step: AnimationAst): boolean {
if (step instanceof AnimationStepAst && step.duration > 0 && step.keyframes.length == 2) { if (step instanceof AnimationStepAst && step.duration > 0 && step.keyframes.length == 2) {
var styles1 = _getStylesArray(step.keyframes[0])[0]; var styles1 = _getStylesArray(step.keyframes[0])[0];
var styles2 = _getStylesArray(step.keyframes[1])[0]; var styles2 = _getStylesArray(step.keyframes[1])[0];
return StringMapWrapper.isEmpty(styles1) && StringMapWrapper.isEmpty(styles2); return Object.keys(styles1).length === 0 && Object.keys(styles2).length === 0;
} }
return false; return false;
} }

View File

@ -20,6 +20,10 @@ const _INITIAL_KEYFRAME = 0;
const _TERMINAL_KEYFRAME = 1; const _TERMINAL_KEYFRAME = 1;
const _ONE_SECOND = 1000; const _ONE_SECOND = 1000;
declare type Styles = {
[key: string]: string | number
};
export class AnimationParseError extends ParseError { export class AnimationParseError extends ParseError {
constructor(message: string) { super(null, message); } constructor(message: string) { super(null, message); }
toString(): string { return `${this.msg}`; } toString(): string { return `${this.msg}`; }
@ -90,11 +94,11 @@ export class AnimationParser {
function _parseAnimationDeclarationStates( function _parseAnimationDeclarationStates(
stateMetadata: CompileAnimationStateDeclarationMetadata, stateMetadata: CompileAnimationStateDeclarationMetadata,
errors: AnimationParseError[]): AnimationStateDeclarationAst[] { errors: AnimationParseError[]): AnimationStateDeclarationAst[] {
var styleValues: {[key: string]: string | number}[] = []; var styleValues: Styles[] = [];
stateMetadata.styles.styles.forEach(stylesEntry => { stateMetadata.styles.styles.forEach(stylesEntry => {
// TODO (matsko): change this when we get CSS class integration support // TODO (matsko): change this when we get CSS class integration support
if (isStringMap(stylesEntry)) { if (isStringMap(stylesEntry)) {
styleValues.push(<{[key: string]: string | number}>stylesEntry); styleValues.push(stylesEntry as Styles);
} else { } else {
errors.push(new AnimationParseError( errors.push(new AnimationParseError(
`State based animations cannot contain references to other states`)); `State based animations cannot contain references to other states`));
@ -169,16 +173,6 @@ function _parseAnimationTransitionExpr(
return expressions; return expressions;
} }
function _fetchSylesFromState(stateName: string, stateStyles: {[key: string]: AnimationStylesAst}):
CompileAnimationStyleMetadata {
var entry = stateStyles[stateName];
if (isPresent(entry)) {
var styles = <{[key: string]: string | number}[]>entry.styles;
return new CompileAnimationStyleMetadata(0, styles);
}
return null;
}
function _normalizeAnimationEntry(entry: CompileAnimationMetadata | CompileAnimationMetadata[]): function _normalizeAnimationEntry(entry: CompileAnimationMetadata | CompileAnimationMetadata[]):
CompileAnimationMetadata { CompileAnimationMetadata {
return isArray(entry) ? new CompileAnimationSequenceMetadata(<CompileAnimationMetadata[]>entry) : return isArray(entry) ? new CompileAnimationSequenceMetadata(<CompileAnimationMetadata[]>entry) :
@ -234,7 +228,7 @@ function _normalizeStyleStepEntry(
} }
var newSteps: CompileAnimationMetadata[] = []; var newSteps: CompileAnimationMetadata[] = [];
var combinedStyles: {[key: string]: string | number}[]; var combinedStyles: Styles[];
steps.forEach(step => { steps.forEach(step => {
if (step instanceof CompileAnimationStyleMetadata) { if (step instanceof CompileAnimationStyleMetadata) {
// this occurs when a style step is followed by a previous style step // this occurs when a style step is followed by a previous style step
@ -290,7 +284,7 @@ function _normalizeStyleStepEntry(
function _resolveStylesFromState( function _resolveStylesFromState(
stateName: string, stateStyles: {[key: string]: AnimationStylesAst}, stateName: string, stateStyles: {[key: string]: AnimationStylesAst},
errors: AnimationParseError[]) { errors: AnimationParseError[]) {
var styles: {[key: string]: string | number}[] = []; var styles: Styles[] = [];
if (stateName[0] != ':') { if (stateName[0] != ':') {
errors.push(new AnimationParseError(`Animation states via styles must be prefixed with a ":"`)); errors.push(new AnimationParseError(`Animation states via styles must be prefixed with a ":"`));
} else { } else {
@ -302,7 +296,7 @@ function _resolveStylesFromState(
} else { } else {
value.styles.forEach(stylesEntry => { value.styles.forEach(stylesEntry => {
if (isStringMap(stylesEntry)) { if (isStringMap(stylesEntry)) {
styles.push(<{[key: string]: string | number}>stylesEntry); styles.push(stylesEntry as Styles);
} }
}); });
} }
@ -336,15 +330,13 @@ function _parseAnimationKeyframes(
var lastOffset = 0; var lastOffset = 0;
keyframeSequence.steps.forEach(styleMetadata => { keyframeSequence.steps.forEach(styleMetadata => {
var offset = styleMetadata.offset; var offset = styleMetadata.offset;
var keyframeStyles: {[key: string]: string | number} = {}; var keyframeStyles: Styles = {};
styleMetadata.styles.forEach(entry => { styleMetadata.styles.forEach(entry => {
StringMapWrapper.forEach( Object.keys(entry).forEach(prop => {
<{[key: string]: string | number}>entry, if (prop != 'offset') {
(value: any /** TODO #9100 */, prop: any /** TODO #9100 */) => { keyframeStyles[prop] = (entry as Styles)[prop];
if (prop != 'offset') { }
keyframeStyles[prop] = value; });
}
});
}); });
if (isPresent(offset)) { if (isPresent(offset)) {
@ -381,24 +373,22 @@ function _parseAnimationKeyframes(
let entry = rawKeyframes[i]; let entry = rawKeyframes[i];
let styles = entry[1]; let styles = entry[1];
StringMapWrapper.forEach( Object.keys(styles).forEach(prop => {
styles, (value: any /** TODO #9100 */, prop: any /** TODO #9100 */) => { if (!isPresent(firstKeyframeStyles[prop])) {
if (!isPresent(firstKeyframeStyles[prop])) { firstKeyframeStyles[prop] = FILL_STYLE_FLAG;
firstKeyframeStyles[prop] = FILL_STYLE_FLAG; }
} });
});
} }
for (i = limit - 1; i >= 0; i--) { for (i = limit - 1; i >= 0; i--) {
let entry = rawKeyframes[i]; let entry = rawKeyframes[i];
let styles = entry[1]; let styles = entry[1];
StringMapWrapper.forEach( Object.keys(styles).forEach(prop => {
styles, (value: any /** TODO #9100 */, prop: any /** TODO #9100 */) => { if (!isPresent(lastKeyframeStyles[prop])) {
if (!isPresent(lastKeyframeStyles[prop])) { lastKeyframeStyles[prop] = styles[prop];
lastKeyframeStyles[prop] = value; }
} });
});
} }
return rawKeyframes.map( return rawKeyframes.map(
@ -422,11 +412,9 @@ function _parseTransitionAnimation(
if (entry instanceof CompileAnimationStyleMetadata) { if (entry instanceof CompileAnimationStyleMetadata) {
entry.styles.forEach(stylesEntry => { entry.styles.forEach(stylesEntry => {
// by this point we know that we only have stringmap values // by this point we know that we only have stringmap values
var map = <{[key: string]: string | number}>stylesEntry; var map = stylesEntry as Styles;
StringMapWrapper.forEach( Object.keys(map).forEach(
map, (value: any /** TODO #9100 */, prop: any /** TODO #9100 */) => { prop => { collectedStyles.insertAtTime(prop, time, map[prop]); });
collectedStyles.insertAtTime(prop, time, value);
});
}); });
previousStyles = entry.styles; previousStyles = entry.styles;
return; return;
@ -472,7 +460,7 @@ function _parseTransitionAnimation(
} else { } else {
let styleData = <CompileAnimationStyleMetadata>styles; let styleData = <CompileAnimationStyleMetadata>styles;
let offset = _TERMINAL_KEYFRAME; let offset = _TERMINAL_KEYFRAME;
let styleAst = new AnimationStylesAst(<{[key: string]: string | number}[]>styleData.styles); let styleAst = new AnimationStylesAst(styleData.styles as Styles[]);
var keyframe = new AnimationKeyframeAst(offset, styleAst); var keyframe = new AnimationKeyframeAst(offset, styleAst);
keyframes = [keyframe]; keyframes = [keyframe];
} }
@ -484,9 +472,8 @@ function _parseTransitionAnimation(
keyframes.forEach( keyframes.forEach(
(keyframe: any /** TODO #9100 */) => keyframe.styles.styles.forEach( (keyframe: any /** TODO #9100 */) => keyframe.styles.styles.forEach(
(entry: any /** TODO #9100 */) => StringMapWrapper.forEach( (entry: any /** TODO #9100 */) => Object.keys(entry).forEach(
entry, (value: any /** TODO #9100 */, prop: any /** TODO #9100 */) => prop => { collectedStyles.insertAtTime(prop, currentTime, entry[prop]); })));
collectedStyles.insertAtTime(prop, currentTime, value))));
} else { } else {
// if the code reaches this stage then an error // if the code reaches this stage then an error
// has already been populated within the _normalizeStyleSteps() // has already been populated within the _normalizeStyleSteps()
@ -559,10 +546,11 @@ function _parseTimeExpression(
function _createStartKeyframeFromEndKeyframe( function _createStartKeyframeFromEndKeyframe(
endKeyframe: AnimationKeyframeAst, startTime: number, duration: number, endKeyframe: AnimationKeyframeAst, startTime: number, duration: number,
collectedStyles: StylesCollection, errors: AnimationParseError[]): AnimationKeyframeAst { collectedStyles: StylesCollection, errors: AnimationParseError[]): AnimationKeyframeAst {
var values: {[key: string]: string | number} = {}; var values: Styles = {};
var endTime = startTime + duration; var endTime = startTime + duration;
endKeyframe.styles.styles.forEach((styleData: {[key: string]: string | number}) => { endKeyframe.styles.styles.forEach((styleData: Styles) => {
StringMapWrapper.forEach(styleData, (val: any /** TODO #9100 */, prop: any /** TODO #9100 */) => { Object.keys(styleData).forEach(prop => {
const val = styleData[prop];
if (prop == 'offset') return; if (prop == 'offset') return;
var resultIndex = collectedStyles.indexOfAtOrBeforeTime(prop, startTime); var resultIndex = collectedStyles.indexOfAtOrBeforeTime(prop, startTime);

View File

@ -8,7 +8,7 @@
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core'; import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
import {ListWrapper, MapWrapper, StringMapWrapper} from './facade/collection'; import {ListWrapper, MapWrapper} from './facade/collection';
import {isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang'; import {isPresent, isStringMap, normalizeBlank, normalizeBool} from './facade/lang';
import {LifecycleHooks} from './private_import_core'; import {LifecycleHooks} from './private_import_core';
import {CssSelector} from './selector'; import {CssSelector} from './selector';
@ -342,7 +342,8 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier {
var hostProperties: {[key: string]: string} = {}; var hostProperties: {[key: string]: string} = {};
var hostAttributes: {[key: string]: string} = {}; var hostAttributes: {[key: string]: string} = {};
if (isPresent(host)) { if (isPresent(host)) {
StringMapWrapper.forEach(host, (value: string, key: string) => { Object.keys(host).forEach(key => {
const value = host[key];
const matches = key.match(HOST_REG_EXP); const matches = key.match(HOST_REG_EXP);
if (matches === null) { if (matches === null) {
hostAttributes[key] = value; hostAttributes[key] = value;

View File

@ -8,7 +8,6 @@
import {CompileIdentifierMetadata} from '../compile_metadata'; import {CompileIdentifierMetadata} from '../compile_metadata';
import {StringMapWrapper} from '../facade/collection';
import {ValueTransformer, visitValue} from '../util'; import {ValueTransformer, visitValue} from '../util';
import * as o from './output_ast'; import * as o from './output_ast';
@ -24,9 +23,7 @@ class _ValueOutputAstTransformer implements ValueTransformer {
visitStringMap(map: {[key: string]: any}, type: o.MapType): o.Expression { visitStringMap(map: {[key: string]: any}, type: o.MapType): o.Expression {
var entries: Array<string|o.Expression>[] = []; var entries: Array<string|o.Expression>[] = [];
StringMapWrapper.forEach(map, (value: any, key: string) => { Object.keys(map).forEach(key => { entries.push([key, visitValue(map[key], this, null)]); });
entries.push([key, visitValue(value, this, null)]);
});
return o.literalMap(entries, type); return o.literalMap(entries, type);
} }

View File

@ -11,7 +11,6 @@ import {Inject, Injectable, OpaqueToken, Optional, SchemaMetadata, SecurityConte
import {CompileDirectiveMetadata, CompilePipeMetadata, CompileTemplateMetadata, CompileTokenMetadata, removeIdentifierDuplicates} from '../compile_metadata'; import {CompileDirectiveMetadata, CompilePipeMetadata, CompileTemplateMetadata, CompileTokenMetadata, removeIdentifierDuplicates} from '../compile_metadata';
import {AST, ASTWithSource, BindingPipe, EmptyExpr, Interpolation, ParserError, RecursiveAstVisitor, TemplateBinding} from '../expression_parser/ast'; import {AST, ASTWithSource, BindingPipe, EmptyExpr, Interpolation, ParserError, RecursiveAstVisitor, TemplateBinding} from '../expression_parser/ast';
import {Parser} from '../expression_parser/parser'; import {Parser} from '../expression_parser/parser';
import {StringMapWrapper} from '../facade/collection';
import {isPresent, isString} from '../facade/lang'; import {isPresent, isString} from '../facade/lang';
import {I18NHtmlParser} from '../i18n/i18n_html_parser'; import {I18NHtmlParser} from '../i18n/i18n_html_parser';
import {Identifiers, identifierToken, resolveIdentifierToken} from '../identifiers'; import {Identifiers, identifierToken, resolveIdentifierToken} from '../identifiers';
@ -832,7 +831,8 @@ class TemplateParseVisitor implements html.Visitor {
elementName: string, hostProps: {[key: string]: string}, sourceSpan: ParseSourceSpan, elementName: string, hostProps: {[key: string]: string}, sourceSpan: ParseSourceSpan,
targetPropertyAsts: BoundElementPropertyAst[]) { targetPropertyAsts: BoundElementPropertyAst[]) {
if (hostProps) { if (hostProps) {
StringMapWrapper.forEach(hostProps, (expression: string, propName: string) => { Object.keys(hostProps).forEach(propName => {
const expression = hostProps[propName];
if (isString(expression)) { if (isString(expression)) {
const exprAst = this._parseBinding(expression, sourceSpan); const exprAst = this._parseBinding(expression, sourceSpan);
targetPropertyAsts.push( targetPropertyAsts.push(
@ -850,7 +850,8 @@ class TemplateParseVisitor implements html.Visitor {
hostListeners: {[key: string]: string}, sourceSpan: ParseSourceSpan, hostListeners: {[key: string]: string}, sourceSpan: ParseSourceSpan,
targetEventAsts: BoundEventAst[]) { targetEventAsts: BoundEventAst[]) {
if (hostListeners) { if (hostListeners) {
StringMapWrapper.forEach(hostListeners, (expression: string, propName: string) => { Object.keys(hostListeners).forEach(propName => {
const expression = hostListeners[propName];
if (isString(expression)) { if (isString(expression)) {
this._parseEventOrAnimationEvent(propName, expression, sourceSpan, [], targetEventAsts); this._parseEventOrAnimationEvent(propName, expression, sourceSpan, [], targetEventAsts);
} else { } else {
@ -875,7 +876,8 @@ class TemplateParseVisitor implements html.Visitor {
} }
}); });
StringMapWrapper.forEach(directiveProperties, (elProp: string, dirProp: string) => { Object.keys(directiveProperties).forEach(dirProp => {
const elProp = directiveProperties[dirProp];
const boundProp = boundPropsByName.get(elProp); const boundProp = boundPropsByName.get(elProp);
// Bindings are optional, so this binding only needs to be set up if an expression is given. // Bindings are optional, so this binding only needs to be set up if an expression is given.
@ -1047,7 +1049,8 @@ class TemplateParseVisitor implements html.Visitor {
const allDirectiveEvents = new Set<string>(); const allDirectiveEvents = new Set<string>();
directives.forEach(directive => { directives.forEach(directive => {
StringMapWrapper.forEach(directive.directive.outputs, (eventName: string) => { Object.keys(directive.directive.outputs).forEach(k => {
const eventName = directive.directive.outputs[k];
allDirectiveEvents.add(eventName); allDirectiveEvents.add(eventName);
}); });
}); });

View File

@ -7,7 +7,6 @@
*/ */
import {CompileTokenMetadata} from './compile_metadata'; import {CompileTokenMetadata} from './compile_metadata';
import {StringMapWrapper} from './facade/collection';
import {StringWrapper, isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang'; import {StringWrapper, isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang';
import * as o from './output/output_ast'; import * as o from './output/output_ast';
@ -63,9 +62,8 @@ export class ValueTransformer implements ValueVisitor {
} }
visitStringMap(map: {[key: string]: any}, context: any): any { visitStringMap(map: {[key: string]: any}, context: any): any {
var result = {}; var result = {};
StringMapWrapper.forEach(map, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => { Object.keys(map).forEach(
(result as any /** TODO #9100 */)[key] = visitValue(value, this, context); key => { (result as any /** TODO #9100 */)[key] = visitValue(map[key], this, context); });
});
return result; return result;
} }
visitPrimitive(value: any, context: any): any { return value; } visitPrimitive(value: any, context: any): any { return value; }

View File

@ -8,7 +8,7 @@
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata'; import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
import {ListWrapper, MapWrapper, StringMapWrapper} from '../facade/collection'; import {ListWrapper, MapWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang'; import {isPresent} from '../facade/lang';
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers'; import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
import * as o from '../output/output_ast'; import * as o from '../output/output_ast';
@ -192,7 +192,7 @@ export class CompileElement extends CompileNode {
queriesWithReads, queriesWithReads,
queriesForProvider.map(query => new _QueryWithRead(query, resolvedProvider.token))); queriesForProvider.map(query => new _QueryWithRead(query, resolvedProvider.token)));
}); });
StringMapWrapper.forEach(this.referenceTokens, (_: CompileTokenMetadata, varName: string) => { Object.keys(this.referenceTokens).forEach(varName => {
var token = this.referenceTokens[varName]; var token = this.referenceTokens[varName];
var varValue: o.Expression; var varValue: o.Expression;
if (isPresent(token)) { if (isPresent(token)) {

View File

@ -7,7 +7,6 @@
*/ */
import {CompileDirectiveMetadata} from '../compile_metadata'; import {CompileDirectiveMetadata} from '../compile_metadata';
import {StringMapWrapper} from '../facade/collection';
import {StringWrapper, isPresent} from '../facade/lang'; import {StringWrapper, isPresent} from '../facade/lang';
import {identifierToken} from '../identifiers'; import {identifierToken} from '../identifiers';
import * as o from '../output/output_ast'; import * as o from '../output/output_ast';
@ -173,13 +172,12 @@ export function collectEventListeners(
export function bindDirectiveOutputs( export function bindDirectiveOutputs(
directiveAst: DirectiveAst, directiveInstance: o.Expression, directiveAst: DirectiveAst, directiveInstance: o.Expression,
eventListeners: CompileEventListener[]) { eventListeners: CompileEventListener[]) {
StringMapWrapper.forEach( Object.keys(directiveAst.directive.outputs).forEach(observablePropName => {
directiveAst.directive.outputs, const eventName = directiveAst.directive.outputs[observablePropName];
(eventName: any /** TODO #9100 */, observablePropName: any /** TODO #9100 */) => { eventListeners.filter(listener => listener.eventName == eventName).forEach((listener) => {
eventListeners.filter(listener => listener.eventName == eventName).forEach((listener) => { listener.listenToDirective(directiveInstance, observablePropName);
listener.listenToDirective(directiveInstance, observablePropName); });
}); });
});
} }
export function bindRenderOutputs(eventListeners: CompileEventListener[]) { export function bindRenderOutputs(eventListeners: CompileEventListener[]) {

View File

@ -9,7 +9,7 @@
import {ViewEncapsulation} from '@angular/core'; import {ViewEncapsulation} from '@angular/core';
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata} from '../compile_metadata'; import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata} from '../compile_metadata';
import {ListWrapper, StringMapWrapper} from '../facade/collection'; import {ListWrapper} from '../facade/collection';
import {StringWrapper, isPresent} from '../facade/lang'; import {StringWrapper, isPresent} from '../facade/lang';
import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers'; import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers';
import * as o from '../output/output_ast'; import * as o from '../output/output_ast';
@ -346,10 +346,10 @@ function _mergeHtmlAndDirectiveAttrs(
declaredHtmlAttrs: {[key: string]: string}, declaredHtmlAttrs: {[key: string]: string},
directives: CompileDirectiveMetadata[]): string[][] { directives: CompileDirectiveMetadata[]): string[][] {
var result: {[key: string]: string} = {}; var result: {[key: string]: string} = {};
StringMapWrapper.forEach( Object.keys(declaredHtmlAttrs).forEach(key => { result[key] = declaredHtmlAttrs[key]; });
declaredHtmlAttrs, (value: string, key: string) => { result[key] = value; });
directives.forEach(directiveMeta => { directives.forEach(directiveMeta => {
StringMapWrapper.forEach(directiveMeta.hostAttributes, (value: string, name: string) => { Object.keys(directiveMeta.hostAttributes).forEach(name => {
const value = directiveMeta.hostAttributes[name];
var prevValue = result[name]; var prevValue = result[name];
result[name] = isPresent(prevValue) ? mergeAttributeValue(name, prevValue, value) : value; result[name] = isPresent(prevValue) ? mergeAttributeValue(name, prevValue, value) : value;
}); });
@ -373,9 +373,7 @@ function mergeAttributeValue(attrName: string, attrValue1: string, attrValue2: s
function mapToKeyValueArray(data: {[key: string]: string}): string[][] { function mapToKeyValueArray(data: {[key: string]: string}): string[][] {
var entryArray: string[][] = []; var entryArray: string[][] = [];
StringMapWrapper.forEach(data, (value: string, name: string) => { Object.keys(data).forEach(name => { entryArray.push([name, data[name]]); });
entryArray.push([name, value]);
});
// We need to sort to get a defined output order // We need to sort to get a defined output order
// for tests and for caching generated artifacts... // for tests and for caching generated artifacts...
ListWrapper.sort(entryArray, (entry1, entry2) => StringWrapper.compare(entry1[0], entry2[0])); ListWrapper.sort(entryArray, (entry1, entry2) => StringWrapper.compare(entry1[0], entry2[0]));
@ -421,11 +419,11 @@ function createStaticNodeDebugInfo(node: CompileNode): o.Expression {
if (isPresent(compileElement.component)) { if (isPresent(compileElement.component)) {
componentToken = createDiTokenExpression(identifierToken(compileElement.component.type)); componentToken = createDiTokenExpression(identifierToken(compileElement.component.type));
} }
StringMapWrapper.forEach( Object.keys(compileElement.referenceTokens).forEach(varName => {
compileElement.referenceTokens, (token: CompileTokenMetadata, varName: string) => { const token = compileElement.referenceTokens[varName];
varTokenEntries.push( varTokenEntries.push(
[varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]); [varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]);
}); });
} }
return o.importExpr(resolveIdentifier(Identifiers.StaticNodeDebugInfo)) return o.importExpr(resolveIdentifier(Identifiers.StaticNodeDebugInfo))
.instantiate( .instantiate(

View File

@ -12,7 +12,6 @@ import {expect} from '@angular/platform-browser/testing/matchers';
import {AnimationEntryAst, AnimationGroupAst, AnimationKeyframeAst, AnimationSequenceAst, AnimationStepAst, AnimationStylesAst} from '../../src/animation/animation_ast'; import {AnimationEntryAst, AnimationGroupAst, AnimationKeyframeAst, AnimationSequenceAst, AnimationStepAst, AnimationStylesAst} from '../../src/animation/animation_ast';
import {AnimationParser} from '../../src/animation/animation_parser'; import {AnimationParser} from '../../src/animation/animation_parser';
import {StringMapWrapper} from '../../src/facade/collection';
import {CompileMetadataResolver} from '../../src/metadata_resolver'; import {CompileMetadataResolver} from '../../src/metadata_resolver';
import {FILL_STYLE_FLAG, flattenStyles} from '../private_import_core'; import {FILL_STYLE_FLAG, flattenStyles} from '../private_import_core';
@ -21,10 +20,7 @@ export function main() {
var combineStyles = (styles: AnimationStylesAst): {[key: string]: string | number} => { var combineStyles = (styles: AnimationStylesAst): {[key: string]: string | number} => {
var flatStyles: {[key: string]: string | number} = {}; var flatStyles: {[key: string]: string | number} = {};
styles.styles.forEach( styles.styles.forEach(
entry => StringMapWrapper.forEach( entry => Object.keys(entry).forEach(prop => { flatStyles[prop] = entry[prop]; }));
entry, (val: any /** TODO #9100 */, prop: any /** TODO #9100 */) => {
flatStyles[prop] = val;
}));
return flatStyles; return flatStyles;
}; };

View File

@ -17,11 +17,12 @@ export function prepareFinalAnimationStyles(
nullValue: string = null): {[key: string]: string} { nullValue: string = null): {[key: string]: string} {
var finalStyles: {[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(); finalStyles[prop] = value == AUTO_STYLE ? nullValue : value.toString();
}); });
StringMapWrapper.forEach(previousStyles, (value: string, prop: string) => { Object.keys(previousStyles).forEach(prop => {
if (!isPresent(finalStyles[prop])) { if (!isPresent(finalStyles[prop])) {
finalStyles[prop] = nullValue; finalStyles[prop] = nullValue;
} }
@ -41,7 +42,8 @@ export function balanceAnimationKeyframes(
var extraFirstKeyframeStyles: {[key: string]: string} = {}; var extraFirstKeyframeStyles: {[key: string]: string} = {};
var hasExtraFirstStyles = false; 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 // if the style is already defined in the first keyframe then
// we do not replace it. // we do not replace it.
if (!flatenedFirstKeyframeStyles[prop]) { if (!flatenedFirstKeyframeStyles[prop]) {
@ -60,7 +62,7 @@ export function balanceAnimationKeyframes(
var flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles); var flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
var extraFinalKeyframeStyles: {[key: string]: string} = {}; var extraFinalKeyframeStyles: {[key: string]: string} = {};
var hasExtraFinalStyles = false; var hasExtraFinalStyles = false;
StringMapWrapper.forEach(keyframeCollectedStyles, (value: string, prop: string) => { Object.keys(keyframeCollectedStyles).forEach(prop => {
if (!isPresent(flatenedFinalKeyframeStyles[prop])) { if (!isPresent(flatenedFinalKeyframeStyles[prop])) {
extraFinalKeyframeStyles[prop] = AUTO_STYLE; extraFinalKeyframeStyles[prop] = AUTO_STYLE;
hasExtraFinalStyles = true; hasExtraFinalStyles = true;
@ -71,7 +73,7 @@ export function balanceAnimationKeyframes(
finalKeyframe.styles.styles.push(extraFinalKeyframeStyles); finalKeyframe.styles.styles.push(extraFinalKeyframeStyles);
} }
StringMapWrapper.forEach(flatenedFinalKeyframeStyles, (value: string, prop: string) => { Object.keys(flatenedFinalKeyframeStyles).forEach(prop => {
if (!isPresent(flatenedFirstKeyframeStyles[prop])) { if (!isPresent(flatenedFirstKeyframeStyles[prop])) {
extraFirstKeyframeStyles[prop] = AUTO_STYLE; extraFirstKeyframeStyles[prop] = AUTO_STYLE;
hasExtraFirstStyles = true; hasExtraFirstStyles = true;
@ -87,7 +89,7 @@ export function balanceAnimationKeyframes(
export function clearStyles(styles: {[key: string]: string | number}): {[key: string]: string} { export function clearStyles(styles: {[key: string]: string | number}): {[key: string]: string} {
var finalStyles: {[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; return finalStyles;
} }
@ -95,7 +97,8 @@ export function collectAndResolveStyles(
collection: {[key: string]: string | number}, styles: {[key: string]: string | number}[]) { collection: {[key: string]: string | number}, styles: {[key: string]: string | number}[]) {
return styles.map(entry => { return styles.map(entry => {
var stylesObj: {[key: string]: string | number} = {}; 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) { if (value == FILL_STYLE_FLAG) {
value = collection[prop]; value = collection[prop];
if (!isPresent(value)) { if (!isPresent(value)) {
@ -111,15 +114,13 @@ export function collectAndResolveStyles(
export function renderStyles( export function renderStyles(
element: any, renderer: any, styles: {[key: string]: string | number}): void { element: any, renderer: any, styles: {[key: string]: string | number}): void {
StringMapWrapper.forEach( Object.keys(styles).forEach(prop => { renderer.setElementStyle(element, prop, styles[prop]); });
styles, (value: string, prop: string) => { renderer.setElementStyle(element, prop, value); });
} }
export function flattenStyles(styles: {[key: string]: string | number}[]): {[key: string]: string} { export function flattenStyles(styles: {[key: string]: string | number}[]): {[key: string]: string} {
var finalStyles: {[key: string]: string} = {}; var finalStyles: {[key: string]: string} = {};
styles.forEach(entry => { styles.forEach(entry => {
StringMapWrapper.forEach( Object.keys(entry).forEach(prop => { finalStyles[prop] = entry[prop] as string; });
entry, (value: string, prop: string) => { finalStyles[prop] = value; });
}); });
return finalStyles; return finalStyles;
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {StringMapWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang'; import {isPresent} from '../facade/lang';
import {AnimationPlayer} from './animation_player'; import {AnimationPlayer} from './animation_player';
@ -27,7 +27,7 @@ export class ViewAnimationMap {
findAllPlayersByElement(element: any): AnimationPlayer[] { findAllPlayersByElement(element: any): AnimationPlayer[] {
const el = this._map.get(element); 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 { set(element: any, animationName: string, player: AnimationPlayer): void {
@ -54,7 +54,7 @@ export class ViewAnimationMap {
const index = this._allPlayers.indexOf(player); const index = this._allPlayers.indexOf(player);
this._allPlayers.splice(index, 1); this._allPlayers.splice(index, 1);
if (StringMapWrapper.isEmpty(playersByAnimation)) { if (Object.keys(playersByAnimation).length === 0) {
this._map.delete(element); this._map.delete(element);
} }
} }

View File

@ -284,7 +284,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
if (obj instanceof Map) { if (obj instanceof Map) {
obj.forEach(fn); obj.forEach(fn);
} else { } else {
StringMapWrapper.forEach(obj, fn); Object.keys(obj).forEach(k => fn(obj[k], k));
} }
} }
} }

View File

@ -7,7 +7,6 @@
*/ */
import {Injector} from '../di'; import {Injector} from '../di';
import {StringMapWrapper} from '../facade/collection';
import {isBlank, isPresent} from '../facade/lang'; import {isBlank, isPresent} from '../facade/lang';
import {RenderDebugInfo} from '../render/api'; import {RenderDebugInfo} from '../render/api';
@ -68,7 +67,8 @@ export class DebugContext implements RenderDebugInfo {
var staticNodeInfo = this._staticNodeInfo; var staticNodeInfo = this._staticNodeInfo;
if (isPresent(staticNodeInfo)) { if (isPresent(staticNodeInfo)) {
var refs = staticNodeInfo.refTokens; var refs = staticNodeInfo.refTokens;
StringMapWrapper.forEach(refs, (refToken: any, refName: string) => { Object.keys(refs).forEach(refName => {
const refToken = refs[refName];
let varValue: any; let varValue: any;
if (isBlank(refToken)) { if (isBlank(refToken)) {
varValue = this._view.allNodes ? this._view.allNodes[this._nodeIndex] : null; varValue = this._view.allNodes ? this._view.allNodes[this._nodeIndex] : null;

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 {isPresent} from '../facade/lang';
import {Type} from '../type'; import {Type} from '../type';
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities'; 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 { 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]); });
} }

View File

@ -17,7 +17,6 @@ import {DomRootRenderer} from '@angular/platform-browser/src/dom/dom_renderer';
import {MockSchemaRegistry} from '../../../compiler/testing/index'; import {MockSchemaRegistry} from '../../../compiler/testing/index';
import {EventEmitter} from '../../src/facade/async'; import {EventEmitter} from '../../src/facade/async';
import {StringMapWrapper} from '../../src/facade/collection';
import {NumberWrapper} from '../../src/facade/lang'; import {NumberWrapper} from '../../src/facade/lang';
export function main() { export function main() {
@ -1348,7 +1347,7 @@ class TestDirective implements OnInit, DoCheck, OnChanges, AfterContentInit, Aft
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
this.log.add(this.name, 'ngOnChanges'); this.log.add(this.name, 'ngOnChanges');
const r: {[k: string]: string} = {}; 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; this.changes = r;
if (this.throwOn == 'ngOnChanges') { if (this.throwOn == 'ngOnChanges') {
throw new Error('Boom!'); throw new Error('Boom!');

View File

@ -224,9 +224,7 @@ export class SpyObject {
} }
var m = StringMapWrapper.merge(config, overrides); var m = StringMapWrapper.merge(config, overrides);
StringMapWrapper.forEach(m, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => { Object.keys(m).forEach(key => { object.spy(key).andReturn(m[key]); });
object.spy(key).andReturn(value);
});
return object; return object;
} }

View File

@ -98,32 +98,6 @@ export class MapWrapper {
* Wraps Javascript Objects * Wraps Javascript Objects
*/ */
export class StringMapWrapper { export class StringMapWrapper {
static create(): {[k: /*any*/ string]: any} {
// Note: We are not using Object.create(null) here due to
// performance!
// http://jsperf.com/ng2-object-create-null
return {};
}
static contains(map: {[key: string]: any}, key: string): boolean {
return map.hasOwnProperty(key);
}
static keys(map: {[key: string]: any}): string[] { return Object.keys(map); }
static values<T>(map: {[key: string]: T}): T[] {
return Object.keys(map).map((k: string): T => map[k]);
}
static isEmpty(map: {[key: string]: any}): boolean {
for (var prop in map) {
return false;
}
return true;
}
static forEach<K, V>(map: {[key: string]: V}, callback: (v: V, K: string) => void) {
for (let k of Object.keys(map)) {
callback(map[k], k);
}
}
static merge<V>(m1: {[key: string]: V}, m2: {[key: string]: V}): {[key: string]: V} { static merge<V>(m1: {[key: string]: V}, m2: {[key: string]: V}): {[key: string]: V} {
var m: {[key: string]: V} = {}; var m: {[key: string]: V} = {};
@ -317,4 +291,4 @@ export function iterateListLike(obj: any, fn: Function) {
fn(item.value); fn(item.value);
} }
} }
} }

View File

@ -9,7 +9,6 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {AsyncValidatorFn, ValidatorFn} from './directives/validators'; import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
import {StringMapWrapper} from './facade/collection';
import {isArray, isPresent} from './facade/lang'; import {isArray, isPresent} from './facade/lang';
import {AbstractControl, FormArray, FormControl, FormGroup} from './model'; import {AbstractControl, FormArray, FormControl, FormGroup} from './model';
@ -75,8 +74,8 @@ export class FormBuilder {
/** @internal */ /** @internal */
_reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} { _reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} {
var controls: {[key: string]: AbstractControl} = {}; var controls: {[key: string]: AbstractControl} = {};
StringMapWrapper.forEach(controlsConfig, (controlConfig: any, controlName: string) => { Object.keys(controlsConfig).forEach(controlName => {
controls[controlName] = this._createControl(controlConfig); controls[controlName] = this._createControl(controlsConfig[controlName]);
}); });
return controls; return controls;
} }

View File

@ -939,9 +939,9 @@ export class FormGroup extends AbstractControl {
*/ */
setValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void { setValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void {
this._checkAllValuesPresent(value); this._checkAllValuesPresent(value);
StringMapWrapper.forEach(value, (newValue: any, name: string) => { Object.keys(value).forEach(name => {
this._throwIfControlMissing(name); this._throwIfControlMissing(name);
this.controls[name].setValue(newValue, {onlySelf: true}); this.controls[name].setValue(value[name], {onlySelf: true});
}); });
this.updateValueAndValidity({onlySelf: onlySelf}); this.updateValueAndValidity({onlySelf: onlySelf});
} }
@ -968,9 +968,9 @@ export class FormGroup extends AbstractControl {
* ``` * ```
*/ */
patchValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void { patchValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void {
StringMapWrapper.forEach(value, (newValue: any, name: string) => { Object.keys(value).forEach(name => {
if (this.controls[name]) { if (this.controls[name]) {
this.controls[name].patchValue(newValue, {onlySelf: true}); this.controls[name].patchValue(value[name], {onlySelf: true});
} }
}); });
this.updateValueAndValidity({onlySelf: onlySelf}); this.updateValueAndValidity({onlySelf: onlySelf});
@ -1046,7 +1046,7 @@ export class FormGroup extends AbstractControl {
/** @internal */ /** @internal */
_forEachChild(cb: (v: any, k: string) => void): void { _forEachChild(cb: (v: any, k: string) => void): void {
StringMapWrapper.forEach(this.controls, cb); Object.keys(this.controls).forEach(k => cb(this.controls[k], k));
} }
/** @internal */ /** @internal */

View File

@ -152,5 +152,5 @@ function _mergeErrors(arrayOfErrors: any[]): {[key: string]: any} {
arrayOfErrors.reduce((res: {[key: string]: any}, errors: {[key: string]: any}) => { arrayOfErrors.reduce((res: {[key: string]: any}, errors: {[key: string]: any}) => {
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res; return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
}, {}); }, {});
return StringMapWrapper.isEmpty(res) ? null : res; return Object.keys(res).length === 0 ? null : res;
} }

View File

@ -7,8 +7,6 @@
*/ */
import {AUTO_STYLE} from '@angular/core'; import {AUTO_STYLE} from '@angular/core';
import {StringMapWrapper} from '../facade/collection';
import {StringWrapper, isNumber, isPresent} from '../facade/lang'; import {StringWrapper, isNumber, isPresent} from '../facade/lang';
import {AnimationKeyframe, AnimationStyles} from '../private_import_core'; import {AnimationKeyframe, AnimationStyles} from '../private_import_core';
@ -65,15 +63,16 @@ function _populateStyles(
defaultStyles: {[key: string]: string | number}): {[key: string]: string | number} { defaultStyles: {[key: string]: string | number}): {[key: string]: string | number} {
var data: {[key: string]: string | number} = {}; var data: {[key: string]: string | number} = {};
styles.styles.forEach((entry) => { styles.styles.forEach((entry) => {
StringMapWrapper.forEach(entry, (val: any, prop: string) => { Object.keys(entry).forEach(prop => {
const val = entry[prop];
var formattedProp = dashCaseToCamelCase(prop); var formattedProp = dashCaseToCamelCase(prop);
data[formattedProp] = data[formattedProp] =
val == AUTO_STYLE ? val : val.toString() + _resolveStyleUnit(val, prop, formattedProp); val == AUTO_STYLE ? val : val.toString() + _resolveStyleUnit(val, prop, formattedProp);
}); });
}); });
StringMapWrapper.forEach(defaultStyles, (value: string, prop: string) => { Object.keys(defaultStyles).forEach(prop => {
if (!isPresent(data[prop])) { if (!isPresent(data[prop])) {
data[prop] = value; data[prop] = defaultStyles[prop];
} }
}); });
return data; return data;

View File

@ -7,8 +7,6 @@
*/ */
import {AUTO_STYLE} from '@angular/core'; import {AUTO_STYLE} from '@angular/core';
import {StringMapWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang'; import {isPresent} from '../facade/lang';
import {AnimationPlayer} from '../private_import_core'; import {AnimationPlayer} from '../private_import_core';
@ -49,7 +47,8 @@ export class WebAnimationsPlayer implements AnimationPlayer {
var keyframes = this.keyframes.map(styles => { var keyframes = this.keyframes.map(styles => {
var formattedKeyframe: {[key: string]: string | number} = {}; var formattedKeyframe: {[key: string]: string | number} = {};
StringMapWrapper.forEach(styles, (value: string | number, prop: string) => { Object.keys(styles).forEach(prop => {
const value = styles[prop];
formattedKeyframe[prop] = value == AUTO_STYLE ? _computeStyle(this.element, prop) : value; formattedKeyframe[prop] = value == AUTO_STYLE ? _computeStyle(this.element, prop) : value;
}); });
return formattedKeyframe; return formattedKeyframe;

View File

@ -12,7 +12,6 @@ import {el} from '@angular/platform-browser/testing/browser_util';
import {DomAnimatePlayer} from '../../src/dom/dom_animate_player'; import {DomAnimatePlayer} from '../../src/dom/dom_animate_player';
import {WebAnimationsDriver} from '../../src/dom/web_animations_driver'; import {WebAnimationsDriver} from '../../src/dom/web_animations_driver';
import {WebAnimationsPlayer} from '../../src/dom/web_animations_player'; import {WebAnimationsPlayer} from '../../src/dom/web_animations_player';
import {StringMapWrapper} from '../../src/facade/collection';
import {AnimationKeyframe, AnimationStyles} from '../../src/private_import_core'; import {AnimationKeyframe, AnimationStyles} from '../../src/private_import_core';
import {MockDomAnimatePlayer} from '../../testing/mock_dom_animate_player'; import {MockDomAnimatePlayer} from '../../testing/mock_dom_animate_player';
@ -113,7 +112,7 @@ export function main() {
var player = driver.animate(elm, startingStyles, styles, 1000, 1000, null); var player = driver.animate(elm, startingStyles, styles, 1000, 1000, null);
var details = _formatOptions(player); var details = _formatOptions(player);
var options = details['options']; var options = details['options'];
var keys = StringMapWrapper.keys(options); var keys = Object.keys(options);
expect(keys.indexOf('easing')).toEqual(-1); expect(keys.indexOf('easing')).toEqual(-1);
}); });
}); });

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {StringMapWrapper} from './facade/collection';
import {global, isString} from './facade/lang'; import {global, isString} from './facade/lang';
import {getDOM} from './private_import_platform-browser'; import {getDOM} from './private_import_platform-browser';
@ -190,9 +190,9 @@ _global.beforeEach(function() {
if (isString(styles)) { if (isString(styles)) {
allPassed = getDOM().hasStyle(actual, styles); allPassed = getDOM().hasStyle(actual, styles);
} else { } else {
allPassed = !StringMapWrapper.isEmpty(styles); allPassed = Object.keys(styles).length !== 0;
StringMapWrapper.forEach(styles, (style: string, prop: string) => { Object.keys(styles).forEach(prop => {
allPassed = allPassed && getDOM().hasStyle(actual, prop, style); allPassed = allPassed && getDOM().hasStyle(actual, prop, styles[prop]);
}); });
} }

View File

@ -9,8 +9,6 @@
import {AnimationPlayer} from '@angular/core'; import {AnimationPlayer} from '@angular/core';
import {MockAnimationPlayer} from '@angular/core/testing/testing_internal'; import {MockAnimationPlayer} from '@angular/core/testing/testing_internal';
import {AnimationDriver} from '@angular/platform-browser'; import {AnimationDriver} from '@angular/platform-browser';
import {StringMapWrapper} from './facade/collection';
import {AnimationKeyframe, AnimationStyles} from './private_import_core'; import {AnimationKeyframe, AnimationStyles} from './private_import_core';
export class MockAnimationDriver extends AnimationDriver { export class MockAnimationDriver extends AnimationDriver {
@ -40,7 +38,7 @@ function _serializeKeyframes(keyframes: AnimationKeyframe[]): any[] {
function _serializeStyles(styles: AnimationStyles): {[key: string]: any} { function _serializeStyles(styles: AnimationStyles): {[key: string]: any} {
var flatStyles: {[key: string]: any} = {}; var flatStyles: {[key: string]: any} = {};
styles.styles.forEach((entry: {[key: string]: string | number;}) => { styles.styles.forEach((entry: {[key: string]: string | number;}) => {
StringMapWrapper.forEach(entry, (val: any, prop: string) => { flatStyles[prop] = val; }); Object.keys(entry).forEach(prop => { flatStyles[prop] = entry[prop]; });
}); });
return flatStyles; return flatStyles;
} }

View File

@ -8,7 +8,7 @@
const parse5 = require('parse5'); const parse5 = require('parse5');
import {ListWrapper, StringMapWrapper} from '../src/facade/collection'; import {ListWrapper} from '../src/facade/collection';
import {DomAdapter, setRootDomAdapter} from './private_import_platform-browser'; import {DomAdapter, setRootDomAdapter} from './private_import_platform-browser';
import {isPresent, isBlank, global, setValueOnPath} from '../src/facade/lang'; import {isPresent, isBlank, global, setValueOnPath} from '../src/facade/lang';
import {SelectorMatcher, CssSelector} from './private_import_compiler'; import {SelectorMatcher, CssSelector} from './private_import_compiler';
@ -474,7 +474,7 @@ export class Parse5DomAdapter extends DomAdapter {
this.appendChild(newDoc, body); this.appendChild(newDoc, body);
newDoc['head'] = head; newDoc['head'] = head;
newDoc['body'] = body; newDoc['body'] = body;
newDoc['_window'] = StringMapWrapper.create(); newDoc['_window'] = {};
return newDoc; return newDoc;
} }
defaultDoc(): Document { return defDoc = defDoc || this.createHtmlDocument(); } defaultDoc(): Document { return defDoc = defDoc || this.createHtmlDocument(); }

View File

@ -1,8 +1,8 @@
import {ApplicationRef, NgModule, enableProdMode} from '@angular/core'; import {ApplicationRef, enableProdMode} from '@angular/core';
import {platformBrowser} from '@angular/platform-browser'; import {platformBrowser} from '@angular/platform-browser';
import {bindAction, profile} from '../../util'; import {bindAction, profile} from '../../util';
import {TreeNode, buildTree, emptyTree} from '../util'; import {buildTree, emptyTree} from '../util';
import {AppModuleNgFactory} from './app.ngfactory'; import {AppModuleNgFactory} from './app.ngfactory';
import {TreeComponent} from './tree'; import {TreeComponent} from './tree';

View File

@ -1,8 +1,8 @@
import {ApplicationRef, NgModule, enableProdMode} from '@angular/core'; import {ApplicationRef, enableProdMode} from '@angular/core';
import {platformBrowser} from '@angular/platform-browser'; import {platformBrowser} from '@angular/platform-browser';
import {bindAction, profile} from '../../util'; import {bindAction, profile} from '../../util';
import {TreeNode, buildTree, emptyTree} from '../util'; import {buildTree, emptyTree} from '../util';
import {AppModuleNgFactory} from './app.ngfactory'; import {AppModuleNgFactory} from './app.ngfactory';
import {TreeRootComponent} from './tree'; import {TreeRootComponent} from './tree';