feat: remove MapWrapper.create()/get()/set().

Better dart2js code, better Angular code.
This commit is contained in:
Martin Probst
2015-06-17 16:21:40 -07:00
parent 35e882e74f
commit be7ac9fd41
67 changed files with 388 additions and 418 deletions

View File

@ -1,5 +1,5 @@
import {isPresent} from 'angular2/src/facade/lang'; 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'; import {RecordType, ProtoRecord} from './proto_record';
/** /**
@ -14,7 +14,7 @@ import {RecordType, ProtoRecord} from './proto_record';
*/ */
export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> { export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
var res: List<ProtoRecord> = []; var res: List<ProtoRecord> = [];
var indexMap: Map<number, number> = MapWrapper.create(); var indexMap: Map<number, number> = new Map<number, number>();
for (var i = 0; i < records.length; ++i) { for (var i = 0; i < records.length; ++i) {
var r = records[i]; var r = records[i];
@ -23,14 +23,14 @@ export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
if (isPresent(matchingRecord) && record.lastInBinding) { if (isPresent(matchingRecord) && record.lastInBinding) {
res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1)); 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) { } else if (isPresent(matchingRecord) && !record.lastInBinding) {
MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex); indexMap.set(r.selfIndex, matchingRecord.selfIndex);
} else { } else {
res.push(record); 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<any, a
} }
function _map(indexMap: Map<any, any>, value: number) { function _map(indexMap: Map<any, any>, value: number) {
var r = MapWrapper.get(indexMap, value); var r = indexMap.get(value);
return isPresent(r) ? r : value; return isPresent(r) ? r : value;
} }

View File

