diff --git a/modules/angular2/src/change_detection/coalesce.ts b/modules/angular2/src/change_detection/coalesce.ts index 041a3f64c0..53d1d24957 100644 --- a/modules/angular2/src/change_detection/coalesce.ts +++ b/modules/angular2/src/change_detection/coalesce.ts @@ -1,5 +1,5 @@ import {isPresent} from 'angular2/src/facade/lang'; -import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection'; +import {List, ListWrapper, Map} from 'angular2/src/facade/collection'; import {RecordType, ProtoRecord} from './proto_record'; /** @@ -14,7 +14,7 @@ import {RecordType, ProtoRecord} from './proto_record'; */ export function coalesce(records: List): List { var res: List = []; - var indexMap: Map = MapWrapper.create(); + var indexMap: Map = new Map(); for (var i = 0; i < records.length; ++i) { var r = records[i]; @@ -23,14 +23,14 @@ export function coalesce(records: List): List { if (isPresent(matchingRecord) && record.lastInBinding) { res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1)); - MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex); + indexMap.set(r.selfIndex, matchingRecord.selfIndex); } else if (isPresent(matchingRecord) && !record.lastInBinding) { - MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex); + indexMap.set(r.selfIndex, matchingRecord.selfIndex); } else { res.push(record); - MapWrapper.set(indexMap, r.selfIndex, record.selfIndex); + indexMap.set(r.selfIndex, record.selfIndex); } } @@ -59,6 +59,6 @@ function _replaceIndices(r: ProtoRecord, selfIndex: number, indexMap: Map, value: number) { - var r = MapWrapper.get(indexMap, value); + var r = indexMap.get(value); return isPresent(r) ? r : value; } diff --git a/modules/angular2/src/change_detection/parser/locals.ts b/modules/angular2/src/change_detection/parser/locals.ts index 04396ebd0e..b45ac4f569 100644 --- a/modules/angular2/src/change_detection/parser/locals.ts +++ b/modules/angular2/src/change_detection/parser/locals.ts @@ -18,7 +18,7 @@ export class Locals { get(name: string) { if (MapWrapper.contains(this.current, name)) { - return MapWrapper.get(this.current, name); + return this.current.get(name); } if (isPresent(this.parent)) { @@ -33,7 +33,7 @@ export class Locals { // exposed to the public API. // TODO: vsavkin maybe it should check only the local map if (MapWrapper.contains(this.current, name)) { - MapWrapper.set(this.current, name, value); + this.current.set(name, value); } else { throw new BaseException( `Setting of new keys post-construction is not supported. Key: ${name}.`); diff --git a/modules/angular2/src/change_detection/pipes/iterable_changes.ts b/modules/angular2/src/change_detection/pipes/iterable_changes.ts index 8df8aabb3c..c51cf33697 100644 --- a/modules/angular2/src/change_detection/pipes/iterable_changes.ts +++ b/modules/angular2/src/change_detection/pipes/iterable_changes.ts @@ -574,16 +574,16 @@ class _DuplicateItemRecordList { } class _DuplicateMap { - map: Map = MapWrapper.create(); + map: Map = new Map(); put(record: CollectionChangeRecord) { // todo(vicb) handle corner cases var key = getMapKey(record.item); - var duplicates = MapWrapper.get(this.map, key); + var duplicates = this.map.get(key); if (!isPresent(duplicates)) { duplicates = new _DuplicateItemRecordList(); - MapWrapper.set(this.map, key, duplicates); + this.map.set(key, duplicates); } duplicates.add(record); } @@ -598,7 +598,7 @@ class _DuplicateMap { get(value, afterIndex = null): CollectionChangeRecord { var key = getMapKey(value); - var recordList = MapWrapper.get(this.map, key); + var recordList = this.map.get(key); return isBlank(recordList) ? null : recordList.get(value, afterIndex); } @@ -611,7 +611,7 @@ class _DuplicateMap { var key = getMapKey(record.item); // todo(vicb) // assert(this.map.containsKey(key)); - var recordList: _DuplicateItemRecordList = MapWrapper.get(this.map, key); + var recordList: _DuplicateItemRecordList = this.map.get(key); // Remove the list of duplicates when it gets empty if (recordList.remove(record)) { MapWrapper.delete(this.map, key); diff --git a/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts b/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts index cb6471379e..e015a2bfde 100644 --- a/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts +++ b/modules/angular2/src/change_detection/pipes/keyvalue_changes.ts @@ -19,7 +19,7 @@ export class KeyValueChangesFactory extends PipeFactory { * @exportedAs angular2/pipes */ export class KeyValueChanges extends Pipe { - private _records: Map = MapWrapper.create(); + private _records: Map = new Map(); private _mapHead: KVChangeRecord = null; private _previousMapHead: KVChangeRecord = null; private _changesHead: KVChangeRecord = null; @@ -106,10 +106,10 @@ export class KeyValueChanges extends Pipe { this._addToRemovals(oldSeqRecord); } if (MapWrapper.contains(records, key)) { - newSeqRecord = MapWrapper.get(records, key); + newSeqRecord = records.get(key); } else { newSeqRecord = new KVChangeRecord(key); - MapWrapper.set(records, key, newSeqRecord); + records.set(key, newSeqRecord); newSeqRecord.currentValue = value; this._addToAdditions(newSeqRecord); } diff --git a/modules/angular2/src/core/compiler/compiler.ts b/modules/angular2/src/core/compiler/compiler.ts index 19a3bf95c6..bd835d9761 100644 --- a/modules/angular2/src/core/compiler/compiler.ts +++ b/modules/angular2/src/core/compiler/compiler.ts @@ -32,24 +32,22 @@ import * as renderApi from 'angular2/src/render/api'; */ @Injectable() export class CompilerCache { - _cache: Map = MapWrapper.create(); - _hostCache: Map = MapWrapper.create(); + _cache: Map = new Map(); + _hostCache: Map = new Map(); - set(component: Type, protoView: AppProtoView): void { - MapWrapper.set(this._cache, component, protoView); - } + set(component: Type, protoView: AppProtoView): void { this._cache.set(component, protoView); } get(component: Type): AppProtoView { - var result = MapWrapper.get(this._cache, component); + var result = this._cache.get(component); return normalizeBlank(result); } setHost(component: Type, protoView: AppProtoView): void { - MapWrapper.set(this._hostCache, component, protoView); + this._hostCache.set(component, protoView); } getHost(component: Type): AppProtoView { - var result = MapWrapper.get(this._hostCache, component); + var result = this._hostCache.get(component); return normalizeBlank(result); } @@ -79,7 +77,7 @@ export class Compiler { render: renderApi.RenderCompiler, protoViewFactory: ProtoViewFactory) { this._reader = reader; this._compilerCache = cache; - this._compiling = MapWrapper.create(); + this._compiling = new Map(); this._templateResolver = templateResolver; this._componentUrlMapper = componentUrlMapper; this._urlResolver = urlResolver; @@ -132,7 +130,7 @@ export class Compiler { return protoView; } - var pvPromise = MapWrapper.get(this._compiling, component); + var pvPromise = this._compiling.get(component); if (isPresent(pvPromise)) { // The component is already being compiled, attach to the existing Promise // instead of re-compiling the component. @@ -160,7 +158,7 @@ export class Compiler { return this._compileNestedProtoViews(componentBinding, renderPv, boundDirectives); }); - MapWrapper.set(this._compiling, component, pvPromise); + this._compiling.set(component, pvPromise); return pvPromise; } diff --git a/modules/angular2/src/core/compiler/component_url_mapper.ts b/modules/angular2/src/core/compiler/component_url_mapper.ts index 8326a1b699..038ff34af3 100644 --- a/modules/angular2/src/core/compiler/component_url_mapper.ts +++ b/modules/angular2/src/core/compiler/component_url_mapper.ts @@ -16,15 +16,13 @@ export class RuntimeComponentUrlMapper extends ComponentUrlMapper { constructor() { super(); - this._componentUrls = MapWrapper.create(); + this._componentUrls = new Map(); } - setComponentUrl(component: Type, url: string) { - MapWrapper.set(this._componentUrls, component, url); - } + setComponentUrl(component: Type, url: string) { this._componentUrls.set(component, url); } getUrl(component: Type): string { - var url = MapWrapper.get(this._componentUrls, component); + var url = this._componentUrls.get(component); if (isPresent(url)) return url; return super.getUrl(component); } diff --git a/modules/angular2/src/core/compiler/element_injector.ts b/modules/angular2/src/core/compiler/element_injector.ts index c41b4b890c..970305ec68 100644 --- a/modules/angular2/src/core/compiler/element_injector.ts +++ b/modules/angular2/src/core/compiler/element_injector.ts @@ -234,7 +234,7 @@ export class DirectiveBinding extends ResolvedBinding { get hostActions(): Map { return isPresent(this.metadata) && isPresent(this.metadata.hostActions) ? this.metadata.hostActions : - MapWrapper.create(); + new Map(); } get changeDetection() { return this.metadata.changeDetection; } @@ -418,14 +418,14 @@ export class ProtoElementInjector { private static _createHostInjectorBindingData(dirBindings: List, bd: List, firstBindingIsComponent: boolean) { - var visitedIds: Map = MapWrapper.create(); + var visitedIds: Map = new Map(); ListWrapper.forEach(dirBindings, dirBinding => { ListWrapper.forEach(dirBinding.resolvedHostInjectables, b => { if (MapWrapper.contains(visitedIds, b.key.id)) { throw new BaseException( `Multiple directives defined the same host injectable: "${stringify(b.key.token)}"`); } - MapWrapper.set(visitedIds, b.key.id, true); + visitedIds.set(b.key.id, true); bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding, dirBindings, ProtoElementInjector._createBinding(b))); @@ -734,7 +734,7 @@ export class ElementInjector extends TreeNode { } getVariableBinding(name: string): any { - var index = MapWrapper.get(this._proto.directiveVariableBindings, name); + var index = this._proto.directiveVariableBindings.get(name); return isPresent(index) ? this.getDirectiveAtIndex(index) : this.getElementRef(); } @@ -892,7 +892,7 @@ export class ElementInjector extends TreeNode { private _buildAttribute(dep: DirectiveDependency): string { var attributes = this._proto.attributes; if (isPresent(attributes) && MapWrapper.contains(attributes, dep.attributeName)) { - return MapWrapper.get(attributes, dep.attributeName); + return attributes.get(dep.attributeName); } else { return null; } diff --git a/modules/angular2/src/core/compiler/proto_view_factory.ts b/modules/angular2/src/core/compiler/proto_view_factory.ts index 63d6810f3b..86094974f5 100644 --- a/modules/angular2/src/core/compiler/proto_view_factory.ts +++ b/modules/angular2/src/core/compiler/proto_view_factory.ts @@ -20,7 +20,7 @@ import {ElementBinder} from './element_binder'; import {ProtoElementInjector, DirectiveBinding} from './element_injector'; class BindingRecordsCreator { - _directiveRecordsMap: Map = MapWrapper.create(); + _directiveRecordsMap: Map = new Map(); _textNodeIndex: number = 0; getBindingRecords(elementBinders: List, @@ -116,17 +116,18 @@ class BindingRecordsCreator { var id = boundElementIndex * 100 + directiveIndex; if (!MapWrapper.contains(this._directiveRecordsMap, id)) { - MapWrapper.set(this._directiveRecordsMap, id, new DirectiveRecord({ - directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex), - callOnAllChangesDone: directiveMetadata.callOnAllChangesDone, - callOnChange: directiveMetadata.callOnChange, - callOnCheck: directiveMetadata.callOnCheck, - callOnInit: directiveMetadata.callOnInit, - changeDetection: directiveMetadata.changeDetection - })); + this._directiveRecordsMap.set( + id, new DirectiveRecord({ + directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex), + callOnAllChangesDone: directiveMetadata.callOnAllChangesDone, + callOnChange: directiveMetadata.callOnChange, + callOnCheck: directiveMetadata.callOnCheck, + callOnInit: directiveMetadata.callOnInit, + changeDetection: directiveMetadata.changeDetection + })); } - return MapWrapper.get(this._directiveRecordsMap, id); + return this._directiveRecordsMap.get(id); } } @@ -245,10 +246,9 @@ function _collectNestedProtoViewsVariableBindings( } function _createVariableBindings(renderProtoView): Map { - var variableBindings = MapWrapper.create(); - MapWrapper.forEach(renderProtoView.variableBindings, (mappedName, varName) => { - MapWrapper.set(variableBindings, varName, mappedName); - }); + var variableBindings = new Map(); + MapWrapper.forEach(renderProtoView.variableBindings, + (mappedName, varName) => { variableBindings.set(varName, mappedName); }); return variableBindings; } @@ -276,12 +276,11 @@ function _createVariableNames(parentVariableNames, renderProtoView): List): Map { - var variableLocations = MapWrapper.create(); + var variableLocations = new Map(); for (var i = 0; i < elementBinders.length; i++) { var binder = elementBinders[i]; - MapWrapper.forEach(binder.variableBindings, (mappedName, varName) => { - MapWrapper.set(variableLocations, mappedName, i); - }); + MapWrapper.forEach(binder.variableBindings, + (mappedName, varName) => { variableLocations.set(mappedName, i); }); } return variableLocations; } @@ -348,7 +347,7 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE return protoElementInjector; } -function _createElementBinder(protoView, boundElementIndex, renderElementBinder, +function _createElementBinder(protoView: AppProtoView, boundElementIndex, renderElementBinder, protoElementInjector, componentDirectiveBinding, directiveBindings): ElementBinder { var parent = null; @@ -363,19 +362,18 @@ function _createElementBinder(protoView, boundElementIndex, renderElementBinder, // in order to prevent new variables from being set later in the lifecycle. Since we don't want // to actually create variable bindings for the $implicit bindings, add to the // protoLocals manually. - MapWrapper.forEach(renderElementBinder.variableBindings, (mappedName, varName) => { - MapWrapper.set(protoView.protoLocals, mappedName, null); - }); + MapWrapper.forEach(renderElementBinder.variableBindings, + (mappedName, varName) => { protoView.protoLocals.set(mappedName, null); }); return elBinder; } export function createDirectiveVariableBindings( renderElementBinder: renderApi.ElementBinder, directiveBindings: List): Map { - var directiveVariableBindings = MapWrapper.create(); + var directiveVariableBindings = new Map(); MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => { var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs); - MapWrapper.set(directiveVariableBindings, templateName, dirIndex); + directiveVariableBindings.set(templateName, dirIndex); }); return directiveVariableBindings; } diff --git a/modules/angular2/src/core/compiler/template_resolver.ts b/modules/angular2/src/core/compiler/template_resolver.ts index f0548a55d8..6125f632d6 100644 --- a/modules/angular2/src/core/compiler/template_resolver.ts +++ b/modules/angular2/src/core/compiler/template_resolver.ts @@ -9,14 +9,14 @@ import {reflector} from 'angular2/src/reflection/reflection'; @Injectable() export class TemplateResolver { - _cache: Map = MapWrapper.create(); + _cache: Map = new Map(); resolve(component: Type): View { - var view = MapWrapper.get(this._cache, component); + var view = this._cache.get(component); if (isBlank(view)) { view = this._resolve(component); - MapWrapper.set(this._cache, component, view); + this._cache.set(component, view); } return view; diff --git a/modules/angular2/src/core/compiler/view.ts b/modules/angular2/src/core/compiler/view.ts index 3a4eef8f8d..9ef1ca5aa7 100644 --- a/modules/angular2/src/core/compiler/view.ts +++ b/modules/angular2/src/core/compiler/view.ts @@ -76,7 +76,7 @@ export class AppView implements ChangeDispatcher, EventDispatcher { if (!MapWrapper.contains(this.proto.variableBindings, contextName)) { return; } - var templateName = MapWrapper.get(this.proto.variableBindings, contextName); + var templateName = this.proto.variableBindings.get(contextName); this.locals.set(templateName, value); } @@ -92,8 +92,8 @@ export class AppView implements ChangeDispatcher, EventDispatcher { * @param {int} binderIndex */ triggerEventHandlers(eventName: string, eventObj, binderIndex: int): void { - var locals = MapWrapper.create(); - MapWrapper.set(locals, '$event', eventObj); + var locals = new Map(); + locals.set('$event', eventObj); this.dispatchEvent(binderIndex, eventName, locals); } @@ -162,16 +162,15 @@ export class AppView implements ChangeDispatcher, EventDispatcher { */ export class AppProtoView { elementBinders: List = []; - protoLocals: Map = MapWrapper.create(); + protoLocals: Map = new Map(); constructor(public render: renderApi.RenderProtoViewRef, public protoChangeDetector: ProtoChangeDetector, public variableBindings: Map, public variableLocations: Map) { if (isPresent(variableBindings)) { - MapWrapper.forEach(variableBindings, (templateName, _) => { - MapWrapper.set(this.protoLocals, templateName, null); - }); + MapWrapper.forEach(variableBindings, + (templateName, _) => { this.protoLocals.set(templateName, null); }); } } @@ -211,10 +210,10 @@ export class AppProtoView { var eventName = eventBinding.fullName; var event = StringMapWrapper.get(events, eventName); if (isBlank(event)) { - event = MapWrapper.create(); + event = new Map(); StringMapWrapper.set(events, eventName, event); } - MapWrapper.set(event, directiveIndex, eventBinding.source); + event.set(directiveIndex, eventBinding.source); } } } diff --git a/modules/angular2/src/core/compiler/view_manager.ts b/modules/angular2/src/core/compiler/view_manager.ts index 54c3816df3..31b04e5112 100644 --- a/modules/angular2/src/core/compiler/view_manager.ts +++ b/modules/angular2/src/core/compiler/view_manager.ts @@ -8,7 +8,6 @@ import {Renderer, RenderViewRef} from 'angular2/src/render/api'; import {AppViewManagerUtils} from './view_manager_utils'; import {AppViewPool} from './view_pool'; import {AppViewListener} from './view_listener'; -import {MapWrapper} from 'angular2/src/facade/collection'; /** * Entry point for creating, moving views in the view hierarchy and destroying views. @@ -42,7 +41,7 @@ export class AppViewManager { if (isBlank(componentView)) { throw new BaseException(`There is no component directive at element ${boundElementIndex}`); } - var elementIndex = MapWrapper.get(componentView.proto.variableLocations, variableName); + var elementIndex = componentView.proto.variableLocations.get(variableName); if (isBlank(elementIndex)) { throw new BaseException(`Could not find variable ${variableName}`); } diff --git a/modules/angular2/src/core/compiler/view_pool.ts b/modules/angular2/src/core/compiler/view_pool.ts index 5fd4047ddb..b1369f94ef 100644 --- a/modules/angular2/src/core/compiler/view_pool.ts +++ b/modules/angular2/src/core/compiler/view_pool.ts @@ -10,15 +10,14 @@ export const APP_VIEW_POOL_CAPACITY = CONST_EXPR(new OpaqueToken('AppViewPool.vi @Injectable() export class AppViewPool { _poolCapacityPerProtoView: number; - _pooledViewsPerProtoView: Map> = - MapWrapper.create(); + _pooledViewsPerProtoView: Map> = new Map(); constructor(@Inject(APP_VIEW_POOL_CAPACITY) poolCapacityPerProtoView) { this._poolCapacityPerProtoView = poolCapacityPerProtoView; } getView(protoView: viewModule.AppProtoView): viewModule.AppView { - var pooledViews = MapWrapper.get(this._pooledViewsPerProtoView, protoView); + var pooledViews = this._pooledViewsPerProtoView.get(protoView); if (isPresent(pooledViews) && pooledViews.length > 0) { return ListWrapper.removeLast(pooledViews); } @@ -27,10 +26,10 @@ export class AppViewPool { returnView(view: viewModule.AppView): boolean { var protoView = view.proto; - var pooledViews = MapWrapper.get(this._pooledViewsPerProtoView, protoView); + var pooledViews = this._pooledViewsPerProtoView.get(protoView); if (isBlank(pooledViews)) { pooledViews = []; - MapWrapper.set(this._pooledViewsPerProtoView, protoView, pooledViews); + this._pooledViewsPerProtoView.set(protoView, pooledViews); } var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView; if (haveRemainingCapacity) { diff --git a/modules/angular2/src/core/testability/testability.ts b/modules/angular2/src/core/testability/testability.ts index 866c1a4361..70eea10336 100644 --- a/modules/angular2/src/core/testability/testability.ts +++ b/modules/angular2/src/core/testability/testability.ts @@ -58,13 +58,13 @@ export class TestabilityRegistry { _applications: Map; constructor() { - this._applications = MapWrapper.create(); + this._applications = new Map(); getTestabilityModule.GetTestability.addToWindow(this); } registerApplication(token, testability: Testability) { - MapWrapper.set(this._applications, token, testability); + this._applications.set(token, testability); } findTestabilityInTree(elem): Testability { @@ -72,7 +72,7 @@ export class TestabilityRegistry { return null; } if (MapWrapper.contains(this._applications, elem)) { - return MapWrapper.get(this._applications, elem); + return this._applications.get(elem); } if (DOM.isShadowRoot(elem)) { return this.findTestabilityInTree(DOM.getHost(elem)); diff --git a/modules/angular2/src/debug/debug_element_view_listener.ts b/modules/angular2/src/debug/debug_element_view_listener.ts index 938ed22281..442a45944c 100644 --- a/modules/angular2/src/debug/debug_element_view_listener.ts +++ b/modules/angular2/src/debug/debug_element_view_listener.ts @@ -20,8 +20,9 @@ var NG_ID_SEPARATOR_RE = RegExpWrapper.create('#'); var NG_ID_SEPARATOR = '#'; // Need to keep the views in a global Map so that multiple angular apps are supported -var _allIdsByView: Map = CONST_EXPR(MapWrapper.create()); -var _allViewsById: Map = CONST_EXPR(MapWrapper.create()); +var _allIdsByView = new Map(); +var _allViewsById = new Map(); + var _nextId = 0; function _setElementId(element, indices: List) { @@ -43,7 +44,7 @@ function _getElementId(element): List { export function inspectDomElement(element): DebugElement { var elId = _getElementId(element); if (isPresent(elId)) { - var view = MapWrapper.get(_allViewsById, elId[0]); + var view = _allViewsById.get(elId[0]); if (isPresent(view)) { return new DebugElement(view, elId[1]); } @@ -57,8 +58,8 @@ export class DebugElementViewListener implements AppViewListener { viewCreated(view: AppView) { var viewId = _nextId++; - MapWrapper.set(_allViewsById, viewId, view); - MapWrapper.set(_allIdsByView, view, viewId); + _allViewsById.set(viewId, view); + _allIdsByView.set(view, viewId); var renderView = resolveInternalDomView(view.render); for (var i = 0; i < renderView.boundElements.length; i++) { _setElementId(renderView.boundElements[i].element, [viewId, i]); @@ -66,7 +67,7 @@ export class DebugElementViewListener implements AppViewListener { } viewDestroyed(view: AppView) { - var viewId = MapWrapper.get(_allIdsByView, view); + var viewId = _allIdsByView.get(view); MapWrapper.delete(_allIdsByView, view); MapWrapper.delete(_allViewsById, viewId); } diff --git a/modules/angular2/src/di/injector.ts b/modules/angular2/src/di/injector.ts index a9d0e969c3..8ee63b5e2d 100644 --- a/modules/angular2/src/di/injector.ts +++ b/modules/angular2/src/di/injector.ts @@ -89,7 +89,7 @@ export class Injector { */ static resolve(bindings: List>): List { var resolvedBindings = resolveBindings(bindings); - var flatten = _flattenBindings(resolvedBindings, MapWrapper.create()); + var flatten = _flattenBindings(resolvedBindings, new Map()); return _createListOfBindings(flatten); } @@ -389,7 +389,7 @@ export function resolveBindings(bindings: List>): Lis } function flattenBindings(bindings: List): List { - var map = _flattenBindings(bindings, MapWrapper.create()); + var map = _flattenBindings(bindings, new Map()); var res = []; MapWrapper.forEach(map, (binding, keyId) => res.push(binding)); return res; @@ -406,7 +406,7 @@ function _flattenBindings(bindings: List>, res: Map): Map { ListWrapper.forEach(bindings, function(b) { if (b instanceof ResolvedBinding) { - MapWrapper.set(res, b.key.id, b); + res.set(b.key.id, b); } else if (b instanceof List) { _flattenBindings(b, res); } diff --git a/modules/angular2/src/di/key.ts b/modules/angular2/src/di/key.ts index 6b2627d09f..d19358ab35 100644 --- a/modules/angular2/src/di/key.ts +++ b/modules/angular2/src/di/key.ts @@ -44,7 +44,7 @@ export class Key { * @private */ export class KeyRegistry { - private _allKeys: Map = MapWrapper.create(); + private _allKeys: Map = new Map(); get(token: Object): Key { if (token instanceof Key) return token; @@ -57,11 +57,11 @@ export class KeyRegistry { token = theToken; if (MapWrapper.contains(this._allKeys, token)) { - return MapWrapper.get(this._allKeys, token); + return this._allKeys.get(token); } var newKey = new Key(token, Key.numberOfKeys); - MapWrapper.set(this._allKeys, token, newKey); + this._allKeys.set(token, newKey); return newKey; } diff --git a/modules/angular2/src/directives/ng_switch.ts b/modules/angular2/src/directives/ng_switch.ts index 2ece6d28de..24268fa65d 100644 --- a/modules/angular2/src/directives/ng_switch.ts +++ b/modules/angular2/src/directives/ng_switch.ts @@ -52,7 +52,7 @@ export class NgSwitch { _activeViews: List; constructor() { - this._valueViews = MapWrapper.create(); + this._valueViews = new Map(); this._activeViews = []; this._useDefault = false; } @@ -63,10 +63,10 @@ export class NgSwitch { // Add the ViewContainers matching the value (with a fallback to default) this._useDefault = false; - var views = MapWrapper.get(this._valueViews, value); + var views = this._valueViews.get(value); if (isBlank(views)) { this._useDefault = true; - views = normalizeBlank(MapWrapper.get(this._valueViews, _whenDefault)); + views = normalizeBlank(this._valueViews.get(_whenDefault)); } this._activateViews(views); @@ -92,7 +92,7 @@ export class NgSwitch { // Switch to default when there is no more active ViewContainers if (this._activeViews.length === 0 && !this._useDefault) { this._useDefault = true; - this._activateViews(MapWrapper.get(this._valueViews, _whenDefault)); + this._activateViews(this._valueViews.get(_whenDefault)); } } @@ -115,10 +115,10 @@ export class NgSwitch { } _registerView(value, view: SwitchView): void { - var views = MapWrapper.get(this._valueViews, value); + var views = this._valueViews.get(value); if (isBlank(views)) { views = []; - MapWrapper.set(this._valueViews, value, views); + this._valueViews.set(value, views); } views.push(view); } @@ -126,7 +126,7 @@ export class NgSwitch { _deregisterView(value, view: SwitchView): void { // `_whenDefault` is used a marker for non-registered whens if (value == _whenDefault) return; - var views = MapWrapper.get(this._valueViews, value); + var views = this._valueViews.get(value); if (views.length == 1) { MapWrapper.delete(this._valueViews, value); } else { diff --git a/modules/angular2/src/dom/browser_adapter.ts b/modules/angular2/src/dom/browser_adapter.ts index 99e79e4132..e055873aa1 100644 --- a/modules/angular2/src/dom/browser_adapter.ts +++ b/modules/angular2/src/dom/browser_adapter.ts @@ -168,11 +168,11 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { getStyle(element, stylename: string) { return element.style[stylename]; } tagName(element): string { return element.tagName; } attributeMap(element) { - var res = MapWrapper.create(); + var res = new Map(); var elAttrs = element.attributes; for (var i = 0; i < elAttrs.length; i++) { var attrib = elAttrs[i]; - MapWrapper.set(res, attrib.name, attrib.value); + res.set(attrib.name, attrib.value); } return res; } diff --git a/modules/angular2/src/dom/parse5_adapter.ts b/modules/angular2/src/dom/parse5_adapter.ts index a1e137987d..936f60f59a 100644 --- a/modules/angular2/src/dom/parse5_adapter.ts +++ b/modules/angular2/src/dom/parse5_adapter.ts @@ -339,11 +339,11 @@ export class Parse5DomAdapter extends DomAdapter { } tagName(element): string { return element.tagName == "style" ? "STYLE" : element.tagName; } attributeMap(element) { - var res = MapWrapper.create(); + var res = new Map(); var elAttrs = treeAdapter.getAttrList(element); for (var i = 0; i < elAttrs.length; i++) { var attrib = elAttrs[i]; - MapWrapper.set(res, attrib.name, attrib.value); + res.set(attrib.name, attrib.value); } return res; } diff --git a/modules/angular2/src/facade/collection.dart b/modules/angular2/src/facade/collection.dart index 6682bce221..099dd1efe9 100644 --- a/modules/angular2/src/facade/collection.dart +++ b/modules/angular2/src/facade/collection.dart @@ -30,17 +30,12 @@ class IterableMap extends IterableBase { } class MapWrapper { - static Map create() => {}; static Map clone(Map m) => new Map.from(m); static Map createFromStringMap(Map m) => m; static Map createFromPairs(List pairs) => pairs.fold({}, (m, p) { m[p[0]] = p[1]; return m; }); - static get(Map m, k) => m[k]; - static void set(Map m, k, v) { - m[k] = v; - } static contains(Map m, k) => m.containsKey(k); static forEach(Map m, fn(v, k)) { m.forEach((k, v) => fn(v, k)); diff --git a/modules/angular2/src/facade/collection.ts b/modules/angular2/src/facade/collection.ts index 3e50ff6ece..48a21268ca 100644 --- a/modules/angular2/src/facade/collection.ts +++ b/modules/angular2/src/facade/collection.ts @@ -55,18 +55,15 @@ var _clearValues: {(m: Map)} = (function() { })(); export class MapWrapper { - static create(): Map { return new Map(); } static clone(m: Map): Map { return createMapFromMap(m); } static createFromStringMap(stringMap): Map { - var result = MapWrapper.create(); + var result = new Map(); for (var prop in stringMap) { - MapWrapper.set(result, prop, stringMap[prop]); + result.set(prop, stringMap[prop]); } return result; } static createFromPairs(pairs: List): Map { return createMapFromPairs(pairs); } - static get(m: Map, k: K): V { return m.get(k); } - static set(m: Map, k: K, v: V) { m.set(k, v); } static contains(m: Map, k: K) { return m.has(k); } static forEach(m: Map, fn: /*(V, K) => void*/ Function) { m.forEach(fn); } static size(m: Map) { return m.size; } diff --git a/modules/angular2/src/http/headers.ts b/modules/angular2/src/http/headers.ts index 16a6ec099a..cf0c6efa0d 100644 --- a/modules/angular2/src/http/headers.ts +++ b/modules/angular2/src/http/headers.ts @@ -23,7 +23,7 @@ export class Headers { _headersMap: Map>; constructor(headers?: Headers | Object) { if (isBlank(headers)) { - this._headersMap = MapWrapper.create(); + this._headersMap = new Map(); return; } @@ -35,25 +35,23 @@ export class Headers { if (!isListLikeIterable(v)) { var list = []; list.push(v); - MapWrapper.set(this._headersMap, k, list); + this._headersMap.set(k, list); } }); } } append(name: string, value: string): void { - var list = MapWrapper.get(this._headersMap, name) || []; + var list = this._headersMap.get(name) || []; list.push(value); - MapWrapper.set(this._headersMap, name, list); + this._headersMap.set(name, list); } delete (name: string): void { MapWrapper.delete(this._headersMap, name); } forEach(fn: Function) { return MapWrapper.forEach(this._headersMap, fn); } - get(header: string): string { - return ListWrapper.first(MapWrapper.get(this._headersMap, header)); - } + get(header: string): string { return ListWrapper.first(this._headersMap.get(header)); } has(header: string) { return MapWrapper.contains(this._headersMap, header); } @@ -68,12 +66,12 @@ export class Headers { list.push(ListWrapper.toString((>value))); } - MapWrapper.set(this._headersMap, header, list); + this._headersMap.set(header, list); } values() { return MapWrapper.values(this._headersMap); } - getAll(header: string): Array { return MapWrapper.get(this._headersMap, header) || []; } + getAll(header: string): Array { return this._headersMap.get(header) || []; } entries() { throw new BaseException('"entries" method is not implemented on Headers class'); } } diff --git a/modules/angular2/src/http/url_search_params.ts b/modules/angular2/src/http/url_search_params.ts index 86a04ae50f..becf9e88f4 100644 --- a/modules/angular2/src/http/url_search_params.ts +++ b/modules/angular2/src/http/url_search_params.ts @@ -2,15 +2,15 @@ import {isPresent, isBlank, StringWrapper} from 'angular2/src/facade/lang'; import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection'; function paramParser(rawParams: string): Map> { - var map: Map> = MapWrapper.create(); + var map: Map> = new Map(); var params: List = StringWrapper.split(rawParams, '&'); ListWrapper.forEach(params, (param: string) => { var split: List = StringWrapper.split(param, '='); var key = ListWrapper.get(split, 0); var val = ListWrapper.get(split, 1); - var list = MapWrapper.get(map, key) || []; + var list = map.get(key) || []; list.push(val); - MapWrapper.set(map, key, list); + map.set(key, list); }); return map; } @@ -21,14 +21,14 @@ export class URLSearchParams { has(param: string): boolean { return MapWrapper.contains(this.paramsMap, param); } - get(param: string): string { return ListWrapper.first(MapWrapper.get(this.paramsMap, param)); } + get(param: string): string { return ListWrapper.first(this.paramsMap.get(param)); } - getAll(param: string): List { return MapWrapper.get(this.paramsMap, param) || []; } + getAll(param: string): List { return this.paramsMap.get(param) || []; } append(param: string, val: string): void { - var list = MapWrapper.get(this.paramsMap, param) || []; + var list = this.paramsMap.get(param) || []; list.push(val); - MapWrapper.set(this.paramsMap, param, list); + this.paramsMap.set(param, list); } toString(): string { diff --git a/modules/angular2/src/mock/template_resolver_mock.ts b/modules/angular2/src/mock/template_resolver_mock.ts index b332a545ca..02e00b16aa 100644 --- a/modules/angular2/src/mock/template_resolver_mock.ts +++ b/modules/angular2/src/mock/template_resolver_mock.ts @@ -13,10 +13,10 @@ export class MockTemplateResolver extends TemplateResolver { constructor() { super(); - this._views = MapWrapper.create(); - this._inlineTemplates = MapWrapper.create(); - this._viewCache = MapWrapper.create(); - this._directiveOverrides = MapWrapper.create(); + this._views = new Map(); + this._inlineTemplates = new Map(); + this._viewCache = new Map(); + this._directiveOverrides = new Map(); } /** @@ -27,7 +27,7 @@ export class MockTemplateResolver extends TemplateResolver { */ setView(component: Type, view: View): void { this._checkOverrideable(component); - MapWrapper.set(this._views, component, view); + this._views.set(component, view); } /** @@ -38,7 +38,7 @@ export class MockTemplateResolver extends TemplateResolver { */ setInlineTemplate(component: Type, template: string): void { this._checkOverrideable(component); - MapWrapper.set(this._inlineTemplates, component, template); + this._inlineTemplates.set(component, template); } /** @@ -51,14 +51,14 @@ export class MockTemplateResolver extends TemplateResolver { overrideViewDirective(component: Type, from: Type, to: Type): void { this._checkOverrideable(component); - var overrides = MapWrapper.get(this._directiveOverrides, component); + var overrides = this._directiveOverrides.get(component); if (isBlank(overrides)) { - overrides = MapWrapper.create(); - MapWrapper.set(this._directiveOverrides, component, overrides); + overrides = new Map(); + this._directiveOverrides.set(component, overrides); } - MapWrapper.set(overrides, from, to); + overrides.set(from, to); } /** @@ -73,16 +73,16 @@ export class MockTemplateResolver extends TemplateResolver { * @returns {ViewDefinition} */ resolve(component: Type): View { - var view = MapWrapper.get(this._viewCache, component); + var view = this._viewCache.get(component); if (isPresent(view)) return view; - view = MapWrapper.get(this._views, component); + view = this._views.get(component); if (isBlank(view)) { view = super.resolve(component); } var directives = view.directives; - var overrides = MapWrapper.get(this._directiveOverrides, component); + var overrides = this._directiveOverrides.get(component); if (isPresent(overrides) && isPresent(directives)) { directives = ListWrapper.clone(view.directives); @@ -98,12 +98,12 @@ export class MockTemplateResolver extends TemplateResolver { {template: view.template, templateUrl: view.templateUrl, directives: directives}); } - var inlineTemplate = MapWrapper.get(this._inlineTemplates, component); + var inlineTemplate = this._inlineTemplates.get(component); if (isPresent(inlineTemplate)) { view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives}); } - MapWrapper.set(this._viewCache, component, view); + this._viewCache.set(component, view); return view; } @@ -116,7 +116,7 @@ export class MockTemplateResolver extends TemplateResolver { * @param {Type} component */ _checkOverrideable(component: Type): void { - var cached = MapWrapper.get(this._viewCache, component); + var cached = this._viewCache.get(component); if (isPresent(cached)) { throw new BaseException( diff --git a/modules/angular2/src/reflection/reflector.ts b/modules/angular2/src/reflection/reflector.ts index 5582ece148..d27ab4fbf3 100644 --- a/modules/angular2/src/reflection/reflector.ts +++ b/modules/angular2/src/reflection/reflector.ts @@ -20,15 +20,15 @@ export class Reflector { reflectionCapabilities: PlatformReflectionCapabilities; constructor(reflectionCapabilities: PlatformReflectionCapabilities) { - this._typeInfo = MapWrapper.create(); - this._getters = MapWrapper.create(); - this._setters = MapWrapper.create(); - this._methods = MapWrapper.create(); + this._typeInfo = new Map(); + this._getters = new Map(); + this._setters = new Map(); + this._methods = new Map(); this.reflectionCapabilities = reflectionCapabilities; } registerType(type: Type, typeInfo: StringMap): void { - MapWrapper.set(this._typeInfo, type, typeInfo); + this._typeInfo.set(type, typeInfo); } registerGetters(getters: StringMap): void { @@ -77,7 +77,7 @@ export class Reflector { getter(name: string): GetterFn { if (MapWrapper.contains(this._getters, name)) { - return MapWrapper.get(this._getters, name); + return this._getters.get(name); } else { return this.reflectionCapabilities.getter(name); } @@ -85,7 +85,7 @@ export class Reflector { setter(name: string): SetterFn { if (MapWrapper.contains(this._setters, name)) { - return MapWrapper.get(this._setters, name); + return this._setters.get(name); } else { return this.reflectionCapabilities.setter(name); } @@ -93,14 +93,14 @@ export class Reflector { method(name: string): MethodFn { if (MapWrapper.contains(this._methods, name)) { - return MapWrapper.get(this._methods, name); + return this._methods.get(name); } else { return this.reflectionCapabilities.method(name); } } _getTypeInfoField(typeOrFunc, key, defaultValue) { - var res = MapWrapper.get(this._typeInfo, typeOrFunc)[key]; + var res = this._typeInfo.get(typeOrFunc)[key]; return isPresent(res) ? res : defaultValue; } @@ -108,5 +108,5 @@ export class Reflector { } function _mergeMaps(target: Map, config: StringMap): void { - StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v)); + StringMapWrapper.forEach(config, (v, k) => target.set(k, v)); } diff --git a/modules/angular2/src/render/api.ts b/modules/angular2/src/render/api.ts index dd440ad7a6..3230d5dd8d 100644 --- a/modules/angular2/src/render/api.ts +++ b/modules/angular2/src/render/api.ts @@ -205,22 +205,22 @@ export class DirectiveMetadata { changeDetection?: string, exportAs?: string }) { - let hostListeners = MapWrapper.create(); - let hostProperties = MapWrapper.create(); - let hostAttributes = MapWrapper.create(); - let hostActions = MapWrapper.create(); + let hostListeners = new Map(); + let hostProperties = new Map(); + let hostAttributes = new Map(); + let hostActions = new Map(); if (isPresent(host)) { MapWrapper.forEach(host, (value: string, key: string) => { var matches = RegExpWrapper.firstMatch(hostRegExp, key); if (isBlank(matches)) { - MapWrapper.set(hostAttributes, key, value); + hostAttributes.set(key, value); } else if (isPresent(matches[1])) { - MapWrapper.set(hostProperties, matches[1], value); + hostProperties.set(matches[1], value); } else if (isPresent(matches[2])) { - MapWrapper.set(hostListeners, matches[2], value); + hostListeners.set(matches[2], value); } else if (isPresent(matches[3])) { - MapWrapper.set(hostActions, matches[3], value); + hostActions.set(matches[3], value); } }); } diff --git a/modules/angular2/src/render/dom/compiler/compile_element.ts b/modules/angular2/src/render/dom/compiler/compile_element.ts index af5e6eee17..1d64db7b16 100644 --- a/modules/angular2/src/render/dom/compiler/compile_element.ts +++ b/modules/angular2/src/render/dom/compiler/compile_element.ts @@ -83,8 +83,8 @@ function getElementDescription(domElement): string { buf.add(DOM.tagName(domElement).toLowerCase()); // show id and class first to ease element identification - addDescriptionAttribute(buf, "id", MapWrapper.get(atts, "id")); - addDescriptionAttribute(buf, "class", MapWrapper.get(atts, "class")); + addDescriptionAttribute(buf, "id", atts.get("id")); + addDescriptionAttribute(buf, "class", atts.get("class")); MapWrapper.forEach(atts, (attValue, attName) => { if (attName !== "id" && attName !== "class") { addDescriptionAttribute(buf, attName, attValue); diff --git a/modules/angular2/src/render/dom/compiler/directive_parser.ts b/modules/angular2/src/render/dom/compiler/directive_parser.ts index bb6397d739..628f755309 100644 --- a/modules/angular2/src/render/dom/compiler/directive_parser.ts +++ b/modules/angular2/src/render/dom/compiler/directive_parser.ts @@ -135,11 +135,10 @@ export class DirectiveParser implements CompileStep { pipes = []; } - var bindingAst = - MapWrapper.get(compileElement.bindElement().propertyBindings, dashCaseToCamelCase(elProp)); + var bindingAst = compileElement.bindElement().propertyBindings.get(dashCaseToCamelCase(elProp)); if (isBlank(bindingAst)) { - var attributeValue = MapWrapper.get(compileElement.attrs(), camelCaseToDashCase(elProp)); + var attributeValue = compileElement.attrs().get(camelCaseToDashCase(elProp)); if (isPresent(attributeValue)) { bindingAst = this._parser.wrapLiteralPrimitive(attributeValue, compileElement.elementDescription); diff --git a/modules/angular2/src/render/dom/compiler/property_binding_parser.ts b/modules/angular2/src/render/dom/compiler/property_binding_parser.ts index 381a4e6771..1304ce5d0f 100644 --- a/modules/angular2/src/render/dom/compiler/property_binding_parser.ts +++ b/modules/angular2/src/render/dom/compiler/property_binding_parser.ts @@ -27,7 +27,7 @@ export class PropertyBindingParser implements CompileStep { process(parent: CompileElement, current: CompileElement, control: CompileControl) { var attrs = current.attrs(); - var newAttrs = MapWrapper.create(); + var newAttrs = new Map(); MapWrapper.forEach(attrs, (attrValue, attrName) => { var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName); @@ -66,13 +66,12 @@ export class PropertyBindingParser implements CompileStep { } }); - MapWrapper.forEach(newAttrs, - (attrValue, attrName) => { MapWrapper.set(attrs, attrName, attrValue); }); + MapWrapper.forEach(newAttrs, (attrValue, attrName) => { attrs.set(attrName, attrValue); }); } - _bindVariable(identifier, value, current: CompileElement, newAttrs) { + _bindVariable(identifier, value, current: CompileElement, newAttrs: Map) { current.bindElement().bindVariable(dashCaseToCamelCase(identifier), value); - MapWrapper.set(newAttrs, identifier, value); + newAttrs.set(identifier, value); } _bindProperty(name, expression, current: CompileElement, newAttrs) { @@ -80,10 +79,10 @@ export class PropertyBindingParser implements CompileStep { current, newAttrs); } - _bindPropertyAst(name, ast, current: CompileElement, newAttrs) { + _bindPropertyAst(name, ast, current: CompileElement, newAttrs: Map) { var binder = current.bindElement(); binder.bindProperty(dashCaseToCamelCase(name), ast); - MapWrapper.set(newAttrs, name, ast.source); + newAttrs.set(name, ast.source); } _bindAssignmentEvent(name, expression, current: CompileElement, newAttrs) { diff --git a/modules/angular2/src/render/dom/compiler/selector.ts b/modules/angular2/src/render/dom/compiler/selector.ts index a339488c56..45e261fe19 100644 --- a/modules/angular2/src/render/dom/compiler/selector.ts +++ b/modules/angular2/src/render/dom/compiler/selector.ts @@ -141,12 +141,12 @@ export class SelectorMatcher { return notMatcher; } - private _elementMap: Map> = MapWrapper.create(); - private _elementPartialMap: Map = MapWrapper.create(); - private _classMap: Map> = MapWrapper.create(); - private _classPartialMap: Map = MapWrapper.create(); - private _attrValueMap: Map>> = MapWrapper.create(); - private _attrValuePartialMap: Map> = MapWrapper.create(); + private _elementMap: Map> = new Map(); + private _elementPartialMap: Map = new Map(); + private _classMap: Map> = new Map(); + private _classPartialMap: Map = new Map(); + private _attrValueMap: Map>> = new Map(); + private _attrValuePartialMap: Map> = new Map(); private _listContexts: List = []; addSelectables(cssSelectors: List, callbackCtxt?: any) { @@ -201,18 +201,18 @@ export class SelectorMatcher { var attrValue = attrs[index++]; if (isTerminal) { var terminalMap = matcher._attrValueMap; - var terminalValuesMap = MapWrapper.get(terminalMap, attrName); + var terminalValuesMap = terminalMap.get(attrName); if (isBlank(terminalValuesMap)) { - terminalValuesMap = MapWrapper.create(); - MapWrapper.set(terminalMap, attrName, terminalValuesMap); + terminalValuesMap = new Map(); + terminalMap.set(attrName, terminalValuesMap); } this._addTerminal(terminalValuesMap, attrValue, selectable); } else { var parttialMap = matcher._attrValuePartialMap; - var partialValuesMap = MapWrapper.get(parttialMap, attrName); + var partialValuesMap = parttialMap.get(attrName); if (isBlank(partialValuesMap)) { - partialValuesMap = MapWrapper.create(); - MapWrapper.set(parttialMap, attrName, partialValuesMap); + partialValuesMap = new Map(); + parttialMap.set(attrName, partialValuesMap); } matcher = this._addPartial(partialValuesMap, attrValue); } @@ -222,19 +222,19 @@ export class SelectorMatcher { private _addTerminal(map: Map>, name: string, selectable: SelectorContext) { - var terminalList = MapWrapper.get(map, name); + var terminalList = map.get(name); if (isBlank(terminalList)) { terminalList = []; - MapWrapper.set(map, name, terminalList); + map.set(name, terminalList); } terminalList.push(selectable); } private _addPartial(map: Map, name: string): SelectorMatcher { - var matcher = MapWrapper.get(map, name); + var matcher = map.get(name); if (isBlank(matcher)) { matcher = new SelectorMatcher(); - MapWrapper.set(map, name, matcher); + map.set(name, matcher); } return matcher; } @@ -276,7 +276,7 @@ export class SelectorMatcher { var attrName = attrs[index++]; var attrValue = attrs[index++]; - var terminalValuesMap = MapWrapper.get(this._attrValueMap, attrName); + var terminalValuesMap = this._attrValueMap.get(attrName); if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) { result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) || @@ -285,7 +285,7 @@ export class SelectorMatcher { result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) || result; - var partialValuesMap = MapWrapper.get(this._attrValuePartialMap, attrName); + var partialValuesMap = this._attrValuePartialMap.get(attrName); if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) { result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) || @@ -304,8 +304,8 @@ export class SelectorMatcher { return false; } - var selectables = MapWrapper.get(map, name); - var starSelectables = MapWrapper.get(map, "*"); + var selectables = map.get(name); + var starSelectables = map.get("*"); if (isPresent(starSelectables)) { selectables = ListWrapper.concat(selectables, starSelectables); } @@ -326,7 +326,7 @@ export class SelectorMatcher { if (isBlank(map) || isBlank(name)) { return false; } - var nestedSelector = MapWrapper.get(map, name); + var nestedSelector = map.get(name); if (isBlank(nestedSelector)) { return false; } diff --git a/modules/angular2/src/render/dom/compiler/template_loader.ts b/modules/angular2/src/render/dom/compiler/template_loader.ts index b22506edbe..4d79bb1758 100644 --- a/modules/angular2/src/render/dom/compiler/template_loader.ts +++ b/modules/angular2/src/render/dom/compiler/template_loader.ts @@ -15,7 +15,7 @@ import {UrlResolver} from 'angular2/src/services/url_resolver'; */ @Injectable() export class TemplateLoader { - _cache: Map> = MapWrapper.create(); + _cache: Map> = new Map(); constructor(private _xhr: XHR, urlResolver: UrlResolver) {} @@ -52,7 +52,7 @@ export class TemplateLoader { } private _loadText(url: string): Promise { - var response = MapWrapper.get(this._cache, url); + var response = this._cache.get(url); if (isBlank(response)) { // TODO(vicb): change error when TS gets fixed @@ -62,7 +62,7 @@ export class TemplateLoader { this._xhr.get(url), _ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null)); - MapWrapper.set(this._cache, url, response); + this._cache.set(url, response); } return response; diff --git a/modules/angular2/src/render/dom/compiler/view_splitter.ts b/modules/angular2/src/render/dom/compiler/view_splitter.ts index acdf3daf72..9329b9bfd0 100644 --- a/modules/angular2/src/render/dom/compiler/view_splitter.ts +++ b/modules/angular2/src/render/dom/compiler/view_splitter.ts @@ -30,7 +30,7 @@ export class ViewSplitter implements CompileStep { process(parent: CompileElement, current: CompileElement, control: CompileControl) { var attrs = current.attrs(); - var templateBindings = MapWrapper.get(attrs, 'template'); + var templateBindings = attrs.get('template'); var hasTemplateBinding = isPresent(templateBindings); // look for template shortcuts such as *ng-if="condition" and treat them as template="if @@ -106,11 +106,11 @@ export class ViewSplitter implements CompileStep { var binding = bindings[i]; if (binding.keyIsVar) { compileElement.bindElement().bindVariable(dashCaseToCamelCase(binding.key), binding.name); - MapWrapper.set(compileElement.attrs(), binding.key, binding.name); + compileElement.attrs().set(binding.key, binding.name); } else if (isPresent(binding.expression)) { compileElement.bindElement().bindProperty(dashCaseToCamelCase(binding.key), binding.expression); - MapWrapper.set(compileElement.attrs(), binding.key, binding.expression.source); + compileElement.attrs().set(binding.key, binding.expression.source); } else { DOM.setAttribute(compileElement.element, binding.key, ''); } diff --git a/modules/angular2/src/render/dom/convert.ts b/modules/angular2/src/render/dom/convert.ts index b73b4f3d86..7259b9fdff 100644 --- a/modules/angular2/src/render/dom/convert.ts +++ b/modules/angular2/src/render/dom/convert.ts @@ -37,24 +37,24 @@ export function directiveMetadataToMap(meta: DirectiveMetadata): Map): DirectiveMetadata { return new DirectiveMetadata({ - id:MapWrapper.get(map, 'id'), - selector:MapWrapper.get(map, 'selector'), - compileChildren:MapWrapper.get(map, 'compileChildren'), - hostProperties:>_cloneIfPresent(MapWrapper.get(map, 'hostProperties')), - hostListeners:>_cloneIfPresent(MapWrapper.get(map, 'hostListeners')), - hostActions:>_cloneIfPresent(MapWrapper.get(map, 'hostActions')), - hostAttributes:>_cloneIfPresent(MapWrapper.get(map, 'hostAttributes')), - properties:>_cloneIfPresent(MapWrapper.get(map, 'properties')), - readAttributes:>_cloneIfPresent(MapWrapper.get(map, 'readAttributes')), - type:MapWrapper.get(map, 'type'), - exportAs:MapWrapper.get(map, 'exportAs'), - callOnDestroy:MapWrapper.get(map, 'callOnDestroy'), - callOnCheck:MapWrapper.get(map, 'callOnCheck'), - callOnChange:MapWrapper.get(map, 'callOnChange'), - callOnInit:MapWrapper.get(map, 'callOnInit'), - callOnAllChangesDone:MapWrapper.get(map, 'callOnAllChangesDone'), - events:>_cloneIfPresent(MapWrapper.get(map, 'events')), - changeDetection:MapWrapper.get(map, 'changeDetection'), + id:map.get('id'), + selector:map.get('selector'), + compileChildren:map.get('compileChildren'), + hostProperties:>_cloneIfPresent(map.get('hostProperties')), + hostListeners:>_cloneIfPresent(map.get('hostListeners')), + hostActions:>_cloneIfPresent(map.get('hostActions')), + hostAttributes:>_cloneIfPresent(map.get('hostAttributes')), + properties:>_cloneIfPresent(map.get('properties')), + readAttributes:>_cloneIfPresent(map.get('readAttributes')), + type:map.get('type'), + exportAs:map.get('exportAs'), + callOnDestroy:map.get('callOnDestroy'), + callOnCheck:map.get('callOnCheck'), + callOnChange:map.get('callOnChange'), + callOnInit:map.get('callOnInit'), + callOnAllChangesDone:map.get('callOnAllChangesDone'), + events:>_cloneIfPresent(map.get('events')), + changeDetection:map.get('changeDetection'), }); } diff --git a/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.ts b/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.ts index 4b4df8b154..0670befa2e 100644 --- a/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.ts +++ b/modules/angular2/src/render/dom/shadow_dom/shadow_dom_compile_step.ts @@ -44,7 +44,7 @@ export class ShadowDomCompileStep implements CompileStep { return; } var attrs = current.attrs(); - var selector = MapWrapper.get(attrs, 'select'); + var selector = attrs.get('select'); selector = isPresent(selector) ? selector : ''; // The content tag should be replaced by a pair of marker tags (start & end). diff --git a/modules/angular2/src/render/dom/shadow_dom/util.ts b/modules/angular2/src/render/dom/shadow_dom/util.ts index 1e3bb20dd6..bbb1e86250 100644 --- a/modules/angular2/src/render/dom/shadow_dom/util.ts +++ b/modules/angular2/src/render/dom/shadow_dom/util.ts @@ -5,16 +5,16 @@ import {DOM} from 'angular2/src/dom/dom_adapter'; import {ShadowCss} from './shadow_css'; -var _componentUIDs: Map = MapWrapper.create(); +var _componentUIDs: Map = new Map(); var _nextComponentUID: int = 0; -var _sharedStyleTexts: Map = MapWrapper.create(); +var _sharedStyleTexts: Map = new Map(); var _lastInsertedStyleEl; export function getComponentId(componentStringId: string) { - var id = MapWrapper.get(_componentUIDs, componentStringId); + var id = _componentUIDs.get(componentStringId); if (isBlank(id)) { id = _nextComponentUID++; - MapWrapper.set(_componentUIDs, componentStringId, id); + _componentUIDs.set(componentStringId, id); } return id; } @@ -23,7 +23,7 @@ export function insertSharedStyleText(cssText, styleHost, styleEl) { if (!MapWrapper.contains(_sharedStyleTexts, cssText)) { // Styles are unscoped and shared across components, only append them to the head // when there are not present yet - MapWrapper.set(_sharedStyleTexts, cssText, true); + _sharedStyleTexts.set(cssText, true); insertStyleElement(styleHost, styleEl); } } diff --git a/modules/angular2/src/render/dom/view/proto_view_builder.ts b/modules/angular2/src/render/dom/view/proto_view_builder.ts index fb1a95055e..716720b3a3 100644 --- a/modules/angular2/src/render/dom/view/proto_view_builder.ts +++ b/modules/angular2/src/render/dom/view/proto_view_builder.ts @@ -20,7 +20,7 @@ import * as api from '../../api'; import {NG_BINDING_CLASS, EVENT_TARGET_SEPARATOR} from '../util'; export class ProtoViewBuilder { - variableBindings: Map = MapWrapper.create(); + variableBindings: Map = new Map(); elements: List = []; constructor(public rootElement, public type: api.ViewType) {} @@ -40,7 +40,7 @@ export class ProtoViewBuilder { // by the "value", or exported identifier. For example, ng-for sets a view local of "index". // When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing // it. - MapWrapper.set(this.variableBindings, value, name); + this.variableBindings.set(value, name); } build(setterFactory: PropertySetterFactory): api.ProtoViewDto { @@ -49,20 +49,20 @@ export class ProtoViewBuilder { var apiElementBinders = []; var transitiveContentTagCount = 0; ListWrapper.forEach(this.elements, (ebb: ElementBinderBuilder) => { - var propertySetters = MapWrapper.create(); - var hostActions = MapWrapper.create(); + var propertySetters = new Map(); + var hostActions = new Map(); var apiDirectiveBinders = ListWrapper.map(ebb.directives, (dbb: DirectiveBuilder) => { ebb.eventBuilder.merge(dbb.eventBuilder); MapWrapper.forEach(dbb.hostPropertyBindings, (_, hostPropertyName) => { - MapWrapper.set(propertySetters, hostPropertyName, - setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), - hostPropertyName)); + propertySetters.set(hostPropertyName, + setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), + hostPropertyName)); }); ListWrapper.forEach(dbb.hostActions, (hostAction) => { - MapWrapper.set(hostActions, hostAction.actionExpression, hostAction.expression); + hostActions.set(hostAction.actionExpression, hostAction.expression); }); return new api.DirectiveBinder({ @@ -74,8 +74,9 @@ export class ProtoViewBuilder { }); MapWrapper.forEach(ebb.propertyBindings, (_, propertyName) => { - MapWrapper.set( - propertySetters, propertyName, + + propertySetters.set( + propertyName, setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), propertyName)); }); @@ -149,14 +150,14 @@ export class ElementBinderBuilder { distanceToParent: number = 0; directives: List = []; nestedProtoView: ProtoViewBuilder = null; - propertyBindings: Map = MapWrapper.create(); - variableBindings: Map = MapWrapper.create(); + propertyBindings: Map = new Map(); + variableBindings: Map = new Map(); eventBindings: List = []; eventBuilder: EventBuilder = new EventBuilder(); textBindingIndices: List = []; textBindings: List = []; contentTagSelector: string = null; - readAttributes: Map = MapWrapper.create(); + readAttributes: Map = new Map(); componentId: string = null; constructor(public index: number, public element, description: string) {} @@ -170,8 +171,8 @@ export class ElementBinderBuilder { } readAttribute(attrName: string) { - if (isBlank(MapWrapper.get(this.readAttributes, attrName))) { - MapWrapper.set(this.readAttributes, attrName, DOM.getAttribute(this.element, attrName)); + if (isBlank(this.readAttributes.get(attrName))) { + this.readAttributes.set(attrName, DOM.getAttribute(this.element, attrName)); } } @@ -189,7 +190,7 @@ export class ElementBinderBuilder { return this.nestedProtoView; } - bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); } + bindProperty(name, expression) { this.propertyBindings.set(name, expression); } bindVariable(name, value) { // When current is a view root, the variable bindings are set to the *nested* proto view. @@ -205,7 +206,7 @@ export class ElementBinderBuilder { // When this occurs, a lookup keyed by "index" must occur to find if there is a var // referencing // it. - MapWrapper.set(this.variableBindings, value, name); + this.variableBindings.set(value, name); } } @@ -224,19 +225,17 @@ export class ElementBinderBuilder { } export class DirectiveBuilder { - propertyBindings: Map = MapWrapper.create(); - hostPropertyBindings: Map = MapWrapper.create(); + propertyBindings: Map = new Map(); + hostPropertyBindings: Map = new Map(); hostActions: List = []; eventBindings: List = []; eventBuilder: EventBuilder = new EventBuilder(); constructor(public directiveIndex: number) {} - bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); } + bindProperty(name, expression) { this.propertyBindings.set(name, expression); } - bindHostProperty(name, expression) { - MapWrapper.set(this.hostPropertyBindings, name, expression); - } + bindHostProperty(name, expression) { this.hostPropertyBindings.set(name, expression); } bindHostAction(actionName: string, actionExpression: string, expression: ASTWithSource) { this.hostActions.push(new HostAction(actionName, actionExpression, expression)); diff --git a/modules/angular2/src/render/dom/view/view.ts b/modules/angular2/src/render/dom/view/view.ts index 41ca42764c..e4b804351d 100644 --- a/modules/angular2/src/render/dom/view/view.ts +++ b/modules/angular2/src/render/dom/view/view.ts @@ -40,20 +40,19 @@ export class DomView { } setElementProperty(elementIndex: number, propertyName: string, value: any) { - var setter = - MapWrapper.get(this.proto.elementBinders[elementIndex].propertySetters, propertyName); + var setter = this.proto.elementBinders[elementIndex].propertySetters.get(propertyName); setter(this.boundElements[elementIndex].element, value); } callAction(elementIndex: number, actionExpression: string, actionArgs: any) { var binder = this.proto.elementBinders[elementIndex]; - var hostAction = MapWrapper.get(binder.hostActions, actionExpression); + var hostAction = binder.hostActions.get(actionExpression); hostAction.eval(this.boundElements[elementIndex].element, this._localsWithAction(actionArgs)); } _localsWithAction(action: Object): Locals { - var map = MapWrapper.create(); - MapWrapper.set(map, '$action', action); + var map = new Map(); + map.set('$action', action); return new Locals(null, map); } @@ -62,8 +61,8 @@ export class DomView { dispatchEvent(elementIndex, eventName, event): boolean { var allowDefaultBehavior = true; if (isPresent(this.eventDispatcher)) { - var evalLocals = MapWrapper.create(); - MapWrapper.set(evalLocals, '$event', event); + var evalLocals = new Map(); + evalLocals.set('$event', event); // TODO(tbosch): reenable this when we are parsing element properties // out of action expressions // var localValues = this.proto.elementBinders[elementIndex].eventLocals.eval(null, new diff --git a/modules/angular2/src/render/xhr_mock.ts b/modules/angular2/src/render/xhr_mock.ts index b74e1920ac..606f63acb8 100644 --- a/modules/angular2/src/render/xhr_mock.ts +++ b/modules/angular2/src/render/xhr_mock.ts @@ -11,7 +11,7 @@ export class MockXHR extends XHR { constructor() { super(); this._expectations = []; - this._definitions = MapWrapper.create(); + this._definitions = new Map(); this._requests = []; } @@ -26,7 +26,7 @@ export class MockXHR extends XHR { this._expectations.push(expectation); } - when(url: string, response: string) { MapWrapper.set(this._definitions, url, response); } + when(url: string, response: string) { this._definitions.set(url, response); } flush() { if (this._requests.length === 0) { @@ -66,7 +66,7 @@ export class MockXHR extends XHR { } if (MapWrapper.contains(this._definitions, url)) { - var response = MapWrapper.get(this._definitions, url); + var response = this._definitions.get(url); request.complete(normalizeBlank(response)); return; } diff --git a/modules/angular2/src/router/route_recognizer.ts b/modules/angular2/src/router/route_recognizer.ts index 8e2efac859..440d54f598 100644 --- a/modules/angular2/src/router/route_recognizer.ts +++ b/modules/angular2/src/router/route_recognizer.ts @@ -27,12 +27,12 @@ export class RouteRecognizer { matchers: Map; constructor() { - this.names = MapWrapper.create(); - this.matchers = MapWrapper.create(); - this.redirects = MapWrapper.create(); + this.names = new Map(); + this.matchers = new Map(); + this.redirects = new Map(); } - addRedirect(path: string, target: string): void { MapWrapper.set(this.redirects, path, target); } + addRedirect(path: string, target: string): void { this.redirects.set(path, target); } addConfig(path: string, handler: any, alias: string = null): void { var recognizer = new PathRecognizer(path, handler); @@ -42,9 +42,9 @@ export class RouteRecognizer { `Configuration '${path}' conflicts with existing route '${matcher.path}'`); } }); - MapWrapper.set(this.matchers, recognizer.regex, recognizer); + this.matchers.set(recognizer.regex, recognizer); if (isPresent(alias)) { - MapWrapper.set(this.names, alias, recognizer); + this.names.set(alias, recognizer); } } @@ -93,7 +93,7 @@ export class RouteRecognizer { hasRoute(name: string): boolean { return MapWrapper.contains(this.names, name); } generate(name: string, params: any): string { - var pathRecognizer = MapWrapper.get(this.names, name); + var pathRecognizer = this.names.get(name); return isPresent(pathRecognizer) ? pathRecognizer.generate(params) : null; } } diff --git a/modules/angular2/src/router/route_registry.ts b/modules/angular2/src/router/route_registry.ts index 6a09ac82b1..92a2de95e3 100644 --- a/modules/angular2/src/router/route_registry.ts +++ b/modules/angular2/src/router/route_registry.ts @@ -29,7 +29,7 @@ import {reflector} from 'angular2/src/reflection/reflection'; export class RouteRegistry { _rules: Map; - constructor() { this._rules = MapWrapper.create(); } + constructor() { this._rules = new Map(); } /** * Given a component and a configuration object, add the route to this registry @@ -37,11 +37,11 @@ export class RouteRegistry { config(parentComponent, config: StringMap): void { assertValidConfig(config); - var recognizer: RouteRecognizer = MapWrapper.get(this._rules, parentComponent); + var recognizer: RouteRecognizer = this._rules.get(parentComponent); if (isBlank(recognizer)) { recognizer = new RouteRecognizer(); - MapWrapper.set(this._rules, parentComponent, recognizer); + this._rules.set(parentComponent, recognizer); } if (StringMapWrapper.contains(config, 'redirectTo')) { @@ -90,7 +90,7 @@ export class RouteRegistry { * the application into the state specified by the */ recognize(url: string, parentComponent): Promise { - var componentRecognizer = MapWrapper.get(this._rules, parentComponent); + var componentRecognizer = this._rules.get(parentComponent); if (isBlank(componentRecognizer)) { return PromiseWrapper.resolve(null); } @@ -145,7 +145,7 @@ export class RouteRegistry { generate(name: string, params: StringMap, hostComponent): string { // TODO: implement for hierarchical routes - var componentRecognizer = MapWrapper.get(this._rules, hostComponent); + var componentRecognizer = this._rules.get(hostComponent); return isPresent(componentRecognizer) ? componentRecognizer.generate(name, params) : null; } } diff --git a/modules/angular2/src/test_lib/test_component_builder.ts b/modules/angular2/src/test_lib/test_component_builder.ts index c6a2dc45f4..c8a44b88ad 100644 --- a/modules/angular2/src/test_lib/test_component_builder.ts +++ b/modules/angular2/src/test_lib/test_component_builder.ts @@ -59,9 +59,9 @@ export class TestComponentBuilder { constructor(injector: Injector) { this._injector = injector; - this._viewOverrides = MapWrapper.create(); - this._directiveOverrides = MapWrapper.create(); - this._templateOverrides = MapWrapper.create(); + this._viewOverrides = new Map(); + this._directiveOverrides = new Map(); + this._templateOverrides = new Map(); } _clone(): TestComponentBuilder { @@ -83,7 +83,7 @@ export class TestComponentBuilder { */ overrideTemplate(componentType: Type, template: string): TestComponentBuilder { var clone = this._clone(); - MapWrapper.set(clone._templateOverrides, componentType, template); + clone._templateOverrides.set(componentType, template); return clone; } @@ -97,7 +97,7 @@ export class TestComponentBuilder { */ overrideView(componentType: Type, view: View): TestComponentBuilder { var clone = this._clone(); - MapWrapper.set(clone._viewOverrides, componentType, view); + clone._viewOverrides.set(componentType, view); return clone; } @@ -112,12 +112,12 @@ export class TestComponentBuilder { */ overrideDirective(componentType: Type, from: Type, to: Type): TestComponentBuilder { var clone = this._clone(); - var overridesForComponent = MapWrapper.get(clone._directiveOverrides, componentType); + var overridesForComponent = clone._directiveOverrides.get(componentType); if (!isPresent(overridesForComponent)) { - MapWrapper.set(clone._directiveOverrides, componentType, MapWrapper.create()); - overridesForComponent = MapWrapper.get(clone._directiveOverrides, componentType); + clone._directiveOverrides.set(componentType, new Map()); + overridesForComponent = clone._directiveOverrides.get(componentType); } - MapWrapper.set(overridesForComponent, from, to); + overridesForComponent.set(from, to); return clone; } diff --git a/modules/angular2/src/test_lib/utils.ts b/modules/angular2/src/test_lib/utils.ts index bc45a0614c..371920ee9b 100644 --- a/modules/angular2/src/test_lib/utils.ts +++ b/modules/angular2/src/test_lib/utils.ts @@ -75,7 +75,7 @@ export function stringifyElement(el): string { ListWrapper.sort(keys); for (let i = 0; i < keys.length; i++) { var key = keys[i]; - var attValue = MapWrapper.get(attributeMap, key); + var attValue = attributeMap.get(key); if (!isString(attValue)) { result += ` ${key}`; } else { diff --git a/modules/angular2/test/change_detection/change_detector_config.ts b/modules/angular2/test/change_detection/change_detector_config.ts index 213565b833..c813fc203d 100644 --- a/modules/angular2/test/change_detection/change_detector_config.ts +++ b/modules/angular2/test/change_detection/change_detector_config.ts @@ -120,8 +120,8 @@ class _ExpressionWithLocals { 'functionFromLocals': new _ExpressionWithLocals( 'key()', new Locals(null, MapWrapper.createFromPairs([['key', () => 'value']]))), 'nestedLocals': new _ExpressionWithLocals( - 'key', new Locals(new Locals(null, MapWrapper.createFromPairs([['key', 'value']])), - MapWrapper.create())), + 'key', + new Locals(new Locals(null, MapWrapper.createFromPairs([['key', 'value']])), new Map())), 'fallbackLocals': new _ExpressionWithLocals( 'name', new Locals(null, MapWrapper.createFromPairs([['key', 'value']]))), 'contextNestedPropertyWithLocals': new _ExpressionWithLocals( diff --git a/modules/angular2/test/change_detection/parser/parser_spec.ts b/modules/angular2/test/change_detection/parser/parser_spec.ts index 68a7e48321..fac5bdfbfb 100644 --- a/modules/angular2/test/change_detection/parser/parser_spec.ts +++ b/modules/angular2/test/change_detection/parser/parser_spec.ts @@ -41,7 +41,7 @@ export function main() { function addPipes(ast, pipes): any { return createParser().addPipes(ast, pipes); } - function emptyLocals() { return new Locals(null, MapWrapper.create()); } + function emptyLocals() { return new Locals(null, new Map()); } function evalAction(text, passedInContext = null, passedInLocals = null) { var c = isBlank(passedInContext) ? td() : passedInContext; @@ -195,14 +195,14 @@ export function main() { it("should handle nested Locals", () => { var nested = new Locals(null, MapWrapper.createFromPairs([["key", "value"]])); - var locals = new Locals(nested, MapWrapper.create()); + var locals = new Locals(nested, new Map()); expectEval("key", null, locals).toEqual("value"); }); it("should fall back to a regular field read when Locals " + "does not have the requested field", () => { - var locals = new Locals(null, MapWrapper.create()); + var locals = new Locals(null, new Map()); expectEval("a", td(999), locals).toEqual(999); }); }); @@ -256,7 +256,7 @@ export function main() { it('should fall back to the parent context when Locals does not ' + 'have the requested method', () => { - var locals = new Locals(null, MapWrapper.create()); + var locals = new Locals(null, new Map()); expectEval("fn()", td(0, 0, 'parent'), locals).toEqual('parent'); }); }); @@ -356,7 +356,7 @@ export function main() { it('should reassign when no variable binding with the given name', () => { var context = td(); - var locals = new Locals(null, MapWrapper.create()); + var locals = new Locals(null, new Map()); expectEval('a = 200', context, locals).toEqual(200); expect(context.a).toEqual(200); }); diff --git a/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts b/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts index 76d2915ffd..2691b36796 100644 --- a/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts +++ b/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts @@ -20,7 +20,7 @@ export function main() { it('should support list and iterables', () => { expect(IterableChanges.supportsObj([])).toBeTruthy(); expect(IterableChanges.supportsObj(new TestIterable())).toBeTruthy(); - expect(IterableChanges.supportsObj(MapWrapper.create())).toBeFalsy(); + expect(IterableChanges.supportsObj(new Map())).toBeFalsy(); expect(IterableChanges.supportsObj(null)).toBeFalsy(); }); diff --git a/modules/angular2/test/change_detection/pipes/keyvalue_changes_spec.ts b/modules/angular2/test/change_detection/pipes/keyvalue_changes_spec.ts index 967fef6a2b..ac4b7ac3a3 100644 --- a/modules/angular2/test/change_detection/pipes/keyvalue_changes_spec.ts +++ b/modules/angular2/test/change_detection/pipes/keyvalue_changes_spec.ts @@ -9,11 +9,11 @@ export function main() { describe('keyvalue_changes', function() { describe('KeyValueChanges', function() { var changes; - var m; + var m: Map; beforeEach(() => { changes = new KeyValueChanges(); - m = MapWrapper.create(); + m = new Map(); }); afterEach(() => { changes = null; }); @@ -21,12 +21,12 @@ export function main() { it('should detect additions', () => { changes.check(m); - MapWrapper.set(m, 'a', 1); + m.set('a', 1); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString({map: ['a[null->1]'], additions: ['a[null->1]']})); - MapWrapper.set(m, 'b', 2); + m.set('b', 2); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString( @@ -34,12 +34,12 @@ export function main() { }); it('should handle changing key/values correctly', () => { - MapWrapper.set(m, 1, 10); - MapWrapper.set(m, 2, 20); + m.set(1, 10); + m.set(2, 20); changes.check(m); - MapWrapper.set(m, 2, 10); - MapWrapper.set(m, 1, 20); + m.set(2, 10); + m.set(1, 20); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString({ @@ -52,10 +52,10 @@ export function main() { it('should expose previous and current value', () => { var previous, current; - MapWrapper.set(m, 1, 10); + m.set(1, 10); changes.check(m); - MapWrapper.set(m, 1, 20); + m.set(1, 20); changes.check(m); changes.forEachChangedItem((record) => { @@ -70,19 +70,19 @@ export function main() { it('should do basic map watching', () => { changes.check(m); - MapWrapper.set(m, 'a', 'A'); + m.set('a', 'A'); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString({map: ['a[null->A]'], additions: ['a[null->A]']})); - MapWrapper.set(m, 'b', 'B'); + m.set('b', 'B'); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString( {map: ['a', 'b[null->B]'], previous: ['a'], additions: ['b[null->B]']})); - MapWrapper.set(m, 'b', 'BB'); - MapWrapper.set(m, 'd', 'D'); + m.set('b', 'BB'); + m.set('d', 'D'); changes.check(m); expect(changes.toString()) .toEqual(kvChangesAsString({ @@ -106,7 +106,7 @@ export function main() { }); it('should test string by value rather than by reference (DART)', () => { - MapWrapper.set(m, 'foo', 'bar'); + m.set('foo', 'bar'); changes.check(m); var f = 'f'; @@ -114,14 +114,14 @@ export function main() { var b = 'b'; var ar = 'ar'; - MapWrapper.set(m, f + oo, b + ar); + m.set(f + oo, b + ar); changes.check(m); expect(changes.toString()).toEqual(kvChangesAsString({map: ['foo'], previous: ['foo']})); }); it('should not see a NaN value as a change (JS)', () => { - MapWrapper.set(m, 'foo', NumberWrapper.NaN); + m.set('foo', NumberWrapper.NaN); changes.check(m); changes.check(m); @@ -139,7 +139,7 @@ export function main() { }); it('should do basic object watching', () => { - m = {}; + let m = {}; changes.check(m); m['a'] = 'A'; diff --git a/modules/angular2/test/core/compiler/compiler_spec.ts b/modules/angular2/test/core/compiler/compiler_spec.ts index 52d4a05273..467bcd9223 100644 --- a/modules/angular2/test/core/compiler/compiler_spec.ts +++ b/modules/angular2/test/core/compiler/compiler_spec.ts @@ -471,7 +471,7 @@ function createDirectiveBinding(directiveResolver, type) { } function createProtoView(elementBinders = null) { - var pv = new AppProtoView(null, null, MapWrapper.create(), null); + var pv = new AppProtoView(null, null, new Map(), null); if (isBlank(elementBinders)) { elementBinders = []; } @@ -581,11 +581,11 @@ class FakeTemplateResolver extends TemplateResolver { constructor() { super(); - this._cmpTemplates = MapWrapper.create(); + this._cmpTemplates = new Map(); } resolve(component: Type): viewAnn.View { - var template = MapWrapper.get(this._cmpTemplates, component); + var template = this._cmpTemplates.get(component); if (isBlank(template)) { // dynamic component return null; @@ -593,9 +593,7 @@ class FakeTemplateResolver extends TemplateResolver { return template; } - setView(component: Type, template: viewAnn.View) { - MapWrapper.set(this._cmpTemplates, component, template); - } + setView(component: Type, template: viewAnn.View) { this._cmpTemplates.set(component, template); } } class FakeProtoViewFactory extends ProtoViewFactory { diff --git a/modules/angular2/test/core/compiler/element_injector_spec.ts b/modules/angular2/test/core/compiler/element_injector_spec.ts index 7505c582f2..2871ec2c46 100644 --- a/modules/angular2/test/core/compiler/element_injector_spec.ts +++ b/modules/angular2/test/core/compiler/element_injector_spec.ts @@ -879,9 +879,9 @@ export function main() { describe('static attributes', () => { it('should be injectable', () => { - var attributes = MapWrapper.create(); - MapWrapper.set(attributes, 'type', 'text'); - MapWrapper.set(attributes, 'title', ''); + var attributes = new Map(); + attributes.set( 'type', 'text'); + attributes.set( 'title', ''); var inj = injector(ListWrapper.concat([NeedsAttribute], extraBindings), null, false, null, attributes); @@ -893,8 +893,8 @@ export function main() { }); it('should be injectable without type annotation', () => { - var attributes = MapWrapper.create(); - MapWrapper.set(attributes, 'foo', 'bar'); + var attributes = new Map(); + attributes.set( 'foo', 'bar'); var inj = injector(ListWrapper.concat([NeedsAttributeNoType], extraBindings), null, false, null, attributes); diff --git a/modules/angular2/test/core/compiler/proto_view_factory_spec.ts b/modules/angular2/test/core/compiler/proto_view_factory_spec.ts index aec9d94b6c..6f9c823493 100644 --- a/modules/angular2/test/core/compiler/proto_view_factory_spec.ts +++ b/modules/angular2/test/core/compiler/proto_view_factory_spec.ts @@ -131,7 +131,7 @@ export function main() { it("should not throw when not binding to a name exported by two directives", () => { expect(() => { createDirectiveVariableBindings( - new renderApi.ElementBinder({variableBindings: MapWrapper.create()}), [ + new renderApi.ElementBinder({variableBindings: new Map()}), [ directiveBinding( {metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}), directiveBinding( @@ -167,7 +167,7 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType = elementBinders = []; } return new renderApi.ProtoViewDto( - {elementBinders: elementBinders, type: type, variableBindings: MapWrapper.create()}); + {elementBinders: elementBinders, type: type, variableBindings: new Map()}); } function createRenderComponentElementBinder(directiveIndex) { diff --git a/modules/angular2/test/core/compiler/view_container_ref_spec.ts b/modules/angular2/test/core/compiler/view_container_ref_spec.ts index b1d7c88687..c228a349b9 100644 --- a/modules/angular2/test/core/compiler/view_container_ref_spec.ts +++ b/modules/angular2/test/core/compiler/view_container_ref_spec.ts @@ -37,7 +37,7 @@ export function main() { function createProtoView() { return new AppProtoView(null, null, null, null); } - function createView() { return new AppView(null, createProtoView(), MapWrapper.create()); } + function createView() { return new AppView(null, createProtoView(), new Map()); } function createViewContainer() { return new ViewContainerRef(viewManager, location); } diff --git a/modules/angular2/test/core/compiler/view_manager_spec.ts b/modules/angular2/test/core/compiler/view_manager_spec.ts index f76824d49c..867628b608 100644 --- a/modules/angular2/test/core/compiler/view_manager_spec.ts +++ b/modules/angular2/test/core/compiler/view_manager_spec.ts @@ -100,7 +100,7 @@ export function main() { if (isBlank(renderViewRef)) { renderViewRef = new RenderViewRef(); } - var view = new AppView(renderer, pv, MapWrapper.create()); + var view = new AppView(renderer, pv, new Map()); view.render = renderViewRef; var elementInjectors = ListWrapper.createFixedSize(pv.elementBinders.length); for (var i = 0; i < pv.elementBinders.length; i++) { diff --git a/modules/angular2/test/core/compiler/view_manager_utils_spec.ts b/modules/angular2/test/core/compiler/view_manager_utils_spec.ts index e4354b61c7..c5c99d0fbe 100644 --- a/modules/angular2/test/core/compiler/view_manager_utils_spec.ts +++ b/modules/angular2/test/core/compiler/view_manager_utils_spec.ts @@ -86,7 +86,7 @@ export function main() { if (isBlank(pv)) { pv = createProtoView(); } - var view = new AppView(null, pv, MapWrapper.create()); + var view = new AppView(null, pv, new Map()); var elementInjectors = ListWrapper.createFixedSize(pv.elementBinders.length); var preBuiltObjects = ListWrapper.createFixedSize(pv.elementBinders.length); for (var i = 0; i < pv.elementBinders.length; i++) { diff --git a/modules/angular2/test/core/compiler/view_pool_spec.ts b/modules/angular2/test/core/compiler/view_pool_spec.ts index 2533434b31..abfbb61c78 100644 --- a/modules/angular2/test/core/compiler/view_pool_spec.ts +++ b/modules/angular2/test/core/compiler/view_pool_spec.ts @@ -26,7 +26,7 @@ export function main() { function createProtoView() { return new AppProtoView(null, null, null, null); } - function createView(pv) { return new AppView(null, pv, MapWrapper.create()); } + function createView(pv) { return new AppView(null, pv, new Map()); } it('should support multiple AppProtoViews', () => { var vf = createViewPool({capacity: 2}); diff --git a/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts b/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts index 695eaab17a..bfb5be6567 100644 --- a/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts +++ b/modules/angular2/test/render/dom/compiler/compiler_common_tests.ts @@ -34,7 +34,7 @@ export function runCompilerCommonTests() { function createCompiler(processClosure, urlData = null) { if (isBlank(urlData)) { - urlData = MapWrapper.create(); + urlData = new Map(); } var tplLoader = new FakeTemplateLoader(urlData); mockStepFactory = new MockStepFactory([new MockStep(processClosure)]); @@ -99,7 +99,7 @@ export function runCompilerCommonTests() { })); it('should report loading errors', inject([AsyncTestCompleter], (async) => { - var compiler = createCompiler(EMPTY_STEP, MapWrapper.create()); + var compiler = createCompiler(EMPTY_STEP, new Map()); PromiseWrapper.catchError( compiler.compile( new ViewDefinition({componentId: 'someId', templateAbsUrl: 'someUrl'})), @@ -209,7 +209,7 @@ class FakeTemplateLoader extends TemplateLoader { } if (isPresent(template.templateAbsUrl)) { - var content = MapWrapper.get(this._urlData, template.templateAbsUrl); + var content = this._urlData.get(template.templateAbsUrl); return isPresent(content) ? PromiseWrapper.resolve(DOM.createTemplate(content)) : PromiseWrapper.reject(`Failed to fetch url "${template.templateAbsUrl}"`, null); diff --git a/modules/angular2/test/render/dom/compiler/directive_parser_spec.ts b/modules/angular2/test/render/dom/compiler/directive_parser_spec.ts index f8c24db235..e5edf160c0 100644 --- a/modules/angular2/test/render/dom/compiler/directive_parser_spec.ts +++ b/modules/angular2/test/render/dom/compiler/directive_parser_spec.ts @@ -83,16 +83,15 @@ export function main() { var results = process(el('
'), {'elProp': parser.parseBinding('someExpr', '')}); var directiveBinding = results[0].directives[0]; - expect(MapWrapper.get(directiveBinding.propertyBindings, 'dirProp').source) - .toEqual('someExpr'); + expect(directiveBinding.propertyBindings.get('dirProp').source).toEqual('someExpr'); }); it('should bind directive properties with pipes', () => { var results = process(el('
'), {'elProp': parser.parseBinding('someExpr', '')}); var directiveBinding = results[0].directives[0]; - var pipedProp = MapWrapper.get(directiveBinding.propertyBindings, 'doubleProp'); - var simpleProp = MapWrapper.get(directiveBinding.propertyBindings, 'dirProp'); + var pipedProp = directiveBinding.propertyBindings.get('doubleProp'); + var simpleProp = directiveBinding.propertyBindings.get('dirProp'); expect(pipedProp.ast.name).toEqual('double'); expect(pipedProp.ast.exp).toEqual(simpleProp.ast); expect(simpleProp.source).toEqual('someExpr'); @@ -101,7 +100,7 @@ export function main() { it('should bind directive properties from attribute values', () => { var results = process(el('
')); var directiveBinding = results[0].directives[0]; - var simpleProp = MapWrapper.get(directiveBinding.propertyBindings, 'dirProp'); + var simpleProp = directiveBinding.propertyBindings.get('dirProp'); expect(simpleProp.source).toEqual('someValue'); }); @@ -111,7 +110,7 @@ export function main() { var directiveBinding = results[0].directives[0]; - var ast = MapWrapper.get(directiveBinding.hostPropertyBindings, 'hostProp'); + var ast = directiveBinding.hostPropertyBindings.get('hostProp'); expect(ast.source).toEqual('dirProp'); }); @@ -145,7 +144,7 @@ export function main() { it('should read attribute values', () => { var element = el(''); var results = process(element); - expect(MapWrapper.get(results[0].readAttributes, 'some-attr')).toEqual('someValue'); + expect(results[0].readAttributes.get('some-attr')).toEqual('someValue'); }); it('should bind directive events', () => { diff --git a/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.ts b/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.ts index 9719f6c45e..e052d6ada1 100644 --- a/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.ts +++ b/modules/angular2/test/render/dom/compiler/property_binding_parser_spec.ts @@ -9,7 +9,7 @@ import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control'; import {Lexer, Parser} from 'angular2/change_detection'; import {ElementBinderBuilder} from 'angular2/src/render/dom/view/proto_view_builder'; -var EMPTY_MAP = MapWrapper.create(); +var EMPTY_MAP = new Map(); export function main() { describe('PropertyBindingParser', () => { @@ -31,7 +31,7 @@ export function main() { it('should detect [] syntax', () => { var results = process(el('
')); - expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('b'); + expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect [] syntax only if an attribute name starts and ends with []', () => { @@ -41,7 +41,7 @@ export function main() { it('should detect bind- syntax', () => { var results = process(el('
')); - expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('b'); + expect(results[0].propertyBindings.get('a').source).toEqual('b'); }); it('should detect bind- syntax only if an attribute name starts with bind', @@ -49,53 +49,51 @@ export function main() { it('should detect interpolation syntax', () => { var results = process(el('
')); - expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('{{b}}'); + expect(results[0].propertyBindings.get('a').source).toEqual('{{b}}'); }); it('should store property setters as camel case', () => { var element = el('
'); var results = process(element); - expect(MapWrapper.get(results[0].propertyBindings, 'someProp')).toBeTruthy(); + expect(results[0].propertyBindings.get('someProp')).toBeTruthy(); }); it('should detect var- syntax', () => { var results = process(el('')); - expect(MapWrapper.get(results[0].variableBindings, 'b')).toEqual('a'); + expect(results[0].variableBindings.get('b')).toEqual('a'); }); it('should store variable binding for a template element on the nestedProtoView', () => { var results = process(el('