@ -18,7 +18,7 @@ export class Locals {
get(name: string) { get(name: string) {
if (MapWrapper.contains(this.current, name)) { if (MapWrapper.contains(this.current, name)) {
return MapWrapper.get(this.current, name); return this.current.get(name);
} }
if (isPresent(this.parent)) { if (isPresent(this.parent)) {
@ -33,7 +33,7 @@ export class Locals {
// exposed to the public API. // exposed to the public API.
// TODO: vsavkin maybe it should check only the local map // TODO: vsavkin maybe it should check only the local map
if (MapWrapper.contains(this.current, name)) { if (MapWrapper.contains(this.current, name)) {
MapWrapper.set(this.current, name, value); this.current.set(name, value);
} else { } else {
throw new BaseException( throw new BaseException(
`Setting of new keys post-construction is not supported. Key: ${name}.`); `Setting of new keys post-construction is not supported. Key: ${name}.`);

View File

@ -574,16 +574,16 @@ class _DuplicateItemRecordList {
} }
class _DuplicateMap { class _DuplicateMap {
map: Map<any, _DuplicateItemRecordList> = MapWrapper.create(); map: Map<any, _DuplicateItemRecordList> = new Map();
put(record: CollectionChangeRecord) { put(record: CollectionChangeRecord) {
// todo(vicb) handle corner cases // todo(vicb) handle corner cases
var key = getMapKey(record.item); var key = getMapKey(record.item);
var duplicates = MapWrapper.get(this.map, key); var duplicates = this.map.get(key);
if (!isPresent(duplicates)) { if (!isPresent(duplicates)) {
duplicates = new _DuplicateItemRecordList(); duplicates = new _DuplicateItemRecordList();
MapWrapper.set(this.map, key, duplicates); this.map.set(key, duplicates);
} }
duplicates.add(record); duplicates.add(record);
} }
@ -598,7 +598,7 @@ class _DuplicateMap {
get(value, afterIndex = null): CollectionChangeRecord { get(value, afterIndex = null): CollectionChangeRecord {
var key = getMapKey(value); 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); return isBlank(recordList) ? null : recordList.get(value, afterIndex);
} }
@ -611,7 +611,7 @@ class _DuplicateMap {
var key = getMapKey(record.item); var key = getMapKey(record.item);
// todo(vicb) // todo(vicb)
// assert(this.map.containsKey(key)); // 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 // Remove the list of duplicates when it gets empty
if (recordList.remove(record)) { if (recordList.remove(record)) {
MapWrapper.delete(this.map, key); MapWrapper.delete(this.map, key);

View File

@ -19,7 +19,7 @@ export class KeyValueChangesFactory extends PipeFactory {
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export class KeyValueChanges extends Pipe { export class KeyValueChanges extends Pipe {
private _records: Map<any, any> = MapWrapper.create(); private _records: Map<any, any> = new Map();
private _mapHead: KVChangeRecord = null; private _mapHead: KVChangeRecord = null;
private _previousMapHead: KVChangeRecord = null; private _previousMapHead: KVChangeRecord = null;
private _changesHead: KVChangeRecord = null; private _changesHead: KVChangeRecord = null;
@ -106,10 +106,10 @@ export class KeyValueChanges extends Pipe {
this._addToRemovals(oldSeqRecord); this._addToRemovals(oldSeqRecord);
} }
if (MapWrapper.contains(records, key)) { if (MapWrapper.contains(records, key)) {
newSeqRecord = MapWrapper.get(records, key); newSeqRecord = records.get(key);
} else { } else {
newSeqRecord = new KVChangeRecord(key); newSeqRecord = new KVChangeRecord(key);
MapWrapper.set(records, key, newSeqRecord); records.set(key, newSeqRecord);
newSeqRecord.currentValue = value; newSeqRecord.currentValue = value;
this._addToAdditions(newSeqRecord); this._addToAdditions(newSeqRecord);
} }

View File

@ -32,24 +32,22 @@ import * as renderApi from 'angular2/src/render/api';
*/ */
@Injectable() @Injectable()
export class CompilerCache { export class CompilerCache {
_cache: Map<Type, AppProtoView> = MapWrapper.create(); _cache: Map<Type, AppProtoView> = new Map();
_hostCache: Map<Type, AppProtoView> = MapWrapper.create(); _hostCache: Map<Type, AppProtoView> = new Map();
set(component: Type, protoView: AppProtoView): void { set(component: Type, protoView: AppProtoView): void { this._cache.set(component, protoView); }
MapWrapper.set(this._cache, component, protoView);
}
get(component: Type): AppProtoView { get(component: Type): AppProtoView {
var result = MapWrapper.get(this._cache, component); var result = this._cache.get(component);
return normalizeBlank(result); return normalizeBlank(result);
} }
setHost(component: Type, protoView: AppProtoView): void { setHost(component: Type, protoView: AppProtoView): void {
MapWrapper.set(this._hostCache, component, protoView); this._hostCache.set(component, protoView);
} }
getHost(component: Type): AppProtoView { getHost(component: Type): AppProtoView {
var result = MapWrapper.get(this._hostCache, component); var result = this._hostCache.get(component);
return normalizeBlank(result); return normalizeBlank(result);
} }
@ -79,7 +77,7 @@ export class Compiler {
render: renderApi.RenderCompiler, protoViewFactory: ProtoViewFactory) { render: renderApi.RenderCompiler, protoViewFactory: ProtoViewFactory) {
this._reader = reader; this._reader = reader;
this._compilerCache = cache; this._compilerCache = cache;
this._compiling = MapWrapper.create(); this._compiling = new Map();
this._templateResolver = templateResolver; this._templateResolver = templateResolver;
this._componentUrlMapper = componentUrlMapper; this._componentUrlMapper = componentUrlMapper;
this._urlResolver = urlResolver; this._urlResolver = urlResolver;
@ -132,7 +130,7 @@ export class Compiler {
return protoView; return protoView;
} }
var pvPromise = MapWrapper.get(this._compiling, component); var pvPromise = this._compiling.get(component);
if (isPresent(pvPromise)) { if (isPresent(pvPromise)) {
// The component is already being compiled, attach to the existing Promise // The component is already being compiled, attach to the existing Promise
// instead of re-compiling the component. // instead of re-compiling the component.
@ -160,7 +158,7 @@ export class Compiler {
return this._compileNestedProtoViews(componentBinding, renderPv, boundDirectives); return this._compileNestedProtoViews(componentBinding, renderPv, boundDirectives);
}); });
MapWrapper.set(this._compiling, component, pvPromise); this._compiling.set(component, pvPromise);
return pvPromise; return pvPromise;
} }

View File

@ -16,15 +16,13 @@ export class RuntimeComponentUrlMapper extends ComponentUrlMapper {
constructor() { constructor() {
super(); super();
this._componentUrls = MapWrapper.create(); this._componentUrls = new Map();
} }
setComponentUrl(component: Type, url: string) { setComponentUrl(component: Type, url: string) { this._componentUrls.set(component, url); }
MapWrapper.set(this._componentUrls, component, url);
}
getUrl(component: Type): string { getUrl(component: Type): string {
var url = MapWrapper.get(this._componentUrls, component); var url = this._componentUrls.get(component);
if (isPresent(url)) return url; if (isPresent(url)) return url;
return super.getUrl(component); return super.getUrl(component);
} }

View File

@ -234,7 +234,7 @@ export class DirectiveBinding extends ResolvedBinding {
get hostActions(): Map<string, string> { get hostActions(): Map<string, string> {
return isPresent(this.metadata) && isPresent(this.metadata.hostActions) ? return isPresent(this.metadata) && isPresent(this.metadata.hostActions) ?
this.metadata.hostActions : this.metadata.hostActions :
MapWrapper.create(); new Map();
} }
get changeDetection() { return this.metadata.changeDetection; } get changeDetection() { return this.metadata.changeDetection; }
@ -418,14 +418,14 @@ export class ProtoElementInjector {
private static _createHostInjectorBindingData(dirBindings: List<ResolvedBinding>, private static _createHostInjectorBindingData(dirBindings: List<ResolvedBinding>,
bd: List<BindingData>, bd: List<BindingData>,
firstBindingIsComponent: boolean) { firstBindingIsComponent: boolean) {
var visitedIds: Map<number, boolean> = MapWrapper.create(); var visitedIds: Map<number, boolean> = new Map();
ListWrapper.forEach(dirBindings, dirBinding => { ListWrapper.forEach(dirBindings, dirBinding => {
ListWrapper.forEach(dirBinding.resolvedHostInjectables, b => { ListWrapper.forEach(dirBinding.resolvedHostInjectables, b => {
if (MapWrapper.contains(visitedIds, b.key.id)) { if (MapWrapper.contains(visitedIds, b.key.id)) {
throw new BaseException( throw new BaseException(
`Multiple directives defined the same host injectable: "${stringify(b.key.token)}"`); `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, bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding,
dirBindings, dirBindings,
ProtoElementInjector._createBinding(b))); ProtoElementInjector._createBinding(b)));
@ -734,7 +734,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
} }
getVariableBinding(name: string): any { getVariableBinding(name: string): any {
var index = MapWrapper.get(this._proto.directiveVariableBindings, name); var index = this._proto.directiveVariableBindings.get(name);
return isPresent(index) ? this.getDirectiveAtIndex(<number>index) : this.getElementRef(); return isPresent(index) ? this.getDirectiveAtIndex(<number>index) : this.getElementRef();
} }
@ -892,7 +892,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
private _buildAttribute(dep: DirectiveDependency): string { private _buildAttribute(dep: DirectiveDependency): string {
var attributes = this._proto.attributes; var attributes = this._proto.attributes;
if (isPresent(attributes) && MapWrapper.contains(attributes, dep.attributeName)) { if (isPresent(attributes) && MapWrapper.contains(attributes, dep.attributeName)) {
return MapWrapper.get(attributes, dep.attributeName); return attributes.get(dep.attributeName);
} else { } else {
return null; return null;
} }

View File

@ -20,7 +20,7 @@ import {ElementBinder} from './element_binder';
import {ProtoElementInjector, DirectiveBinding} from './element_injector'; import {ProtoElementInjector, DirectiveBinding} from './element_injector';
class BindingRecordsCreator { class BindingRecordsCreator {
_directiveRecordsMap: Map<number, DirectiveRecord> = MapWrapper.create(); _directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
_textNodeIndex: number = 0; _textNodeIndex: number = 0;
getBindingRecords(elementBinders: List<renderApi.ElementBinder>, getBindingRecords(elementBinders: List<renderApi.ElementBinder>,
@ -116,17 +116,18 @@ class BindingRecordsCreator {
var id = boundElementIndex * 100 + directiveIndex; var id = boundElementIndex * 100 + directiveIndex;
if (!MapWrapper.contains(this._directiveRecordsMap, id)) { if (!MapWrapper.contains(this._directiveRecordsMap, id)) {
MapWrapper.set(this._directiveRecordsMap, id, new DirectiveRecord({ this._directiveRecordsMap.set(
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex), id, new DirectiveRecord({
callOnAllChangesDone: directiveMetadata.callOnAllChangesDone, directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
callOnChange: directiveMetadata.callOnChange, callOnAllChangesDone: directiveMetadata.callOnAllChangesDone,
callOnCheck: directiveMetadata.callOnCheck, callOnChange: directiveMetadata.callOnChange,
callOnInit: directiveMetadata.callOnInit, callOnCheck: directiveMetadata.callOnCheck,
changeDetection: directiveMetadata.changeDetection 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<string, string> { function _createVariableBindings(renderProtoView): Map<string, string> {
var variableBindings = MapWrapper.create(); var variableBindings = new Map();
MapWrapper.forEach(renderProtoView.variableBindings, (mappedName, varName) => { MapWrapper.forEach(renderProtoView.variableBindings,
MapWrapper.set(variableBindings, varName, mappedName); (mappedName, varName) => { variableBindings.set(varName, mappedName); });
});
return variableBindings; return variableBindings;
} }
@ -276,12 +276,11 @@ function _createVariableNames(parentVariableNames, renderProtoView): List<string
export function createVariableLocations( export function createVariableLocations(
elementBinders: List<renderApi.ElementBinder>): Map<string, number> { elementBinders: List<renderApi.ElementBinder>): Map<string, number> {
var variableLocations = MapWrapper.create(); var variableLocations = new Map();
for (var i = 0; i < elementBinders.length; i++) { for (var i = 0; i < elementBinders.length; i++) {
var binder = elementBinders[i]; var binder = elementBinders[i];
MapWrapper.forEach(binder.variableBindings, (mappedName, varName) => { MapWrapper.forEach(binder.variableBindings,
MapWrapper.set(variableLocations, mappedName, i); (mappedName, varName) => { variableLocations.set(mappedName, i); });
});
} }
return variableLocations; return variableLocations;
} }
@ -348,7 +347,7 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE
return protoElementInjector; return protoElementInjector;
} }
function _createElementBinder(protoView, boundElementIndex, renderElementBinder, function _createElementBinder(protoView: AppProtoView, boundElementIndex, renderElementBinder,
protoElementInjector, componentDirectiveBinding, protoElementInjector, componentDirectiveBinding,
directiveBindings): ElementBinder { directiveBindings): ElementBinder {
var parent = null; 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 // 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 // to actually create variable bindings for the $implicit bindings, add to the
// protoLocals manually. // protoLocals manually.
MapWrapper.forEach(renderElementBinder.variableBindings, (mappedName, varName) => { MapWrapper.forEach(renderElementBinder.variableBindings,
MapWrapper.set(protoView.protoLocals, mappedName, null); (mappedName, varName) => { protoView.protoLocals.set(mappedName, null); });
});
return elBinder; return elBinder;
} }
export function createDirectiveVariableBindings( export function createDirectiveVariableBindings(
renderElementBinder: renderApi.ElementBinder, renderElementBinder: renderApi.ElementBinder,
directiveBindings: List<DirectiveBinding>): Map<string, number> { directiveBindings: List<DirectiveBinding>): Map<string, number> {
var directiveVariableBindings = MapWrapper.create(); var directiveVariableBindings = new Map();
MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => { MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => {
var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs); var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs);
MapWrapper.set(directiveVariableBindings, templateName, dirIndex); directiveVariableBindings.set(templateName, dirIndex);
}); });
return directiveVariableBindings; return directiveVariableBindings;
} }

View File

@ -9,14 +9,14 @@ import {reflector} from 'angular2/src/reflection/reflection';
@Injectable() @Injectable()
export class TemplateResolver { export class TemplateResolver {
_cache: Map<Type, /*node*/ any> = MapWrapper.create(); _cache: Map<Type, /*node*/ any> = new Map();
resolve(component: Type): View { resolve(component: Type): View {
var view = MapWrapper.get(this._cache, component); var view = this._cache.get(component);
if (isBlank(view)) { if (isBlank(view)) {
view = this._resolve(component); view = this._resolve(component);
MapWrapper.set(this._cache, component, view); this._cache.set(component, view);
} }
return view; return view;

View File

@ -76,7 +76,7 @@ export class AppView implements ChangeDispatcher, EventDispatcher {
if (!MapWrapper.contains(this.proto.variableBindings, contextName)) { if (!MapWrapper.contains(this.proto.variableBindings, contextName)) {
return; return;
} }
var templateName = MapWrapper.get(this.proto.variableBindings, contextName); var templateName = this.proto.variableBindings.get(contextName);
this.locals.set(templateName, value); this.locals.set(templateName, value);
} }
@ -92,8 +92,8 @@ export class AppView implements ChangeDispatcher, EventDispatcher {
* @param {int} binderIndex * @param {int} binderIndex
*/ */
triggerEventHandlers(eventName: string, eventObj, binderIndex: int): void { triggerEventHandlers(eventName: string, eventObj, binderIndex: int): void {
var locals = MapWrapper.create(); var locals = new Map();
MapWrapper.set(locals, '$event', eventObj); locals.set('$event', eventObj);
this.dispatchEvent(binderIndex, eventName, locals); this.dispatchEvent(binderIndex, eventName, locals);
} }
@ -162,16 +162,15 @@ export class AppView implements ChangeDispatcher, EventDispatcher {
*/ */
export class AppProtoView { export class AppProtoView {
elementBinders: List<ElementBinder> = []; elementBinders: List<ElementBinder> = [];
protoLocals: Map<string, any> = MapWrapper.create(); protoLocals: Map<string, any> = new Map();
constructor(public render: renderApi.RenderProtoViewRef, constructor(public render: renderApi.RenderProtoViewRef,
public protoChangeDetector: ProtoChangeDetector, public protoChangeDetector: ProtoChangeDetector,
public variableBindings: Map<string, string>, public variableBindings: Map<string, string>,
public variableLocations: Map<string, number>) { public variableLocations: Map<string, number>) {
if (isPresent(variableBindings)) { if (isPresent(variableBindings)) {
MapWrapper.forEach(variableBindings, (templateName, _) => { MapWrapper.forEach(variableBindings,
MapWrapper.set(this.protoLocals, templateName, null); (templateName, _) => { this.protoLocals.set(templateName, null); });
});
} }
} }
@ -211,10 +210,10 @@ export class AppProtoView {
var eventName = eventBinding.fullName; var eventName = eventBinding.fullName;
var event = StringMapWrapper.get(events, eventName); var event = StringMapWrapper.get(events, eventName);
if (isBlank(event)) { if (isBlank(event)) {
event = MapWrapper.create(); event = new Map();
StringMapWrapper.set(events, eventName, event); StringMapWrapper.set(events, eventName, event);
} }
MapWrapper.set(event, directiveIndex, eventBinding.source); event.set(directiveIndex, eventBinding.source);
} }
} }
} }

View File

@ -8,7 +8,6 @@ import {Renderer, RenderViewRef} from 'angular2/src/render/api';
import {AppViewManagerUtils} from './view_manager_utils'; import {AppViewManagerUtils} from './view_manager_utils';
import {AppViewPool} from './view_pool'; import {AppViewPool} from './view_pool';
import {AppViewListener} from './view_listener'; 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. * Entry point for creating, moving views in the view hierarchy and destroying views.
@ -42,7 +41,7 @@ export class AppViewManager {
if (isBlank(componentView)) { if (isBlank(componentView)) {
throw new BaseException(`There is no component directive at element ${boundElementIndex}`); 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)) { if (isBlank(elementIndex)) {
throw new BaseException(`Could not find variable ${variableName}`); throw new BaseException(`Could not find variable ${variableName}`);
} }

View File

@ -10,15 +10,14 @@ export const APP_VIEW_POOL_CAPACITY = CONST_EXPR(new OpaqueToken('AppViewPool.vi
@Injectable() @Injectable()
export class AppViewPool { export class AppViewPool {
_poolCapacityPerProtoView: number; _poolCapacityPerProtoView: number;
_pooledViewsPerProtoView: Map<viewModule.AppProtoView, List<viewModule.AppView>> = _pooledViewsPerProtoView: Map<viewModule.AppProtoView, List<viewModule.AppView>> = new Map();
MapWrapper.create();
constructor(@Inject(APP_VIEW_POOL_CAPACITY) poolCapacityPerProtoView) { constructor(@Inject(APP_VIEW_POOL_CAPACITY) poolCapacityPerProtoView) {
this._poolCapacityPerProtoView = poolCapacityPerProtoView; this._poolCapacityPerProtoView = poolCapacityPerProtoView;
} }
getView(protoView: viewModule.AppProtoView): viewModule.AppView { 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) { if (isPresent(pooledViews) && pooledViews.length > 0) {
return ListWrapper.removeLast(pooledViews); return ListWrapper.removeLast(pooledViews);
} }
@ -27,10 +26,10 @@ export class AppViewPool {
returnView(view: viewModule.AppView): boolean { returnView(view: viewModule.AppView): boolean {
var protoView = view.proto; var protoView = view.proto;
var pooledViews = MapWrapper.get(this._pooledViewsPerProtoView, protoView); var pooledViews = this._pooledViewsPerProtoView.get(protoView);
if (isBlank(pooledViews)) { if (isBlank(pooledViews)) {
pooledViews = []; pooledViews = [];
MapWrapper.set(this._pooledViewsPerProtoView, protoView, pooledViews); this._pooledViewsPerProtoView.set(protoView, pooledViews);
} }
var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView; var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView;
if (haveRemainingCapacity) { if (haveRemainingCapacity) {

View File

@ -58,13 +58,13 @@ export class TestabilityRegistry {
_applications: Map<any, Testability>; _applications: Map<any, Testability>;
constructor() { constructor() {
this._applications = MapWrapper.create(); this._applications = new Map();
getTestabilityModule.GetTestability.addToWindow(this); getTestabilityModule.GetTestability.addToWindow(this);
} }
registerApplication(token, testability: Testability) { registerApplication(token, testability: Testability) {
MapWrapper.set(this._applications, token, testability); this._applications.set(token, testability);
} }
findTestabilityInTree(elem): Testability { findTestabilityInTree(elem): Testability {
@ -72,7 +72,7 @@ export class TestabilityRegistry {
return null; return null;
} }
if (MapWrapper.contains(this._applications, elem)) { if (MapWrapper.contains(this._applications, elem)) {
return MapWrapper.get(this._applications, elem); return this._applications.get(elem);
} }
if (DOM.isShadowRoot(elem)) { if (DOM.isShadowRoot(elem)) {
return this.findTestabilityInTree(DOM.getHost(elem)); return this.findTestabilityInTree(DOM.getHost(elem));

View File

@ -20,8 +20,9 @@ var NG_ID_SEPARATOR_RE = RegExpWrapper.create('#');
var NG_ID_SEPARATOR = '#'; var NG_ID_SEPARATOR = '#';
// Need to keep the views in a global Map so that multiple angular apps are supported // Need to keep the views in a global Map so that multiple angular apps are supported
var _allIdsByView: Map<AppView, number> = CONST_EXPR(MapWrapper.create()); var _allIdsByView = new Map<AppView, number>();
var _allViewsById: Map<number, AppView> = CONST_EXPR(MapWrapper.create()); var _allViewsById = new Map<number, AppView>();
var _nextId = 0; var _nextId = 0;
function _setElementId(element, indices: List<number>) { function _setElementId(element, indices: List<number>) {
@ -43,7 +44,7 @@ function _getElementId(element): List<number> {
export function inspectDomElement(element): DebugElement { export function inspectDomElement(element): DebugElement {
var elId = _getElementId(element); var elId = _getElementId(element);
if (isPresent(elId)) { if (isPresent(elId)) {
var view = MapWrapper.get(_allViewsById, elId[0]); var view = _allViewsById.get(elId[0]);
if (isPresent(view)) { if (isPresent(view)) {
return new DebugElement(view, elId[1]); return new DebugElement(view, elId[1]);
} }
@ -57,8 +58,8 @@ export class DebugElementViewListener implements AppViewListener {
viewCreated(view: AppView) { viewCreated(view: AppView) {
var viewId = _nextId++; var viewId = _nextId++;
MapWrapper.set(_allViewsById, viewId, view); _allViewsById.set(viewId, view);
MapWrapper.set(_allIdsByView, view, viewId); _allIdsByView.set(view, viewId);
var renderView = resolveInternalDomView(view.render); var renderView = resolveInternalDomView(view.render);
for (var i = 0; i < renderView.boundElements.length; i++) { for (var i = 0; i < renderView.boundElements.length; i++) {
_setElementId(renderView.boundElements[i].element, [viewId, i]); _setElementId(renderView.boundElements[i].element, [viewId, i]);
@ -66,7 +67,7 @@ export class DebugElementViewListener implements AppViewListener {
} }
viewDestroyed(view: AppView) { viewDestroyed(view: AppView) {
var viewId = MapWrapper.get(_allIdsByView, view); var viewId = _allIdsByView.get(view);
MapWrapper.delete(_allIdsByView, view); MapWrapper.delete(_allIdsByView, view);
MapWrapper.delete(_allViewsById, viewId); MapWrapper.delete(_allViewsById, viewId);
} }

View File

@ -89,7 +89,7 @@ export class Injector {
*/ */
static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> { static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> {
var resolvedBindings = resolveBindings(bindings); var resolvedBindings = resolveBindings(bindings);
var flatten = _flattenBindings(resolvedBindings, MapWrapper.create()); var flatten = _flattenBindings(resolvedBindings, new Map());
return _createListOfBindings(flatten); return _createListOfBindings(flatten);
} }
@ -389,7 +389,7 @@ export function resolveBindings(bindings: List<Type | Binding | List<any>>): Lis
} }
function flattenBindings(bindings: List<ResolvedBinding>): List<ResolvedBinding> { function flattenBindings(bindings: List<ResolvedBinding>): List<ResolvedBinding> {
var map = _flattenBindings(bindings, MapWrapper.create()); var map = _flattenBindings(bindings, new Map());
var res = []; var res = [];
MapWrapper.forEach(map, (binding, keyId) => res.push(binding)); MapWrapper.forEach(map, (binding, keyId) => res.push(binding));
return res; return res;
@ -406,7 +406,7 @@ function _flattenBindings(bindings: List<ResolvedBinding | List<any>>,
res: Map<number, ResolvedBinding>): Map<number, ResolvedBinding> { res: Map<number, ResolvedBinding>): Map<number, ResolvedBinding> {
ListWrapper.forEach(bindings, function(b) { ListWrapper.forEach(bindings, function(b) {
if (b instanceof ResolvedBinding) { if (b instanceof ResolvedBinding) {
MapWrapper.set(res, b.key.id, b); res.set(b.key.id, b);
} else if (b instanceof List) { } else if (b instanceof List) {
_flattenBindings(b, res); _flattenBindings(b, res);
} }

View File

@ -44,7 +44,7 @@ export class Key {
* @private * @private
*/ */
export class KeyRegistry { export class KeyRegistry {
private _allKeys: Map<Object, Key> = MapWrapper.create(); private _allKeys: Map<Object, Key> = new Map();
get(token: Object): Key { get(token: Object): Key {
if (token instanceof Key) return token; if (token instanceof Key) return token;
@ -57,11 +57,11 @@ export class KeyRegistry {
token = theToken; token = theToken;
if (MapWrapper.contains(this._allKeys, token)) { if (MapWrapper.contains(this._allKeys, token)) {
return MapWrapper.get(this._allKeys, token); return this._allKeys.get(token);
} }
var newKey = new Key(token, Key.numberOfKeys); var newKey = new Key(token, Key.numberOfKeys);
MapWrapper.set(this._allKeys, token, newKey); this._allKeys.set(token, newKey);
return newKey; return newKey;
} }

View File

@ -52,7 +52,7 @@ export class NgSwitch {
_activeViews: List<SwitchView>; _activeViews: List<SwitchView>;
constructor() { constructor() {
this._valueViews = MapWrapper.create(); this._valueViews = new Map();
this._activeViews = []; this._activeViews = [];
this._useDefault = false; this._useDefault = false;
} }
@ -63,10 +63,10 @@ export class NgSwitch {
// Add the ViewContainers matching the value (with a fallback to default) // Add the ViewContainers matching the value (with a fallback to default)
this._useDefault = false; this._useDefault = false;
var views = MapWrapper.get(this._valueViews, value); var views = this._valueViews.get(value);
if (isBlank(views)) { if (isBlank(views)) {
this._useDefault = true; this._useDefault = true;
views = normalizeBlank(MapWrapper.get(this._valueViews, _whenDefault)); views = normalizeBlank(this._valueViews.get(_whenDefault));
} }
this._activateViews(views); this._activateViews(views);
@ -92,7 +92,7 @@ export class NgSwitch {
// Switch to default when there is no more active ViewContainers // Switch to default when there is no more active ViewContainers
if (this._activeViews.length === 0 && !this._useDefault) { if (this._activeViews.length === 0 && !this._useDefault) {
this._useDefault = true; 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 { _registerView(value, view: SwitchView): void {
var views = MapWrapper.get(this._valueViews, value); var views = this._valueViews.get(value);
if (isBlank(views)) { if (isBlank(views)) {
views = []; views = [];
MapWrapper.set(this._valueViews, value, views); this._valueViews.set(value, views);
} }
views.push(view); views.push(view);
} }
@ -126,7 +126,7 @@ export class NgSwitch {
_deregisterView(value, view: SwitchView): void { _deregisterView(value, view: SwitchView): void {
// `_whenDefault` is used a marker for non-registered whens // `_whenDefault` is used a marker for non-registered whens
if (value == _whenDefault) return; if (value == _whenDefault) return;
var views = MapWrapper.get(this._valueViews, value); var views = this._valueViews.get(value);
if (views.length == 1) { if (views.length == 1) {
MapWrapper.delete(this._valueViews, value); MapWrapper.delete(this._valueViews, value);
} else { } else {

View File

@ -168,11 +168,11 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
getStyle(element, stylename: string) { return element.style[stylename]; } getStyle(element, stylename: string) { return element.style[stylename]; }
tagName(element): string { return element.tagName; } tagName(element): string { return element.tagName; }
attributeMap(element) { attributeMap(element) {
var res = MapWrapper.create(); var res = new Map();
var elAttrs = element.attributes; var elAttrs = element.attributes;
for (var i = 0; i < elAttrs.length; i++) { for (var i = 0; i < elAttrs.length; i++) {
var attrib = elAttrs[i]; var attrib = elAttrs[i];
MapWrapper.set(res, attrib.name, attrib.value); res.set(attrib.name, attrib.value);
} }
return res; return res;
} }

View File

@ -339,11 +339,11 @@ export class Parse5DomAdapter extends DomAdapter {
} }
tagName(element): string { return element.tagName == "style" ? "STYLE" : element.tagName; } tagName(element): string { return element.tagName == "style" ? "STYLE" : element.tagName; }
attributeMap(element) { attributeMap(element) {
var res = MapWrapper.create(); var res = new Map();
var elAttrs = treeAdapter.getAttrList(element); var elAttrs = treeAdapter.getAttrList(element);
for (var i = 0; i < elAttrs.length; i++) { for (var i = 0; i < elAttrs.length; i++) {
var attrib = elAttrs[i]; var attrib = elAttrs[i];
MapWrapper.set(res, attrib.name, attrib.value); res.set(attrib.name, attrib.value);
} }
return res; return res;
} }

View File

@ -30,17 +30,12 @@ class IterableMap extends IterableBase<List> {
} }
class MapWrapper { class MapWrapper {
static Map create() => {};
static Map clone(Map m) => new Map.from(m); static Map clone(Map m) => new Map.from(m);
static Map createFromStringMap(Map m) => m; static Map createFromStringMap(Map m) => m;
static Map createFromPairs(List pairs) => pairs.fold({}, (m, p) { static Map createFromPairs(List pairs) => pairs.fold({}, (m, p) {
m[p[0]] = p[1]; m[p[0]] = p[1];
return m; 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 contains(Map m, k) => m.containsKey(k);
static forEach(Map m, fn(v, k)) { static forEach(Map m, fn(v, k)) {
m.forEach((k, v) => fn(v, k)); m.forEach((k, v) => fn(v, k));

View File

@ -55,18 +55,15 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
})(); })();
export class MapWrapper { export class MapWrapper {
static create(): Map<any, any> { return new Map(); }
static clone<K, V>(m: Map<K, V>): Map<K, V> { return createMapFromMap(m); } static clone<K, V>(m: Map<K, V>): Map<K, V> { return createMapFromMap(m); }
static createFromStringMap(stringMap): Map<string, any> { static createFromStringMap(stringMap): Map<string, any> {
var result = MapWrapper.create(); var result = new Map();
for (var prop in stringMap) { for (var prop in stringMap) {
MapWrapper.set(result, prop, stringMap[prop]); result.set(prop, stringMap[prop]);
} }
return result; return result;
} }
static createFromPairs(pairs: List<any>): Map<any, any> { return createMapFromPairs(pairs); } static createFromPairs(pairs: List<any>): Map<any, any> { return createMapFromPairs(pairs); }
static get<K, V>(m: Map<K, V>, k: K): V { return m.get(k); }
static set<K, V>(m: Map<K, V>, k: K, v: V) { m.set(k, v); }
static contains<K>(m: Map<K, any>, k: K) { return m.has(k); } static contains<K>(m: Map<K, any>, k: K) { return m.has(k); }
static forEach<K, V>(m: Map<K, V>, fn: /*(V, K) => void*/ Function) { m.forEach(<any>fn); } static forEach<K, V>(m: Map<K, V>, fn: /*(V, K) => void*/ Function) { m.forEach(<any>fn); }
static size(m: Map<any, any>) { return m.size; } static size(m: Map<any, any>) { return m.size; }

View File

@ -23,7 +23,7 @@ export class Headers {
_headersMap: Map<string, List<string>>; _headersMap: Map<string, List<string>>;
constructor(headers?: Headers | Object) { constructor(headers?: Headers | Object) {
if (isBlank(headers)) { if (isBlank(headers)) {
this._headersMap = MapWrapper.create(); this._headersMap = new Map();
return; return;
} }
@ -35,25 +35,23 @@ export class Headers {
if (!isListLikeIterable(v)) { if (!isListLikeIterable(v)) {
var list = []; var list = [];
list.push(v); list.push(v);
MapWrapper.set(this._headersMap, k, list); this._headersMap.set(k, list);
} }
}); });
} }
} }
append(name: string, value: string): void { append(name: string, value: string): void {
var list = MapWrapper.get(this._headersMap, name) || []; var list = this._headersMap.get(name) || [];
list.push(value); list.push(value);
MapWrapper.set(this._headersMap, name, list); this._headersMap.set(name, list);
} }
delete (name: string): void { MapWrapper.delete(this._headersMap, name); } delete (name: string): void { MapWrapper.delete(this._headersMap, name); }
forEach(fn: Function) { return MapWrapper.forEach(this._headersMap, fn); } forEach(fn: Function) { return MapWrapper.forEach(this._headersMap, fn); }
get(header: string): string { get(header: string): string { return ListWrapper.first(this._headersMap.get(header)); }
return ListWrapper.first(MapWrapper.get(this._headersMap, header));
}
has(header: string) { return MapWrapper.contains(this._headersMap, header); } has(header: string) { return MapWrapper.contains(this._headersMap, header); }
@ -68,12 +66,12 @@ export class Headers {
list.push(ListWrapper.toString((<List<string>>value))); list.push(ListWrapper.toString((<List<string>>value)));
} }
MapWrapper.set(this._headersMap, header, list); this._headersMap.set(header, list);
} }
values() { return MapWrapper.values(this._headersMap); } values() { return MapWrapper.values(this._headersMap); }
getAll(header: string): Array<string> { return MapWrapper.get(this._headersMap, header) || []; } getAll(header: string): Array<string> { return this._headersMap.get(header) || []; }
entries() { throw new BaseException('"entries" method is not implemented on Headers class'); } entries() { throw new BaseException('"entries" method is not implemented on Headers class'); }
} }

View File

@ -2,15 +2,15 @@ import {isPresent, isBlank, StringWrapper} from 'angular2/src/facade/lang';
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection'; import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
function paramParser(rawParams: string): Map<string, List<string>> { function paramParser(rawParams: string): Map<string, List<string>> {
var map: Map<string, List<string>> = MapWrapper.create(); var map: Map<string, List<string>> = new Map();
var params: List<string> = StringWrapper.split(rawParams, '&'); var params: List<string> = StringWrapper.split(rawParams, '&');
ListWrapper.forEach(params, (param: string) => { ListWrapper.forEach(params, (param: string) => {
var split: List<string> = StringWrapper.split(param, '='); var split: List<string> = StringWrapper.split(param, '=');
var key = ListWrapper.get(split, 0); var key = ListWrapper.get(split, 0);
var val = ListWrapper.get(split, 1); var val = ListWrapper.get(split, 1);
var list = MapWrapper.get(map, key) || []; var list = map.get(key) || [];
list.push(val); list.push(val);
MapWrapper.set(map, key, list); map.set(key, list);
}); });
return map; return map;
} }
@ -21,14 +21,14 @@ export class URLSearchParams {
has(param: string): boolean { return MapWrapper.contains(this.paramsMap, param); } 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<string> { return MapWrapper.get(this.paramsMap, param) || []; } getAll(param: string): List<string> { return this.paramsMap.get(param) || []; }
append(param: string, val: string): void { append(param: string, val: string): void {
var list = MapWrapper.get(this.paramsMap, param) || []; var list = this.paramsMap.get(param) || [];
list.push(val); list.push(val);
MapWrapper.set(this.paramsMap, param, list); this.paramsMap.set(param, list);
} }
toString(): string { toString(): string {

View File

@ -13,10 +13,10 @@ export class MockTemplateResolver extends TemplateResolver {
constructor() { constructor() {
super(); super();
this._views = MapWrapper.create(); this._views = new Map();
this._inlineTemplates = MapWrapper.create(); this._inlineTemplates = new Map();
this._viewCache = MapWrapper.create(); this._viewCache = new Map();
this._directiveOverrides = MapWrapper.create(); this._directiveOverrides = new Map();
} }
/** /**
@ -27,7 +27,7 @@ export class MockTemplateResolver extends TemplateResolver {
*/ */
setView(component: Type, view: View): void { setView(component: Type, view: View): void {
this._checkOverrideable(component); 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 { setInlineTemplate(component: Type, template: string): void {
this._checkOverrideable(component); 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 { overrideViewDirective(component: Type, from: Type, to: Type): void {
this._checkOverrideable(component); this._checkOverrideable(component);
var overrides = MapWrapper.get(this._directiveOverrides, component); var overrides = this._directiveOverrides.get(component);
if (isBlank(overrides)) { if (isBlank(overrides)) {
overrides = MapWrapper.create(); overrides = new Map();
MapWrapper.set(this._directiveOverrides, component, overrides); 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} * @returns {ViewDefinition}
*/ */
resolve(component: Type): View { resolve(component: Type): View {
var view = MapWrapper.get(this._viewCache, component); var view = this._viewCache.get(component);
if (isPresent(view)) return view; if (isPresent(view)) return view;
view = MapWrapper.get(this._views, component); view = this._views.get(component);
if (isBlank(view)) { if (isBlank(view)) {
view = super.resolve(component); view = super.resolve(component);
} }
var directives = view.directives; var directives = view.directives;
var overrides = MapWrapper.get(this._directiveOverrides, component); var overrides = this._directiveOverrides.get(component);
if (isPresent(overrides) && isPresent(directives)) { if (isPresent(overrides) && isPresent(directives)) {
directives = ListWrapper.clone(view.directives); directives = ListWrapper.clone(view.directives);
@ -98,12 +98,12 @@ export class MockTemplateResolver extends TemplateResolver {
{template: view.template, templateUrl: view.templateUrl, directives: directives}); {template: view.template, templateUrl: view.templateUrl, directives: directives});
} }
var inlineTemplate = MapWrapper.get(this._inlineTemplates, component); var inlineTemplate = this._inlineTemplates.get(component);
if (isPresent(inlineTemplate)) { if (isPresent(inlineTemplate)) {
view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives}); view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives});
} }
MapWrapper.set(this._viewCache, component, view); this._viewCache.set(component, view);
return view; return view;
} }
@ -116,7 +116,7 @@ export class MockTemplateResolver extends TemplateResolver {
* @param {Type} component * @param {Type} component
*/ */
_checkOverrideable(component: Type): void { _checkOverrideable(component: Type): void {
var cached = MapWrapper.get(this._viewCache, component); var cached = this._viewCache.get(component);
if (isPresent(cached)) { if (isPresent(cached)) {
throw new BaseException( throw new BaseException(

View File

@ -20,15 +20,15 @@ export class Reflector {
reflectionCapabilities: PlatformReflectionCapabilities; reflectionCapabilities: PlatformReflectionCapabilities;
constructor(reflectionCapabilities: PlatformReflectionCapabilities) { constructor(reflectionCapabilities: PlatformReflectionCapabilities) {
this._typeInfo = MapWrapper.create(); this._typeInfo = new Map();
this._getters = MapWrapper.create(); this._getters = new Map();
this._setters = MapWrapper.create(); this._setters = new Map();
this._methods = MapWrapper.create(); this._methods = new Map();
this.reflectionCapabilities = reflectionCapabilities; this.reflectionCapabilities = reflectionCapabilities;
} }
registerType(type: Type, typeInfo: StringMap<string, any>): void { registerType(type: Type, typeInfo: StringMap<string, any>): void {
MapWrapper.set(this._typeInfo, type, typeInfo); this._typeInfo.set(type, typeInfo);
} }
registerGetters(getters: StringMap<string, GetterFn>): void { registerGetters(getters: StringMap<string, GetterFn>): void {
@ -77,7 +77,7 @@ export class Reflector {
getter(name: string): GetterFn { getter(name: string): GetterFn {
if (MapWrapper.contains(this._getters, name)) { if (MapWrapper.contains(this._getters, name)) {
return MapWrapper.get(this._getters, name); return this._getters.get(name);
} else { } else {
return this.reflectionCapabilities.getter(name); return this.reflectionCapabilities.getter(name);
} }
@ -85,7 +85,7 @@ export class Reflector {
setter(name: string): SetterFn { setter(name: string): SetterFn {
if (MapWrapper.contains(this._setters, name)) { if (MapWrapper.contains(this._setters, name)) {
return MapWrapper.get(this._setters, name); return this._setters.get(name);
} else { } else {
return this.reflectionCapabilities.setter(name); return this.reflectionCapabilities.setter(name);
} }
@ -93,14 +93,14 @@ export class Reflector {
method(name: string): MethodFn { method(name: string): MethodFn {
if (MapWrapper.contains(this._methods, name)) { if (MapWrapper.contains(this._methods, name)) {
return MapWrapper.get(this._methods, name); return this._methods.get(name);
} else { } else {
return this.reflectionCapabilities.method(name); return this.reflectionCapabilities.method(name);
} }
} }
_getTypeInfoField(typeOrFunc, key, defaultValue) { _getTypeInfoField(typeOrFunc, key, defaultValue) {
var res = MapWrapper.get(this._typeInfo, typeOrFunc)[key]; var res = this._typeInfo.get(typeOrFunc)[key];
return isPresent(res) ? res : defaultValue; return isPresent(res) ? res : defaultValue;
} }
@ -108,5 +108,5 @@ export class Reflector {
} }
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void { function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {
StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v)); StringMapWrapper.forEach(config, (v, k) => target.set(k, v));
} }

View File

@ -205,22 +205,22 @@ export class DirectiveMetadata {
changeDetection?: string, changeDetection?: string,
exportAs?: string exportAs?: string
}) { }) {
let hostListeners = MapWrapper.create(); let hostListeners = new Map();
let hostProperties = MapWrapper.create(); let hostProperties = new Map();
let hostAttributes = MapWrapper.create(); let hostAttributes = new Map();
let hostActions = MapWrapper.create(); let hostActions = new Map();
if (isPresent(host)) { if (isPresent(host)) {
MapWrapper.forEach(host, (value: string, key: string) => { MapWrapper.forEach(host, (value: string, key: string) => {
var matches = RegExpWrapper.firstMatch(hostRegExp, key); var matches = RegExpWrapper.firstMatch(hostRegExp, key);
if (isBlank(matches)) { if (isBlank(matches)) {
MapWrapper.set(hostAttributes, key, value); hostAttributes.set(key, value);
} else if (isPresent(matches[1])) { } else if (isPresent(matches[1])) {
MapWrapper.set(hostProperties, matches[1], value); hostProperties.set(matches[1], value);
} else if (isPresent(matches[2])) { } else if (isPresent(matches[2])) {
MapWrapper.set(hostListeners, matches[2], value); hostListeners.set(matches[2], value);
} else if (isPresent(matches[3])) { } else if (isPresent(matches[3])) {
MapWrapper.set(hostActions, matches[3], value); hostActions.set(matches[3], value);
} }
}); });
} }

View File

@ -83,8 +83,8 @@ function getElementDescription(domElement): string {
buf.add(DOM.tagName(domElement).toLowerCase()); buf.add(DOM.tagName(domElement).toLowerCase());
// show id and class first to ease element identification // show id and class first to ease element identification
addDescriptionAttribute(buf, "id", MapWrapper.get(atts, "id")); addDescriptionAttribute(buf, "id", atts.get("id"));
addDescriptionAttribute(buf, "class", MapWrapper.get(atts, "class")); addDescriptionAttribute(buf, "class", atts.get("class"));
MapWrapper.forEach(atts, (attValue, attName) => { MapWrapper.forEach(atts, (attValue, attName) => {
if (attName !== "id" && attName !== "class") { if (attName !== "id" && attName !== "class") {
addDescriptionAttribute(buf, attName, attValue); addDescriptionAttribute(buf, attName, attValue);

View File

@ -135,11 +135,10 @@ export class DirectiveParser implements CompileStep {
pipes = []; pipes = [];
} }
var bindingAst = var bindingAst = compileElement.bindElement().propertyBindings.get(dashCaseToCamelCase(elProp));
MapWrapper.get(compileElement.bindElement().propertyBindings, dashCaseToCamelCase(elProp));
if (isBlank(bindingAst)) { if (isBlank(bindingAst)) {
var attributeValue = MapWrapper.get(compileElement.attrs(), camelCaseToDashCase(elProp)); var attributeValue = compileElement.attrs().get(camelCaseToDashCase(elProp));
if (isPresent(attributeValue)) { if (isPresent(attributeValue)) {
bindingAst = bindingAst =
this._parser.wrapLiteralPrimitive(attributeValue, compileElement.elementDescription); this._parser.wrapLiteralPrimitive(attributeValue, compileElement.elementDescription);

View File

@ -27,7 +27,7 @@ export class PropertyBindingParser implements CompileStep {
process(parent: CompileElement, current: CompileElement, control: CompileControl) { process(parent: CompileElement, current: CompileElement, control: CompileControl) {
var attrs = current.attrs(); var attrs = current.attrs();
var newAttrs = MapWrapper.create(); var newAttrs = new Map();
MapWrapper.forEach(attrs, (attrValue, attrName) => { MapWrapper.forEach(attrs, (attrValue, attrName) => {
var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName); var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
@ -66,13 +66,12 @@ export class PropertyBindingParser implements CompileStep {
} }
}); });
MapWrapper.forEach(newAttrs, MapWrapper.forEach(newAttrs, (attrValue, attrName) => { attrs.set(attrName, attrValue); });
(attrValue, attrName) => { MapWrapper.set(attrs, attrName, attrValue); });
} }
_bindVariable(identifier, value, current: CompileElement, newAttrs) { _bindVariable(identifier, value, current: CompileElement, newAttrs: Map<any, any>) {
current.bindElement().bindVariable(dashCaseToCamelCase(identifier), value); current.bindElement().bindVariable(dashCaseToCamelCase(identifier), value);
MapWrapper.set(newAttrs, identifier, value); newAttrs.set(identifier, value);
} }
_bindProperty(name, expression, current: CompileElement, newAttrs) { _bindProperty(name, expression, current: CompileElement, newAttrs) {
@ -80,10 +79,10 @@ export class PropertyBindingParser implements CompileStep {
current, newAttrs); current, newAttrs);
} }
_bindPropertyAst(name, ast, current: CompileElement, newAttrs) { _bindPropertyAst(name, ast, current: CompileElement, newAttrs: Map<any, any>) {
var binder = current.bindElement(); var binder = current.bindElement();
binder.bindProperty(dashCaseToCamelCase(name), ast); binder.bindProperty(dashCaseToCamelCase(name), ast);
MapWrapper.set(newAttrs, name, ast.source); newAttrs.set(name, ast.source);
} }
_bindAssignmentEvent(name, expression, current: CompileElement, newAttrs) { _bindAssignmentEvent(name, expression, current: CompileElement, newAttrs) {

View File

@ -141,12 +141,12 @@ export class SelectorMatcher {
return notMatcher; return notMatcher;
} }
private _elementMap: Map<string, List<SelectorContext>> = MapWrapper.create(); private _elementMap: Map<string, List<SelectorContext>> = new Map();
private _elementPartialMap: Map<string, SelectorMatcher> = MapWrapper.create(); private _elementPartialMap: Map<string, SelectorMatcher> = new Map();
private _classMap: Map<string, List<SelectorContext>> = MapWrapper.create(); private _classMap: Map<string, List<SelectorContext>> = new Map();
private _classPartialMap: Map<string, SelectorMatcher> = MapWrapper.create(); private _classPartialMap: Map<string, SelectorMatcher> = new Map();
private _attrValueMap: Map<string, Map<string, List<SelectorContext>>> = MapWrapper.create(); private _attrValueMap: Map<string, Map<string, List<SelectorContext>>> = new Map();
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = MapWrapper.create(); private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = new Map();
private _listContexts: List<SelectorListContext> = []; private _listContexts: List<SelectorListContext> = [];
addSelectables(cssSelectors: List<CssSelector>, callbackCtxt?: any) { addSelectables(cssSelectors: List<CssSelector>, callbackCtxt?: any) {
@ -201,18 +201,18 @@ export class SelectorMatcher {
var attrValue = attrs[index++]; var attrValue = attrs[index++];
if (isTerminal) { if (isTerminal) {
var terminalMap = matcher._attrValueMap; var terminalMap = matcher._attrValueMap;
var terminalValuesMap = MapWrapper.get(terminalMap, attrName); var terminalValuesMap = terminalMap.get(attrName);
if (isBlank(terminalValuesMap)) { if (isBlank(terminalValuesMap)) {
terminalValuesMap = MapWrapper.create(); terminalValuesMap = new Map();
MapWrapper.set(terminalMap, attrName, terminalValuesMap); terminalMap.set(attrName, terminalValuesMap);
} }
this._addTerminal(terminalValuesMap, attrValue, selectable); this._addTerminal(terminalValuesMap, attrValue, selectable);
} else { } else {
var parttialMap = matcher._attrValuePartialMap; var parttialMap = matcher._attrValuePartialMap;
var partialValuesMap = MapWrapper.get(parttialMap, attrName); var partialValuesMap = parttialMap.get(attrName);
if (isBlank(partialValuesMap)) { if (isBlank(partialValuesMap)) {
partialValuesMap = MapWrapper.create(); partialValuesMap = new Map();
MapWrapper.set(parttialMap, attrName, partialValuesMap); parttialMap.set(attrName, partialValuesMap);
} }
matcher = this._addPartial(partialValuesMap, attrValue); matcher = this._addPartial(partialValuesMap, attrValue);
} }
@ -222,19 +222,19 @@ export class SelectorMatcher {
private _addTerminal(map: Map<string, List<SelectorContext>>, name: string, private _addTerminal(map: Map<string, List<SelectorContext>>, name: string,
selectable: SelectorContext) { selectable: SelectorContext) {
var terminalList = MapWrapper.get(map, name); var terminalList = map.get(name);
if (isBlank(terminalList)) { if (isBlank(terminalList)) {
terminalList = []; terminalList = [];
MapWrapper.set(map, name, terminalList); map.set(name, terminalList);
} }
terminalList.push(selectable); terminalList.push(selectable);
} }
private _addPartial(map: Map<string, SelectorMatcher>, name: string): SelectorMatcher { private _addPartial(map: Map<string, SelectorMatcher>, name: string): SelectorMatcher {
var matcher = MapWrapper.get(map, name); var matcher = map.get(name);
if (isBlank(matcher)) { if (isBlank(matcher)) {
matcher = new SelectorMatcher(); matcher = new SelectorMatcher();
MapWrapper.set(map, name, matcher); map.set(name, matcher);
} }
return matcher; return matcher;
} }
@ -276,7 +276,7 @@ export class SelectorMatcher {
var attrName = attrs[index++]; var attrName = attrs[index++];
var attrValue = 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)) { if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector, result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector,
matchedCallback) || matchedCallback) ||
@ -285,7 +285,7 @@ export class SelectorMatcher {
result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) || result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) ||
result; result;
var partialValuesMap = MapWrapper.get(this._attrValuePartialMap, attrName); var partialValuesMap = this._attrValuePartialMap.get(attrName);
if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) { if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector, result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector,
matchedCallback) || matchedCallback) ||
@ -304,8 +304,8 @@ export class SelectorMatcher {
return false; return false;
} }
var selectables = MapWrapper.get(map, name); var selectables = map.get(name);
var starSelectables = MapWrapper.get(map, "*"); var starSelectables = map.get("*");
if (isPresent(starSelectables)) { if (isPresent(starSelectables)) {
selectables = ListWrapper.concat(selectables, starSelectables); selectables = ListWrapper.concat(selectables, starSelectables);
} }
@ -326,7 +326,7 @@ export class SelectorMatcher {
if (isBlank(map) || isBlank(name)) { if (isBlank(map) || isBlank(name)) {
return false; return false;
} }
var nestedSelector = MapWrapper.get(map, name); var nestedSelector = map.get(name);
if (isBlank(nestedSelector)) { if (isBlank(nestedSelector)) {
return false; return false;
} }

View File

@ -15,7 +15,7 @@ import {UrlResolver} from 'angular2/src/services/url_resolver';
*/ */
@Injectable() @Injectable()
export class TemplateLoader { export class TemplateLoader {
_cache: Map<string, Promise<string>> = MapWrapper.create(); _cache: Map<string, Promise<string>> = new Map();
constructor(private _xhr: XHR, urlResolver: UrlResolver) {} constructor(private _xhr: XHR, urlResolver: UrlResolver) {}
@ -52,7 +52,7 @@ export class TemplateLoader {
} }
private _loadText(url: string): Promise<string> { private _loadText(url: string): Promise<string> {
var response = MapWrapper.get(this._cache, url); var response = this._cache.get(url);
if (isBlank(response)) { if (isBlank(response)) {
// TODO(vicb): change error when TS gets fixed // TODO(vicb): change error when TS gets fixed
@ -62,7 +62,7 @@ export class TemplateLoader {
this._xhr.get(url), this._xhr.get(url),
_ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null)); _ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null));
MapWrapper.set(this._cache, url, response); this._cache.set(url, response);
} }
return response; return response;

View File

@ -30,7 +30,7 @@ export class ViewSplitter implements CompileStep {
process(parent: CompileElement, current: CompileElement, control: CompileControl) { process(parent: CompileElement, current: CompileElement, control: CompileControl) {
var attrs = current.attrs(); var attrs = current.attrs();
var templateBindings = MapWrapper.get(attrs, 'template'); var templateBindings = attrs.get('template');
var hasTemplateBinding = isPresent(templateBindings); var hasTemplateBinding = isPresent(templateBindings);
// look for template shortcuts such as *ng-if="condition" and treat them as template="if // 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]; var binding = bindings[i];
if (binding.keyIsVar) { if (binding.keyIsVar) {
compileElement.bindElement().bindVariable(dashCaseToCamelCase(binding.key), binding.name); 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)) { } else if (isPresent(binding.expression)) {
compileElement.bindElement().bindProperty(dashCaseToCamelCase(binding.key), compileElement.bindElement().bindProperty(dashCaseToCamelCase(binding.key),
binding.expression); binding.expression);
MapWrapper.set(compileElement.attrs(), binding.key, binding.expression.source); compileElement.attrs().set(binding.key, binding.expression.source);
} else { } else {
DOM.setAttribute(compileElement.element, binding.key, ''); DOM.setAttribute(compileElement.element, binding.key, '');
} }

View File

@ -37,24 +37,24 @@ export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any
*/ */
export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata { export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata {
return new DirectiveMetadata({ return new DirectiveMetadata({
id:<string>MapWrapper.get(map, 'id'), id:<string>map.get('id'),
selector:<string>MapWrapper.get(map, 'selector'), selector:<string>map.get('selector'),
compileChildren:<boolean>MapWrapper.get(map, 'compileChildren'), compileChildren:<boolean>map.get('compileChildren'),
hostProperties:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostProperties')), hostProperties:<Map<string, string>>_cloneIfPresent(map.get('hostProperties')),
hostListeners:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostListeners')), hostListeners:<Map<string, string>>_cloneIfPresent(map.get('hostListeners')),
hostActions:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostActions')), hostActions:<Map<string, string>>_cloneIfPresent(map.get('hostActions')),
hostAttributes:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostAttributes')), hostAttributes:<Map<string, string>>_cloneIfPresent(map.get('hostAttributes')),
properties:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'properties')), properties:<List<string>>_cloneIfPresent(map.get('properties')),
readAttributes:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'readAttributes')), readAttributes:<List<string>>_cloneIfPresent(map.get('readAttributes')),
type:<number>MapWrapper.get(map, 'type'), type:<number>map.get('type'),
exportAs:<string>MapWrapper.get(map, 'exportAs'), exportAs:<string>map.get('exportAs'),
callOnDestroy:<boolean>MapWrapper.get(map, 'callOnDestroy'), callOnDestroy:<boolean>map.get('callOnDestroy'),
callOnCheck:<boolean>MapWrapper.get(map, 'callOnCheck'), callOnCheck:<boolean>map.get('callOnCheck'),
callOnChange:<boolean>MapWrapper.get(map, 'callOnChange'), callOnChange:<boolean>map.get('callOnChange'),
callOnInit:<boolean>MapWrapper.get(map, 'callOnInit'), callOnInit:<boolean>map.get('callOnInit'),
callOnAllChangesDone:<boolean>MapWrapper.get(map, 'callOnAllChangesDone'), callOnAllChangesDone:<boolean>map.get('callOnAllChangesDone'),
events:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'events')), events:<List<string>>_cloneIfPresent(map.get('events')),
changeDetection:<string>MapWrapper.get(map, 'changeDetection'), changeDetection:<string>map.get('changeDetection'),
}); });
} }

View File

@ -44,7 +44,7 @@ export class ShadowDomCompileStep implements CompileStep {
return; return;
} }
var attrs = current.attrs(); var attrs = current.attrs();
var selector = MapWrapper.get(attrs, 'select'); var selector = attrs.get('select');
selector = isPresent(selector) ? selector : ''; selector = isPresent(selector) ? selector : '';
// The content tag should be replaced by a pair of marker tags (start & end). // The content tag should be replaced by a pair of marker tags (start & end).

View File

@ -5,16 +5,16 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
import {ShadowCss} from './shadow_css'; import {ShadowCss} from './shadow_css';
var _componentUIDs: Map<string, int> = MapWrapper.create(); var _componentUIDs: Map<string, int> = new Map();
var _nextComponentUID: int = 0; var _nextComponentUID: int = 0;
var _sharedStyleTexts: Map<string, boolean> = MapWrapper.create(); var _sharedStyleTexts: Map<string, boolean> = new Map();
var _lastInsertedStyleEl; var _lastInsertedStyleEl;
export function getComponentId(componentStringId: string) { export function getComponentId(componentStringId: string) {
var id = MapWrapper.get(_componentUIDs, componentStringId); var id = _componentUIDs.get(componentStringId);
if (isBlank(id)) { if (isBlank(id)) {
id = _nextComponentUID++; id = _nextComponentUID++;
MapWrapper.set(_componentUIDs, componentStringId, id); _componentUIDs.set(componentStringId, id);
} }
return id; return id;
} }
@ -23,7 +23,7 @@ export function insertSharedStyleText(cssText, styleHost, styleEl) {
if (!MapWrapper.contains(_sharedStyleTexts, cssText)) { if (!MapWrapper.contains(_sharedStyleTexts, cssText)) {
// Styles are unscoped and shared across components, only append them to the head // Styles are unscoped and shared across components, only append them to the head
// when there are not present yet // when there are not present yet
MapWrapper.set(_sharedStyleTexts, cssText, true); _sharedStyleTexts.set(cssText, true);
insertStyleElement(styleHost, styleEl); insertStyleElement(styleHost, styleEl);
} }
} }

View File

@ -20,7 +20,7 @@ import * as api from '../../api';
import {NG_BINDING_CLASS, EVENT_TARGET_SEPARATOR} from '../util'; import {NG_BINDING_CLASS, EVENT_TARGET_SEPARATOR} from '../util';
export class ProtoViewBuilder { export class ProtoViewBuilder {
variableBindings: Map<string, string> = MapWrapper.create(); variableBindings: Map<string, string> = new Map();
elements: List<ElementBinderBuilder> = []; elements: List<ElementBinderBuilder> = [];
constructor(public rootElement, public type: api.ViewType) {} 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". // 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 // When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing
// it. // it.
MapWrapper.set(this.variableBindings, value, name); this.variableBindings.set(value, name);
} }
build(setterFactory: PropertySetterFactory): api.ProtoViewDto { build(setterFactory: PropertySetterFactory): api.ProtoViewDto {
@ -49,20 +49,20 @@ export class ProtoViewBuilder {
var apiElementBinders = []; var apiElementBinders = [];
var transitiveContentTagCount = 0; var transitiveContentTagCount = 0;
ListWrapper.forEach(this.elements, (ebb: ElementBinderBuilder) => { ListWrapper.forEach(this.elements, (ebb: ElementBinderBuilder) => {
var propertySetters = MapWrapper.create(); var propertySetters = new Map();
var hostActions = MapWrapper.create(); var hostActions = new Map();
var apiDirectiveBinders = ListWrapper.map(ebb.directives, (dbb: DirectiveBuilder) => { var apiDirectiveBinders = ListWrapper.map(ebb.directives, (dbb: DirectiveBuilder) => {
ebb.eventBuilder.merge(dbb.eventBuilder); ebb.eventBuilder.merge(dbb.eventBuilder);
MapWrapper.forEach(dbb.hostPropertyBindings, (_, hostPropertyName) => { MapWrapper.forEach(dbb.hostPropertyBindings, (_, hostPropertyName) => {
MapWrapper.set(propertySetters, hostPropertyName, propertySetters.set(hostPropertyName,
setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), setterFactory.createSetter(ebb.element, isPresent(ebb.componentId),
hostPropertyName)); hostPropertyName));
}); });
ListWrapper.forEach(dbb.hostActions, (hostAction) => { ListWrapper.forEach(dbb.hostActions, (hostAction) => {
MapWrapper.set(hostActions, hostAction.actionExpression, hostAction.expression); hostActions.set(hostAction.actionExpression, hostAction.expression);
}); });
return new api.DirectiveBinder({ return new api.DirectiveBinder({
@ -74,8 +74,9 @@ export class ProtoViewBuilder {
}); });
MapWrapper.forEach(ebb.propertyBindings, (_, propertyName) => { MapWrapper.forEach(ebb.propertyBindings, (_, propertyName) => {
MapWrapper.set(
propertySetters, propertyName, propertySetters.set(
propertyName,
setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), propertyName)); setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), propertyName));
}); });
@ -149,14 +150,14 @@ export class ElementBinderBuilder {
distanceToParent: number = 0; distanceToParent: number = 0;
directives: List<DirectiveBuilder> = []; directives: List<DirectiveBuilder> = [];
nestedProtoView: ProtoViewBuilder = null; nestedProtoView: ProtoViewBuilder = null;
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create(); propertyBindings: Map<string, ASTWithSource> = new Map();
variableBindings: Map<string, string> = MapWrapper.create(); variableBindings: Map<string, string> = new Map();
eventBindings: List<api.EventBinding> = []; eventBindings: List<api.EventBinding> = [];
eventBuilder: EventBuilder = new EventBuilder(); eventBuilder: EventBuilder = new EventBuilder();
textBindingIndices: List<number> = []; textBindingIndices: List<number> = [];
textBindings: List<ASTWithSource> = []; textBindings: List<ASTWithSource> = [];
contentTagSelector: string = null; contentTagSelector: string = null;
readAttributes: Map<string, string> = MapWrapper.create(); readAttributes: Map<string, string> = new Map();
componentId: string = null; componentId: string = null;
constructor(public index: number, public element, description: string) {} constructor(public index: number, public element, description: string) {}
@ -170,8 +171,8 @@ export class ElementBinderBuilder {
} }
readAttribute(attrName: string) { readAttribute(attrName: string) {
if (isBlank(MapWrapper.get(this.readAttributes, attrName))) { if (isBlank(this.readAttributes.get(attrName))) {
MapWrapper.set(this.readAttributes, attrName, DOM.getAttribute(this.element, attrName)); this.readAttributes.set(attrName, DOM.getAttribute(this.element, attrName));
} }
} }
@ -189,7 +190,7 @@ export class ElementBinderBuilder {
return this.nestedProtoView; return this.nestedProtoView;
} }
bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); } bindProperty(name, expression) { this.propertyBindings.set(name, expression); }
bindVariable(name, value) { bindVariable(name, value) {
// When current is a view root, the variable bindings are set to the *nested* proto view. // 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 // When this occurs, a lookup keyed by "index" must occur to find if there is a var
// referencing // referencing
// it. // it.
MapWrapper.set(this.variableBindings, value, name); this.variableBindings.set(value, name);
} }
} }
@ -224,19 +225,17 @@ export class ElementBinderBuilder {
} }
export class DirectiveBuilder { export class DirectiveBuilder {
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create(); propertyBindings: Map<string, ASTWithSource> = new Map();
hostPropertyBindings: Map<string, ASTWithSource> = MapWrapper.create(); hostPropertyBindings: Map<string, ASTWithSource> = new Map();
hostActions: List<HostAction> = []; hostActions: List<HostAction> = [];
eventBindings: List<api.EventBinding> = []; eventBindings: List<api.EventBinding> = [];
eventBuilder: EventBuilder = new EventBuilder(); eventBuilder: EventBuilder = new EventBuilder();
constructor(public directiveIndex: number) {} constructor(public directiveIndex: number) {}
bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); } bindProperty(name, expression) { this.propertyBindings.set(name, expression); }
bindHostProperty(name, expression) { bindHostProperty(name, expression) { this.hostPropertyBindings.set(name, expression); }
MapWrapper.set(this.hostPropertyBindings, name, expression);
}
bindHostAction(actionName: string, actionExpression: string, expression: ASTWithSource) { bindHostAction(actionName: string, actionExpression: string, expression: ASTWithSource) {
this.hostActions.push(new HostAction(actionName, actionExpression, expression)); this.hostActions.push(new HostAction(actionName, actionExpression, expression));

View File

@ -40,20 +40,19 @@ export class DomView {
} }
setElementProperty(elementIndex: number, propertyName: string, value: any) { setElementProperty(elementIndex: number, propertyName: string, value: any) {
var setter = var setter = this.proto.elementBinders[elementIndex].propertySetters.get(propertyName);
MapWrapper.get(this.proto.elementBinders[elementIndex].propertySetters, propertyName);
setter(this.boundElements[elementIndex].element, value); setter(this.boundElements[elementIndex].element, value);
} }
callAction(elementIndex: number, actionExpression: string, actionArgs: any) { callAction(elementIndex: number, actionExpression: string, actionArgs: any) {
var binder = this.proto.elementBinders[elementIndex]; 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)); hostAction.eval(this.boundElements[elementIndex].element, this._localsWithAction(actionArgs));
} }
_localsWithAction(action: Object): Locals { _localsWithAction(action: Object): Locals {
var map = MapWrapper.create(); var map = new Map();
MapWrapper.set(map, '$action', action); map.set('$action', action);
return new Locals(null, map); return new Locals(null, map);
} }
@ -62,8 +61,8 @@ export class DomView {
dispatchEvent(elementIndex, eventName, event): boolean { dispatchEvent(elementIndex, eventName, event): boolean {
var allowDefaultBehavior = true; var allowDefaultBehavior = true;
if (isPresent(this.eventDispatcher)) { if (isPresent(this.eventDispatcher)) {
var evalLocals = MapWrapper.create(); var evalLocals = new Map();
MapWrapper.set(evalLocals, '$event', event); evalLocals.set('$event', event);
// TODO(tbosch): reenable this when we are parsing element properties // TODO(tbosch): reenable this when we are parsing element properties
// out of action expressions // out of action expressions
// var localValues = this.proto.elementBinders[elementIndex].eventLocals.eval(null, new // var localValues = this.proto.elementBinders[elementIndex].eventLocals.eval(null, new

View File

@ -11,7 +11,7 @@ export class MockXHR extends XHR {
constructor() { constructor() {
super(); super();
this._expectations = []; this._expectations = [];
this._definitions = MapWrapper.create(); this._definitions = new Map();
this._requests = []; this._requests = [];
} }
@ -26,7 +26,7 @@ export class MockXHR extends XHR {
this._expectations.push(expectation); 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() { flush() {
if (this._requests.length === 0) { if (this._requests.length === 0) {
@ -66,7 +66,7 @@ export class MockXHR extends XHR {
} }
if (MapWrapper.contains(this._definitions, url)) { if (MapWrapper.contains(this._definitions, url)) {
var response = MapWrapper.get(this._definitions, url); var response = this._definitions.get(url);
request.complete(normalizeBlank(response)); request.complete(normalizeBlank(response));
return; return;
} }

View File

@ -27,12 +27,12 @@ export class RouteRecognizer {
matchers: Map<RegExp, PathRecognizer>; matchers: Map<RegExp, PathRecognizer>;
constructor() { constructor() {
this.names = MapWrapper.create(); this.names = new Map();
this.matchers = MapWrapper.create(); this.matchers = new Map();
this.redirects = MapWrapper.create(); 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 { addConfig(path: string, handler: any, alias: string = null): void {
var recognizer = new PathRecognizer(path, handler); var recognizer = new PathRecognizer(path, handler);
@ -42,9 +42,9 @@ export class RouteRecognizer {
`Configuration '${path}' conflicts with existing route '${matcher.path}'`); `Configuration '${path}' conflicts with existing route '${matcher.path}'`);
} }
}); });
MapWrapper.set(this.matchers, recognizer.regex, recognizer); this.matchers.set(recognizer.regex, recognizer);
if (isPresent(alias)) { 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); } hasRoute(name: string): boolean { return MapWrapper.contains(this.names, name); }
generate(name: string, params: any): string { 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; return isPresent(pathRecognizer) ? pathRecognizer.generate(params) : null;
} }
} }

View File

@ -29,7 +29,7 @@ import {reflector} from 'angular2/src/reflection/reflection';
export class RouteRegistry { export class RouteRegistry {
_rules: Map<any, RouteRecognizer>; _rules: Map<any, RouteRecognizer>;
constructor() { this._rules = MapWrapper.create(); } constructor() { this._rules = new Map(); }
/** /**
* Given a component and a configuration object, add the route to this registry * Given a component and a configuration object, add the route to this registry
@ -37,11 +37,11 @@ export class RouteRegistry {
config(parentComponent, config: StringMap<string, any>): void { config(parentComponent, config: StringMap<string, any>): void {
assertValidConfig(config); assertValidConfig(config);
var recognizer: RouteRecognizer = MapWrapper.get(this._rules, parentComponent); var recognizer: RouteRecognizer = this._rules.get(parentComponent);
if (isBlank(recognizer)) { if (isBlank(recognizer)) {
recognizer = new RouteRecognizer(); recognizer = new RouteRecognizer();
MapWrapper.set(this._rules, parentComponent, recognizer); this._rules.set(parentComponent, recognizer);
} }
if (StringMapWrapper.contains(config, 'redirectTo')) { if (StringMapWrapper.contains(config, 'redirectTo')) {
@ -90,7 +90,7 @@ export class RouteRegistry {
* the application into the state specified by the * the application into the state specified by the
*/ */
recognize(url: string, parentComponent): Promise<Instruction> { recognize(url: string, parentComponent): Promise<Instruction> {
var componentRecognizer = MapWrapper.get(this._rules, parentComponent); var componentRecognizer = this._rules.get(parentComponent);
if (isBlank(componentRecognizer)) { if (isBlank(componentRecognizer)) {
return PromiseWrapper.resolve(null); return PromiseWrapper.resolve(null);
} }
@ -145,7 +145,7 @@ export class RouteRegistry {
generate(name: string, params: StringMap<string, string>, hostComponent): string { generate(name: string, params: StringMap<string, string>, hostComponent): string {
// TODO: implement for hierarchical routes // 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; return isPresent(componentRecognizer) ? componentRecognizer.generate(name, params) : null;
} }
} }

View File

@ -59,9 +59,9 @@ export class TestComponentBuilder {
constructor(injector: Injector) { constructor(injector: Injector) {
this._injector = injector; this._injector = injector;
this._viewOverrides = MapWrapper.create(); this._viewOverrides = new Map();
this._directiveOverrides = MapWrapper.create(); this._directiveOverrides = new Map();
this._templateOverrides = MapWrapper.create(); this._templateOverrides = new Map();
} }
_clone(): TestComponentBuilder { _clone(): TestComponentBuilder {
@ -83,7 +83,7 @@ export class TestComponentBuilder {
*/ */
overrideTemplate(componentType: Type, template: string): TestComponentBuilder { overrideTemplate(componentType: Type, template: string): TestComponentBuilder {
var clone = this._clone(); var clone = this._clone();
MapWrapper.set(clone._templateOverrides, componentType, template); clone._templateOverrides.set(componentType, template);
return clone; return clone;
} }
@ -97,7 +97,7 @@ export class TestComponentBuilder {
*/ */
overrideView(componentType: Type, view: View): TestComponentBuilder { overrideView(componentType: Type, view: View): TestComponentBuilder {
var clone = this._clone(); var clone = this._clone();
MapWrapper.set(clone._viewOverrides, componentType, view); clone._viewOverrides.set(componentType, view);
return clone; return clone;
} }
@ -112,12 +112,12 @@ export class TestComponentBuilder {
*/ */
overrideDirective(componentType: Type, from: Type, to: Type): TestComponentBuilder { overrideDirective(componentType: Type, from: Type, to: Type): TestComponentBuilder {
var clone = this._clone(); var clone = this._clone();
var overridesForComponent = MapWrapper.get(clone._directiveOverrides, componentType); var overridesForComponent = clone._directiveOverrides.get(componentType);
if (!isPresent(overridesForComponent)) { if (!isPresent(overridesForComponent)) {
MapWrapper.set(clone._directiveOverrides, componentType, MapWrapper.create()); clone._directiveOverrides.set(componentType, new Map());
overridesForComponent = MapWrapper.get(clone._directiveOverrides, componentType); overridesForComponent = clone._directiveOverrides.get(componentType);
} }
MapWrapper.set(overridesForComponent, from, to); overridesForComponent.set(from, to);
return clone; return clone;
} }

View File

@ -75,7 +75,7 @@ export function stringifyElement(el): string {
ListWrapper.sort(keys); ListWrapper.sort(keys);
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
var key = keys[i]; var key = keys[i];
var attValue = MapWrapper.get(attributeMap, key); var attValue = attributeMap.get(key);
if (!isString(attValue)) { if (!isString(attValue)) {
result += ` ${key}`; result += ` ${key}`;
} else { } else {

View File

@ -120,8 +120,8 @@ class _ExpressionWithLocals {
'functionFromLocals': new _ExpressionWithLocals( 'functionFromLocals': new _ExpressionWithLocals(
'key()', new Locals(null, MapWrapper.createFromPairs([['key', () => 'value']]))), 'key()', new Locals(null, MapWrapper.createFromPairs([['key', () => 'value']]))),
'nestedLocals': new _ExpressionWithLocals( 'nestedLocals': new _ExpressionWithLocals(
'key', new Locals(new Locals(null, MapWrapper.createFromPairs([['key', 'value']])), 'key',
MapWrapper.create())), new Locals(new Locals(null, MapWrapper.createFromPairs([['key', 'value']])), new Map())),
'fallbackLocals': new _ExpressionWithLocals( 'fallbackLocals': new _ExpressionWithLocals(
'name', new Locals(null, MapWrapper.createFromPairs([['key', 'value']]))), 'name', new Locals(null, MapWrapper.createFromPairs([['key', 'value']]))),
'contextNestedPropertyWithLocals': new _ExpressionWithLocals( 'contextNestedPropertyWithLocals': new _ExpressionWithLocals(

View File

@ -41,7 +41,7 @@ export function main() {
function addPipes(ast, pipes): any { return createParser().addPipes(ast, pipes); } 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) { function evalAction(text, passedInContext = null, passedInLocals = null) {
var c = isBlank(passedInContext) ? td() : passedInContext; var c = isBlank(passedInContext) ? td() : passedInContext;
@ -195,14 +195,14 @@ export function main() {
it("should handle nested Locals", () => { it("should handle nested Locals", () => {
var nested = new Locals(null, MapWrapper.createFromPairs([["key", "value"]])); 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"); expectEval("key", null, locals).toEqual("value");
}); });
it("should fall back to a regular field read when Locals " + it("should fall back to a regular field read when Locals " +
"does not have the requested field", "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); 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 ' + it('should fall back to the parent context when Locals does not ' +
'have the requested method', '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'); 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', () => { it('should reassign when no variable binding with the given name', () => {
var context = td(); var context = td();
var locals = new Locals(null, MapWrapper.create()); var locals = new Locals(null, new Map());
expectEval('a = 200', context, locals).toEqual(200); expectEval('a = 200', context, locals).toEqual(200);
expect(context.a).toEqual(200); expect(context.a).toEqual(200);
}); });

View File

@ -20,7 +20,7 @@ export function main() {
it('should support list and iterables', () => { it('should support list and iterables', () => {
expect(IterableChanges.supportsObj([])).toBeTruthy(); expect(IterableChanges.supportsObj([])).toBeTruthy();
expect(IterableChanges.supportsObj(new TestIterable())).toBeTruthy(); expect(IterableChanges.supportsObj(new TestIterable())).toBeTruthy();
expect(IterableChanges.supportsObj(MapWrapper.create())).toBeFalsy(); expect(IterableChanges.supportsObj(new Map())).toBeFalsy();
expect(IterableChanges.supportsObj(null)).toBeFalsy(); expect(IterableChanges.supportsObj(null)).toBeFalsy();
}); });

View File

@ -9,11 +9,11 @@ export function main() {
describe('keyvalue_changes', function() { describe('keyvalue_changes', function() {
describe('KeyValueChanges', function() { describe('KeyValueChanges', function() {
var changes; var changes;
var m; var m: Map<any, any>;
beforeEach(() => { beforeEach(() => {
changes = new KeyValueChanges(); changes = new KeyValueChanges();
m = MapWrapper.create(); m = new Map();
}); });
afterEach(() => { changes = null; }); afterEach(() => { changes = null; });
@ -21,12 +21,12 @@ export function main() {
it('should detect additions', () => { it('should detect additions', () => {
changes.check(m); changes.check(m);
MapWrapper.set(m, 'a', 1); m.set('a', 1);
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString({map: ['a[null->1]'], additions: ['a[null->1]']})); .toEqual(kvChangesAsString({map: ['a[null->1]'], additions: ['a[null->1]']}));
MapWrapper.set(m, 'b', 2); m.set('b', 2);
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString( .toEqual(kvChangesAsString(
@ -34,12 +34,12 @@ export function main() {
}); });
it('should handle changing key/values correctly', () => { it('should handle changing key/values correctly', () => {
MapWrapper.set(m, 1, 10); m.set(1, 10);
MapWrapper.set(m, 2, 20); m.set(2, 20);
changes.check(m); changes.check(m);
MapWrapper.set(m, 2, 10); m.set(2, 10);
MapWrapper.set(m, 1, 20); m.set(1, 20);
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString({ .toEqual(kvChangesAsString({
@ -52,10 +52,10 @@ export function main() {
it('should expose previous and current value', () => { it('should expose previous and current value', () => {
var previous, current; var previous, current;
MapWrapper.set(m, 1, 10); m.set(1, 10);
changes.check(m); changes.check(m);
MapWrapper.set(m, 1, 20); m.set(1, 20);
changes.check(m); changes.check(m);
changes.forEachChangedItem((record) => { changes.forEachChangedItem((record) => {
@ -70,19 +70,19 @@ export function main() {
it('should do basic map watching', () => { it('should do basic map watching', () => {
changes.check(m); changes.check(m);
MapWrapper.set(m, 'a', 'A'); m.set('a', 'A');
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString({map: ['a[null->A]'], additions: ['a[null->A]']})); .toEqual(kvChangesAsString({map: ['a[null->A]'], additions: ['a[null->A]']}));
MapWrapper.set(m, 'b', 'B'); m.set('b', 'B');
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString( .toEqual(kvChangesAsString(
{map: ['a', 'b[null->B]'], previous: ['a'], additions: ['b[null->B]']})); {map: ['a', 'b[null->B]'], previous: ['a'], additions: ['b[null->B]']}));
MapWrapper.set(m, 'b', 'BB'); m.set('b', 'BB');
MapWrapper.set(m, 'd', 'D'); m.set('d', 'D');
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString({ .toEqual(kvChangesAsString({
@ -106,7 +106,7 @@ export function main() {
}); });
it('should test string by value rather than by reference (DART)', () => { it('should test string by value rather than by reference (DART)', () => {
MapWrapper.set(m, 'foo', 'bar'); m.set('foo', 'bar');
changes.check(m); changes.check(m);
var f = 'f'; var f = 'f';
@ -114,14 +114,14 @@ export function main() {
var b = 'b'; var b = 'b';
var ar = 'ar'; var ar = 'ar';
MapWrapper.set(m, f + oo, b + ar); m.set(f + oo, b + ar);
changes.check(m); changes.check(m);
expect(changes.toString()).toEqual(kvChangesAsString({map: ['foo'], previous: ['foo']})); expect(changes.toString()).toEqual(kvChangesAsString({map: ['foo'], previous: ['foo']}));
}); });
it('should not see a NaN value as a change (JS)', () => { 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);
changes.check(m); changes.check(m);
@ -139,7 +139,7 @@ export function main() {
}); });
it('should do basic object watching', () => { it('should do basic object watching', () => {
m = {}; let m = {};
changes.check(m); changes.check(m);
m['a'] = 'A'; m['a'] = 'A';

View File

@ -471,7 +471,7 @@ function createDirectiveBinding(directiveResolver, type) {
} }
function createProtoView(elementBinders = null) { 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)) { if (isBlank(elementBinders)) {
elementBinders = []; elementBinders = [];
} }
@ -581,11 +581,11 @@ class FakeTemplateResolver extends TemplateResolver {
constructor() { constructor() {
super(); super();
this._cmpTemplates = MapWrapper.create(); this._cmpTemplates = new Map();
} }
resolve(component: Type): viewAnn.View { resolve(component: Type): viewAnn.View {
var template = MapWrapper.get(this._cmpTemplates, component); var template = this._cmpTemplates.get(component);
if (isBlank(template)) { if (isBlank(template)) {
// dynamic component // dynamic component
return null; return null;
@ -593,9 +593,7 @@ class FakeTemplateResolver extends TemplateResolver {
return template; return template;
} }
setView(component: Type, template: viewAnn.View) { setView(component: Type, template: viewAnn.View) { this._cmpTemplates.set(component, template); }
MapWrapper.set(this._cmpTemplates, component, template);
}
} }
class FakeProtoViewFactory extends ProtoViewFactory { class FakeProtoViewFactory extends ProtoViewFactory {

View File

@ -879,9 +879,9 @@ export function main() {
describe('static attributes', () => { describe('static attributes', () => {
it('should be injectable', () => { it('should be injectable', () => {
var attributes = MapWrapper.create(); var attributes = new Map();
MapWrapper.set(attributes, 'type', 'text'); attributes.set( 'type', 'text');
MapWrapper.set(attributes, 'title', ''); attributes.set( 'title', '');
var inj = injector(ListWrapper.concat([NeedsAttribute], extraBindings), null, false, null, var inj = injector(ListWrapper.concat([NeedsAttribute], extraBindings), null, false, null,
attributes); attributes);
@ -893,8 +893,8 @@ export function main() {
}); });
it('should be injectable without type annotation', () => { it('should be injectable without type annotation', () => {
var attributes = MapWrapper.create(); var attributes = new Map();
MapWrapper.set(attributes, 'foo', 'bar'); attributes.set( 'foo', 'bar');
var inj = injector(ListWrapper.concat([NeedsAttributeNoType], extraBindings), null, false, var inj = injector(ListWrapper.concat([NeedsAttributeNoType], extraBindings), null, false,
null, attributes); null, attributes);

View File

@ -131,7 +131,7 @@ export function main() {
it("should not throw when not binding to a name exported by two directives", () => { it("should not throw when not binding to a name exported by two directives", () => {
expect(() => { expect(() => {
createDirectiveVariableBindings( createDirectiveVariableBindings(
new renderApi.ElementBinder({variableBindings: MapWrapper.create()}), [ new renderApi.ElementBinder({variableBindings: new Map()}), [
directiveBinding( directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}), {metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
directiveBinding( directiveBinding(
@ -167,7 +167,7 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType =
elementBinders = []; elementBinders = [];
} }
return new renderApi.ProtoViewDto( return new renderApi.ProtoViewDto(
{elementBinders: elementBinders, type: type, variableBindings: MapWrapper.create()}); {elementBinders: elementBinders, type: type, variableBindings: new Map()});
} }
function createRenderComponentElementBinder(directiveIndex) { function createRenderComponentElementBinder(directiveIndex) {

View File

@ -37,7 +37,7 @@ export function main() {
function createProtoView() { return new AppProtoView(null, null, null, null); } 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); } function createViewContainer() { return new ViewContainerRef(viewManager, location); }

View File

@ -100,7 +100,7 @@ export function main() {
if (isBlank(renderViewRef)) { if (isBlank(renderViewRef)) {
renderViewRef = new RenderViewRef(); renderViewRef = new RenderViewRef();
} }
var view = new AppView(renderer, pv, MapWrapper.create()); var view = new AppView(renderer, pv, new Map());
view.render = renderViewRef; view.render = renderViewRef;
var elementInjectors = ListWrapper.createFixedSize(pv.elementBinders.length); var elementInjectors = ListWrapper.createFixedSize(pv.elementBinders.length);
for (var i = 0; i < pv.elementBinders.length; i++) { for (var i = 0; i < pv.elementBinders.length; i++) {

View File

@ -86,7 +86,7 @@ export function main() {
if (isBlank(pv)) { if (isBlank(pv)) {
pv = createProtoView(); 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 elementInjectors = ListWrapper.createFixedSize(pv.elementBinders.length);
var preBuiltObjects = ListWrapper.createFixedSize(pv.elementBinders.length); var preBuiltObjects = ListWrapper.createFixedSize(pv.elementBinders.length);
for (var i = 0; i < pv.elementBinders.length; i++) { for (var i = 0; i < pv.elementBinders.length; i++) {

View File

@ -26,7 +26,7 @@ export function main() {
function createProtoView() { return new AppProtoView(null, null, null, null); } 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', () => { it('should support multiple AppProtoViews', () => {
var vf = createViewPool({capacity: 2}); var vf = createViewPool({capacity: 2});

View File

@ -34,7 +34,7 @@ export function runCompilerCommonTests() {
function createCompiler(processClosure, urlData = null) { function createCompiler(processClosure, urlData = null) {
if (isBlank(urlData)) { if (isBlank(urlData)) {
urlData = MapWrapper.create(); urlData = new Map();
} }
var tplLoader = new FakeTemplateLoader(urlData); var tplLoader = new FakeTemplateLoader(urlData);
mockStepFactory = new MockStepFactory([new MockStep(processClosure)]); mockStepFactory = new MockStepFactory([new MockStep(processClosure)]);
@ -99,7 +99,7 @@ export function runCompilerCommonTests() {
})); }));
it('should report loading errors', inject([AsyncTestCompleter], (async) => { it('should report loading errors', inject([AsyncTestCompleter], (async) => {
var compiler = createCompiler(EMPTY_STEP, MapWrapper.create()); var compiler = createCompiler(EMPTY_STEP, new Map());
PromiseWrapper.catchError( PromiseWrapper.catchError(
compiler.compile( compiler.compile(
new ViewDefinition({componentId: 'someId', templateAbsUrl: 'someUrl'})), new ViewDefinition({componentId: 'someId', templateAbsUrl: 'someUrl'})),
@ -209,7 +209,7 @@ class FakeTemplateLoader extends TemplateLoader {
} }
if (isPresent(template.templateAbsUrl)) { if (isPresent(template.templateAbsUrl)) {
var content = MapWrapper.get(this._urlData, template.templateAbsUrl); var content = this._urlData.get(template.templateAbsUrl);
return isPresent(content) ? return isPresent(content) ?
PromiseWrapper.resolve(DOM.createTemplate(content)) : PromiseWrapper.resolve(DOM.createTemplate(content)) :
PromiseWrapper.reject(`Failed to fetch url "${template.templateAbsUrl}"`, null); PromiseWrapper.reject(`Failed to fetch url "${template.templateAbsUrl}"`, null);

View File

@ -83,16 +83,15 @@ export function main() {
var results = process(el('<div some-decor-props></div>'), var results = process(el('<div some-decor-props></div>'),
{'elProp': parser.parseBinding('someExpr', '')}); {'elProp': parser.parseBinding('someExpr', '')});
var directiveBinding = results[0].directives[0]; var directiveBinding = results[0].directives[0];
expect(MapWrapper.get(directiveBinding.propertyBindings, 'dirProp').source) expect(directiveBinding.propertyBindings.get('dirProp').source).toEqual('someExpr');
.toEqual('someExpr');
}); });
it('should bind directive properties with pipes', () => { it('should bind directive properties with pipes', () => {
var results = process(el('<div some-decor-props></div>'), var results = process(el('<div some-decor-props></div>'),
{'elProp': parser.parseBinding('someExpr', '')}); {'elProp': parser.parseBinding('someExpr', '')});
var directiveBinding = results[0].directives[0]; var directiveBinding = results[0].directives[0];
var pipedProp = <any>MapWrapper.get(directiveBinding.propertyBindings, 'doubleProp'); var pipedProp = <any>directiveBinding.propertyBindings.get('doubleProp');
var simpleProp = <any>MapWrapper.get(directiveBinding.propertyBindings, 'dirProp'); var simpleProp = <any>directiveBinding.propertyBindings.get('dirProp');
expect(pipedProp.ast.name).toEqual('double'); expect(pipedProp.ast.name).toEqual('double');
expect(pipedProp.ast.exp).toEqual(simpleProp.ast); expect(pipedProp.ast.exp).toEqual(simpleProp.ast);
expect(simpleProp.source).toEqual('someExpr'); expect(simpleProp.source).toEqual('someExpr');
@ -101,7 +100,7 @@ export function main() {
it('should bind directive properties from attribute values', () => { it('should bind directive properties from attribute values', () => {
var results = process(el('<div some-decor-props el-prop="someValue"></div>')); var results = process(el('<div some-decor-props el-prop="someValue"></div>'));
var directiveBinding = results[0].directives[0]; var directiveBinding = results[0].directives[0];
var simpleProp = MapWrapper.get(directiveBinding.propertyBindings, 'dirProp'); var simpleProp = directiveBinding.propertyBindings.get('dirProp');
expect(simpleProp.source).toEqual('someValue'); expect(simpleProp.source).toEqual('someValue');
}); });
@ -111,7 +110,7 @@ export function main() {
var directiveBinding = results[0].directives[0]; var directiveBinding = results[0].directives[0];
var ast = MapWrapper.get(directiveBinding.hostPropertyBindings, 'hostProp'); var ast = directiveBinding.hostPropertyBindings.get('hostProp');
expect(ast.source).toEqual('dirProp'); expect(ast.source).toEqual('dirProp');
}); });
@ -145,7 +144,7 @@ export function main() {
it('should read attribute values', () => { it('should read attribute values', () => {
var element = el('<input some-decor-props some-attr="someValue">'); var element = el('<input some-decor-props some-attr="someValue">');
var results = process(element); 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', () => { it('should bind directive events', () => {

View File

@ -9,7 +9,7 @@ import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
import {Lexer, Parser} from 'angular2/change_detection'; import {Lexer, Parser} from 'angular2/change_detection';
import {ElementBinderBuilder} from 'angular2/src/render/dom/view/proto_view_builder'; import {ElementBinderBuilder} from 'angular2/src/render/dom/view/proto_view_builder';
var EMPTY_MAP = MapWrapper.create(); var EMPTY_MAP = new Map();
export function main() { export function main() {
describe('PropertyBindingParser', () => { describe('PropertyBindingParser', () => {
@ -31,7 +31,7 @@ export function main() {
it('should detect [] syntax', () => { it('should detect [] syntax', () => {
var results = process(el('<div [a]="b"></div>')); var results = process(el('<div [a]="b"></div>'));
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 []', () => { 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', () => { it('should detect bind- syntax', () => {
var results = process(el('<div bind-a="b"></div>')); var results = process(el('<div bind-a="b"></div>'));
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', 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', () => { it('should detect interpolation syntax', () => {
var results = process(el('<div a="{{b}}"></div>')); var results = process(el('<div a="{{b}}"></div>'));
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', () => { it('should store property setters as camel case', () => {
var element = el('<div bind-some-prop="1">'); var element = el('<div bind-some-prop="1">');
var results = process(element); var results = process(element);
expect(MapWrapper.get(results[0].propertyBindings, 'someProp')).toBeTruthy(); expect(results[0].propertyBindings.get('someProp')).toBeTruthy();
}); });
it('should detect var- syntax', () => { it('should detect var- syntax', () => {
var results = process(el('<template var-a="b"></template>')); var results = process(el('<template var-a="b"></template>'));
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', () => { it('should store variable binding for a template element on the nestedProtoView', () => {
var results = process(el('<template var-george="washington"></p>'), true); var results = process(el('<template var-george="washington"></p>'), true);
expect(results[0].variableBindings).toEqual(EMPTY_MAP); expect(results[0].variableBindings).toEqual(EMPTY_MAP);
expect(MapWrapper.get(results[0].nestedProtoView.variableBindings, 'washington')) expect(results[0].nestedProtoView.variableBindings.get('washington')).toEqual('george');
.toEqual('george');
}); });
it('should store variable binding for a non-template element using shorthand syntax on the nestedProtoView', it('should store variable binding for a non-template element using shorthand syntax on the nestedProtoView',
() => { () => {
var results = process(el('<template #george="washington"></template>'), true); var results = process(el('<template #george="washington"></template>'), true);
expect(results[0].variableBindings).toEqual(EMPTY_MAP); expect(results[0].variableBindings).toEqual(EMPTY_MAP);
expect(MapWrapper.get(results[0].nestedProtoView.variableBindings, 'washington')) expect(results[0].nestedProtoView.variableBindings.get('washington')).toEqual('george');
.toEqual('george');
}); });
it('should store variable binding for a non-template element', () => { it('should store variable binding for a non-template element', () => {
var results = process(el('<p var-george="washington"></p>')); var results = process(el('<p var-george="washington"></p>'));
expect(MapWrapper.get(results[0].variableBindings, 'washington')).toEqual('george'); expect(results[0].variableBindings.get('washington')).toEqual('george');
}); });
it('should store variable binding for a non-template element using shorthand syntax', () => { it('should store variable binding for a non-template element using shorthand syntax', () => {
var results = process(el('<p #george="washington"></p>')); var results = process(el('<p #george="washington"></p>'));
expect(MapWrapper.get(results[0].variableBindings, 'washington')).toEqual('george'); expect(results[0].variableBindings.get('washington')).toEqual('george');
}); });
it('should store a variable binding with an implicit value', () => { it('should store a variable binding with an implicit value', () => {
var results = process(el('<p var-george></p>')); var results = process(el('<p var-george></p>'));
expect(MapWrapper.get(results[0].variableBindings, '\$implicit')).toEqual('george'); expect(results[0].variableBindings.get('\$implicit')).toEqual('george');
}); });
it('should store a variable binding with an implicit value using shorthand syntax', () => { it('should store a variable binding with an implicit value using shorthand syntax', () => {
var results = process(el('<p #george></p>')); var results = process(el('<p #george></p>'));
expect(MapWrapper.get(results[0].variableBindings, '\$implicit')).toEqual('george'); expect(results[0].variableBindings.get('\$implicit')).toEqual('george');
}); });
it('should detect variable bindings only if an attribute name starts with #', () => { it('should detect variable bindings only if an attribute name starts with #', () => {
@ -143,25 +141,25 @@ export function main() {
it('should store bound properties as temporal attributes', () => { it('should store bound properties as temporal attributes', () => {
var results = createPipeline().process(el('<div bind-a="b" [c]="d"></div>')); var results = createPipeline().process(el('<div bind-a="b" [c]="d"></div>'));
expect(MapWrapper.get(results[0].attrs(), 'a')).toEqual('b'); expect(results[0].attrs().get('a')).toEqual('b');
expect(MapWrapper.get(results[0].attrs(), 'c')).toEqual('d'); expect(results[0].attrs().get('c')).toEqual('d');
}); });
it('should store variables as temporal attributes', () => { it('should store variables as temporal attributes', () => {
var results = createPipeline().process(el('<div var-a="b" #c="d"></div>')); var results = createPipeline().process(el('<div var-a="b" #c="d"></div>'));
expect(MapWrapper.get(results[0].attrs(), 'a')).toEqual('b'); expect(results[0].attrs().get('a')).toEqual('b');
expect(MapWrapper.get(results[0].attrs(), 'c')).toEqual('d'); expect(results[0].attrs().get('c')).toEqual('d');
}); });
it('should detect [()] syntax', () => { it('should detect [()] syntax', () => {
var results = process(el('<div [(a)]="b"></div>')); var results = process(el('<div [(a)]="b"></div>'));
expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('b'); expect(results[0].propertyBindings.get('a').source).toEqual('b');
expect(results[0].eventBindings[0].source.source).toEqual('b=$event'); expect(results[0].eventBindings[0].source.source).toEqual('b=$event');
}); });
it('should detect bindon- syntax', () => { it('should detect bindon- syntax', () => {
var results = process(el('<div bindon-a="b"></div>')); var results = process(el('<div bindon-a="b"></div>'));
expect(MapWrapper.get(results[0].propertyBindings, 'a').source).toEqual('b'); expect(results[0].propertyBindings.get('a').source).toEqual('b');
expect(results[0].eventBindings[0].source.source).toEqual('b=$event'); expect(results[0].eventBindings[0].source.source).toEqual('b=$event');
}); });
}); });

View File

@ -110,10 +110,9 @@ export function main() {
it('should add property bindings from the template attribute', () => { it('should add property bindings from the template attribute', () => {
var rootElement = el('<div><div template="some-prop:expr"></div></div>'); var rootElement = el('<div><div template="some-prop:expr"></div></div>');
var results = createPipeline().process(rootElement); var results = createPipeline().process(rootElement);
expect( expect(results[1].inheritedElementBinder.propertyBindings.get('someProp').source)
MapWrapper.get(results[1].inheritedElementBinder.propertyBindings, 'someProp').source)
.toEqual('expr'); .toEqual('expr');
expect(MapWrapper.get(results[1].attrs(), 'some-prop')).toEqual('expr'); expect(results[1].attrs().get('some-prop')).toEqual('expr');
}); });
it('should add variable mappings from the template attribute to the nestedProtoView', () => { it('should add variable mappings from the template attribute to the nestedProtoView', () => {
@ -126,9 +125,9 @@ export function main() {
it('should add entries without value as attributes to the element', () => { it('should add entries without value as attributes to the element', () => {
var rootElement = el('<div><div template="varname"></div></div>'); var rootElement = el('<div><div template="varname"></div></div>');
var results = createPipeline().process(rootElement); var results = createPipeline().process(rootElement);
expect(MapWrapper.get(results[1].attrs(), 'varname')).toEqual(''); expect(results[1].attrs().get('varname')).toEqual('');
expect(results[1].inheritedElementBinder.propertyBindings).toEqual(MapWrapper.create()); expect(results[1].inheritedElementBinder.propertyBindings).toEqual(new Map());
expect(results[1].inheritedElementBinder.variableBindings).toEqual(MapWrapper.create()); expect(results[1].inheritedElementBinder.variableBindings).toEqual(new Map());
}); });
it('should iterate properly after a template dom modification', () => { it('should iterate properly after a template dom modification', () => {
@ -197,9 +196,9 @@ export function main() {
it('should add property bindings from the template attribute', () => { it('should add property bindings from the template attribute', () => {
var rootElement = el('<div><div *prop="expr"></div></div>'); var rootElement = el('<div><div *prop="expr"></div></div>');
var results = createPipeline().process(rootElement); var results = createPipeline().process(rootElement);
expect(MapWrapper.get(results[1].inheritedElementBinder.propertyBindings, 'prop').source) expect(results[1].inheritedElementBinder.propertyBindings.get('prop').source)
.toEqual('expr'); .toEqual('expr');
expect(MapWrapper.get(results[1].attrs(), 'prop')).toEqual('expr'); expect(results[1].attrs().get('prop')).toEqual('expr');
}); });
it('should add variable mappings from the template attribute to the nestedProtoView', () => { it('should add variable mappings from the template attribute to the nestedProtoView', () => {
@ -212,9 +211,9 @@ export function main() {
it('should add entries without value as attribute to the element', () => { it('should add entries without value as attribute to the element', () => {
var rootElement = el('<div><div *varname></div></div>'); var rootElement = el('<div><div *varname></div></div>');
var results = createPipeline().process(rootElement); var results = createPipeline().process(rootElement);
expect(MapWrapper.get(results[1].attrs(), 'varname')).toEqual(''); expect(results[1].attrs().get('varname')).toEqual('');
expect(results[1].inheritedElementBinder.propertyBindings).toEqual(MapWrapper.create()); expect(results[1].inheritedElementBinder.propertyBindings).toEqual(new Map());
expect(results[1].inheritedElementBinder.variableBindings).toEqual(MapWrapper.create()); expect(results[1].inheritedElementBinder.variableBindings).toEqual(new Map());
}); });
it('should iterate properly after a template dom modification', () => { it('should iterate properly after a template dom modification', () => {

View File

@ -27,28 +27,24 @@ export function main() {
changeDetection: 'CHECK_ONCE' changeDetection: 'CHECK_ONCE'
}); });
var map = directiveMetadataToMap(someComponent); var map = directiveMetadataToMap(someComponent);
expect(MapWrapper.get(map, 'compileChildren')).toEqual(false); expect(map.get('compileChildren')).toEqual(false);
expect(MapWrapper.get(map, 'hostListeners')) expect(map.get('hostListeners')).toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']]));
.toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']])); expect(map.get('hostProperties')).toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']]));
expect(MapWrapper.get(map, 'hostProperties')) expect(map.get('hostActions')).toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']]));
.toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']])); expect(map.get('hostAttributes')).toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']]));
expect(MapWrapper.get(map, 'hostActions')) expect(map.get('id')).toEqual('someComponent');
.toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']])); expect(map.get('properties')).toEqual(['propKey: propVal']);
expect(MapWrapper.get(map, 'hostAttributes')) expect(map.get('readAttributes')).toEqual(['read1', 'read2']);
.toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']])); expect(map.get('selector')).toEqual('some-comp');
expect(MapWrapper.get(map, 'id')).toEqual('someComponent'); expect(map.get('type')).toEqual(DirectiveMetadata.COMPONENT_TYPE);
expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']); expect(map.get('callOnDestroy')).toEqual(true);
expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']); expect(map.get('callOnCheck')).toEqual(true);
expect(MapWrapper.get(map, 'selector')).toEqual('some-comp'); expect(map.get('callOnChange')).toEqual(true);
expect(MapWrapper.get(map, 'type')).toEqual(DirectiveMetadata.COMPONENT_TYPE); expect(map.get('callOnInit')).toEqual(true);
expect(MapWrapper.get(map, 'callOnDestroy')).toEqual(true); expect(map.get('callOnAllChangesDone')).toEqual(true);
expect(MapWrapper.get(map, 'callOnCheck')).toEqual(true); expect(map.get('exportAs')).toEqual('aaa');
expect(MapWrapper.get(map, 'callOnChange')).toEqual(true); expect(map.get('events')).toEqual(['onFoo', 'onBar']);
expect(MapWrapper.get(map, 'callOnInit')).toEqual(true); expect(map.get('changeDetection')).toEqual('CHECK_ONCE');
expect(MapWrapper.get(map, 'callOnAllChangesDone')).toEqual(true);
expect(MapWrapper.get(map, 'exportAs')).toEqual('aaa');
expect(MapWrapper.get(map, 'events')).toEqual(['onFoo', 'onBar']);
expect(MapWrapper.get(map, 'changeDetection')).toEqual('CHECK_ONCE');
}); });
it('mapToDirectiveMetadata', () => { it('mapToDirectiveMetadata', () => {

View File

@ -177,7 +177,7 @@ export function main() {
// event type // event type
expect(eventEntry[1]).toEqual('change'); expect(eventEntry[1]).toEqual('change');
// actual event // actual event
expect((<any>MapWrapper.get(eventEntry[2], '$event')).type).toEqual('change'); expect((<Map<any, any>>eventEntry[2]).get('$event').type).toEqual('change');
async.done(); async.done();
}); });

View File

@ -31,7 +31,7 @@ export function main() {
var plugin = new FakeEventManagerPlugin(['click']); var plugin = new FakeEventManagerPlugin(['click']);
var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone()); var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone());
manager.addEventListener(element, 'click', handler); manager.addEventListener(element, 'click', handler);
expect(MapWrapper.get(plugin._nonBubbleEventHandlers, 'click')).toBe(handler); expect(plugin._nonBubbleEventHandlers.get('click')).toBe(handler);
}); });
it('should delegate bubbling events to plugins', () => { it('should delegate bubbling events to plugins', () => {
@ -40,7 +40,7 @@ export function main() {
var plugin = new FakeEventManagerPlugin(['click']); var plugin = new FakeEventManagerPlugin(['click']);
var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone()); var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone());
manager.addEventListener(element, '^click', handler); manager.addEventListener(element, '^click', handler);
expect(MapWrapper.get(plugin._bubbleEventHandlers, 'click')).toBe(handler); expect(plugin._bubbleEventHandlers.get('click')).toBe(handler);
}); });
it('should delegate event bindings to the first plugin supporting the event', () => { it('should delegate event bindings to the first plugin supporting the event', () => {
@ -53,9 +53,9 @@ export function main() {
manager.addEventListener(element, 'click', clickHandler); manager.addEventListener(element, 'click', clickHandler);
manager.addEventListener(element, 'dblclick', dblClickHandler); manager.addEventListener(element, 'dblclick', dblClickHandler);
expect(MapWrapper.contains(plugin1._nonBubbleEventHandlers, 'click')).toBe(false); expect(MapWrapper.contains(plugin1._nonBubbleEventHandlers, 'click')).toBe(false);
expect(MapWrapper.get(plugin2._nonBubbleEventHandlers, 'click')).toBe(clickHandler); expect(plugin2._nonBubbleEventHandlers.get('click')).toBe(clickHandler);
expect(MapWrapper.contains(plugin2._nonBubbleEventHandlers, 'dblclick')).toBe(false); expect(MapWrapper.contains(plugin2._nonBubbleEventHandlers, 'dblclick')).toBe(false);
expect(MapWrapper.get(plugin1._nonBubbleEventHandlers, 'dblclick')).toBe(dblClickHandler); expect(plugin1._nonBubbleEventHandlers.get('dblclick')).toBe(dblClickHandler);
}); });
it('should throw when no plugin can handle the event', () => { it('should throw when no plugin can handle the event', () => {
@ -126,15 +126,18 @@ class FakeEventManagerPlugin extends EventManagerPlugin {
constructor(supports: List<string>) { constructor(supports: List<string>) {
super(); super();
this._supports = supports; this._supports = supports;
this._nonBubbleEventHandlers = MapWrapper.create(); this._nonBubbleEventHandlers = new Map();
this._bubbleEventHandlers = MapWrapper.create(); this._bubbleEventHandlers = new Map();
} }
supports(eventName: string): boolean { return ListWrapper.contains(this._supports, eventName); } supports(eventName: string): boolean { return ListWrapper.contains(this._supports, eventName); }
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) { addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
MapWrapper.set(shouldSupportBubble ? this._bubbleEventHandlers : this._nonBubbleEventHandlers, if (shouldSupportBubble) {
eventName, handler); this._bubbleEventHandlers.set(eventName, handler);
} else {
this._nonBubbleEventHandlers.set(eventName, handler);
}
return () => { return () => {
MapWrapper.delete( MapWrapper.delete(
shouldSupportBubble ? this._bubbleEventHandlers : this._nonBubbleEventHandlers, eventName) shouldSupportBubble ? this._bubbleEventHandlers : this._nonBubbleEventHandlers, eventName)

View File

@ -142,11 +142,11 @@ class FakeXHR extends XHR {
constructor() { constructor() {
super(); super();
this._responses = MapWrapper.create(); this._responses = new Map();
} }
get(url: string): Promise<string> { get(url: string): Promise<string> {
var response = MapWrapper.get(this._responses, url); var response = this._responses.get(url);
if (isBlank(response)) { if (isBlank(response)) {
return PromiseWrapper.reject('xhr error', null); return PromiseWrapper.reject('xhr error', null);
} }
@ -154,5 +154,5 @@ class FakeXHR extends XHR {
return PromiseWrapper.resolve(response); return PromiseWrapper.resolve(response);
} }
reply(url: string, response: string) { MapWrapper.set(this._responses, url, response); } reply(url: string, response: string) { this._responses.set(url, response); }
} }

View File

@ -187,11 +187,11 @@ class FakeXHR extends XHR {
constructor() { constructor() {
super(); super();
this._responses = MapWrapper.create(); this._responses = new Map();
} }
get(url: string): Promise<string> { get(url: string): Promise<string> {
var response = MapWrapper.get(this._responses, url); var response = this._responses.get(url);
if (isBlank(response)) { if (isBlank(response)) {
return PromiseWrapper.reject('xhr error', null); return PromiseWrapper.reject('xhr error', null);
} }
@ -199,5 +199,5 @@ class FakeXHR extends XHR {
return PromiseWrapper.resolve(response); return PromiseWrapper.resolve(response);
} }
reply(url: string, response: string) { MapWrapper.set(this._responses, url, response); } reply(url: string, response: string) { this._responses.set(url, response); }
} }

View File

@ -48,8 +48,8 @@ declare var Map: {
new (): Map<any, any>; new (): Map<any, any>;
new<K, V>(): Map<K, V>; new<K, V>(): Map<K, V>;
// alexeagle: PATCHED // alexeagle: PATCHED
new<K, V>(m: Map<K, V>): Map<K, V>; new<K, V>(m: Map<K, V>): Map<any, any>;
new<K, V>(l: List<any>): Map<K, V>; new<K, V>(l: List<any>): Map<any, any>;
prototype: Map<any, any>; prototype: Map<any, any>;
}; };

View File

@ -50,7 +50,7 @@ export class MdGridList {
this.rows = 0; this.rows = 0;
} }
set cols(value) { set cols(value: any) {
this._cols = isString(value) ? NumberWrapper.parseInt(value, 10) : <number>value; this._cols = isString(value) ? NumberWrapper.parseInt(value, 10) : <number>value;
} }

View File

@ -101,7 +101,7 @@ class MultipleTemplateResolver extends TemplateResolver {
constructor(multiple: number, components: List<Type>) { constructor(multiple: number, components: List<Type>) {
super(); super();
this._multiple = multiple; this._multiple = multiple;
this._cache = MapWrapper.create(); this._cache = new Map();
ListWrapper.forEach(components, (c) => this._warmUp(c)); ListWrapper.forEach(components, (c) => this._warmUp(c));
} }
@ -111,13 +111,13 @@ class MultipleTemplateResolver extends TemplateResolver {
for (var i = 0; i < this._multiple; ++i) { for (var i = 0; i < this._multiple; ++i) {
multiplier[i] = view.template; multiplier[i] = view.template;
} }
MapWrapper.set(this._cache, component, ListWrapper.join(multiplier, '')); this._cache.set(component, ListWrapper.join(multiplier, ''));
} }
resolve(component: Type): viewModule.View { resolve(component: Type): viewModule.View {
var view = super.resolve(component); var view = super.resolve(component);
var myView = new viewModule.View( var myView = new viewModule.View(
{template:<string>MapWrapper.get(this._cache, component), directives: view.directives}); {template:<string>this._cache.get(component), directives: view.directives});
return myView; return myView;
} }
} }

View File

@ -7,9 +7,9 @@ import {Component, Directive, View} from 'angular2/angular2';
export class HasStyle { export class HasStyle {
style: Map<any, any>; style: Map<any, any>;
constructor() { this.style = MapWrapper.create(); } constructor() { this.style = new Map(); }
set width(w) { MapWrapper.set(this.style, 'width', w); } set width(w) { this.style.set('width', w); }
} }
@Component({selector: 'company-name', properties: ['width: cell-width', 'company']}) @Component({selector: 'company-name', properties: ['width: cell-width', 'company']})
@ -33,7 +33,7 @@ export class OfferingNameComponent extends HasStyle {
export class Stage { export class Stage {
name: string; name: string;
isDisabled: boolean; isDisabled: boolean;
style: Map; style: Map<string, string>;
apply: Function; apply: Function;
} }
@ -73,9 +73,8 @@ export class StageButtonsComponent extends HasStyle {
var stage = new Stage(); var stage = new Stage();
stage.name = status; stage.name = status;
stage.isDisabled = disabled; stage.isDisabled = disabled;
var stageStyle = MapWrapper.create(); var stageStyle = new Map<string, string>();
MapWrapper.set(stageStyle, 'background-color', stageStyle.set('background-color', disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD');
disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD');
stage.style = stageStyle; stage.style = stageStyle;
if (isCurrent) { if (isCurrent) {
disabled = false; disabled = false;

View File

@ -57,7 +57,7 @@ export class CustomDate {
export class RawEntity { export class RawEntity {
_data: Map<any, any>; _data: Map<any, any>;
constructor() { this._data = MapWrapper.create(); } constructor() { this._data = new Map(); }
get(key: string) { get(key: string) {
if (key.indexOf('.') == -1) { if (key.indexOf('.') == -1) {