feat: remove MapWrapper.create()/get()/set().
Better dart2js code, better Angular code.
This commit is contained in:
@ -205,22 +205,22 @@ export class DirectiveMetadata {
|
||||
changeDetection?: string,
|
||||
exportAs?: string
|
||||
}) {
|
||||
let hostListeners = MapWrapper.create();
|
||||
let hostProperties = MapWrapper.create();
|
||||
let hostAttributes = MapWrapper.create();
|
||||
let hostActions = MapWrapper.create();
|
||||
let hostListeners = new Map();
|
||||
let hostProperties = new Map();
|
||||
let hostAttributes = new Map();
|
||||
let hostActions = new Map();
|
||||
|
||||
if (isPresent(host)) {
|
||||
MapWrapper.forEach(host, (value: string, key: string) => {
|
||||
var matches = RegExpWrapper.firstMatch(hostRegExp, key);
|
||||
if (isBlank(matches)) {
|
||||
MapWrapper.set(hostAttributes, key, value);
|
||||
hostAttributes.set(key, value);
|
||||
} else if (isPresent(matches[1])) {
|
||||
MapWrapper.set(hostProperties, matches[1], value);
|
||||
hostProperties.set(matches[1], value);
|
||||
} else if (isPresent(matches[2])) {
|
||||
MapWrapper.set(hostListeners, matches[2], value);
|
||||
hostListeners.set(matches[2], value);
|
||||
} else if (isPresent(matches[3])) {
|
||||
MapWrapper.set(hostActions, matches[3], value);
|
||||
hostActions.set(matches[3], value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ function getElementDescription(domElement): string {
|
||||
buf.add(DOM.tagName(domElement).toLowerCase());
|
||||
|
||||
// show id and class first to ease element identification
|
||||
addDescriptionAttribute(buf, "id", MapWrapper.get(atts, "id"));
|
||||
addDescriptionAttribute(buf, "class", MapWrapper.get(atts, "class"));
|
||||
addDescriptionAttribute(buf, "id", atts.get("id"));
|
||||
addDescriptionAttribute(buf, "class", atts.get("class"));
|
||||
MapWrapper.forEach(atts, (attValue, attName) => {
|
||||
if (attName !== "id" && attName !== "class") {
|
||||
addDescriptionAttribute(buf, attName, attValue);
|
||||
|
@ -135,11 +135,10 @@ export class DirectiveParser implements CompileStep {
|
||||
pipes = [];
|
||||
}
|
||||
|
||||
var bindingAst =
|
||||
MapWrapper.get(compileElement.bindElement().propertyBindings, dashCaseToCamelCase(elProp));
|
||||
var bindingAst = compileElement.bindElement().propertyBindings.get(dashCaseToCamelCase(elProp));
|
||||
|
||||
if (isBlank(bindingAst)) {
|
||||
var attributeValue = MapWrapper.get(compileElement.attrs(), camelCaseToDashCase(elProp));
|
||||
var attributeValue = compileElement.attrs().get(camelCaseToDashCase(elProp));
|
||||
if (isPresent(attributeValue)) {
|
||||
bindingAst =
|
||||
this._parser.wrapLiteralPrimitive(attributeValue, compileElement.elementDescription);
|
||||
|
@ -27,7 +27,7 @@ export class PropertyBindingParser implements CompileStep {
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
var attrs = current.attrs();
|
||||
var newAttrs = MapWrapper.create();
|
||||
var newAttrs = new Map();
|
||||
|
||||
MapWrapper.forEach(attrs, (attrValue, attrName) => {
|
||||
var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
|
||||
@ -66,13 +66,12 @@ export class PropertyBindingParser implements CompileStep {
|
||||
}
|
||||
});
|
||||
|
||||
MapWrapper.forEach(newAttrs,
|
||||
(attrValue, attrName) => { MapWrapper.set(attrs, attrName, attrValue); });
|
||||
MapWrapper.forEach(newAttrs, (attrValue, attrName) => { attrs.set(attrName, attrValue); });
|
||||
}
|
||||
|
||||
_bindVariable(identifier, value, current: CompileElement, newAttrs) {
|
||||
_bindVariable(identifier, value, current: CompileElement, newAttrs: Map<any, any>) {
|
||||
current.bindElement().bindVariable(dashCaseToCamelCase(identifier), value);
|
||||
MapWrapper.set(newAttrs, identifier, value);
|
||||
newAttrs.set(identifier, value);
|
||||
}
|
||||
|
||||
_bindProperty(name, expression, current: CompileElement, newAttrs) {
|
||||
@ -80,10 +79,10 @@ export class PropertyBindingParser implements CompileStep {
|
||||
current, newAttrs);
|
||||
}
|
||||
|
||||
_bindPropertyAst(name, ast, current: CompileElement, newAttrs) {
|
||||
_bindPropertyAst(name, ast, current: CompileElement, newAttrs: Map<any, any>) {
|
||||
var binder = current.bindElement();
|
||||
binder.bindProperty(dashCaseToCamelCase(name), ast);
|
||||
MapWrapper.set(newAttrs, name, ast.source);
|
||||
newAttrs.set(name, ast.source);
|
||||
}
|
||||
|
||||
_bindAssignmentEvent(name, expression, current: CompileElement, newAttrs) {
|
||||
|
@ -141,12 +141,12 @@ export class SelectorMatcher {
|
||||
return notMatcher;
|
||||
}
|
||||
|
||||
private _elementMap: Map<string, List<SelectorContext>> = MapWrapper.create();
|
||||
private _elementPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
|
||||
private _classMap: Map<string, List<SelectorContext>> = MapWrapper.create();
|
||||
private _classPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
|
||||
private _attrValueMap: Map<string, Map<string, List<SelectorContext>>> = MapWrapper.create();
|
||||
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = MapWrapper.create();
|
||||
private _elementMap: Map<string, List<SelectorContext>> = new Map();
|
||||
private _elementPartialMap: Map<string, SelectorMatcher> = new Map();
|
||||
private _classMap: Map<string, List<SelectorContext>> = new Map();
|
||||
private _classPartialMap: Map<string, SelectorMatcher> = new Map();
|
||||
private _attrValueMap: Map<string, Map<string, List<SelectorContext>>> = new Map();
|
||||
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = new Map();
|
||||
private _listContexts: List<SelectorListContext> = [];
|
||||
|
||||
addSelectables(cssSelectors: List<CssSelector>, callbackCtxt?: any) {
|
||||
@ -201,18 +201,18 @@ export class SelectorMatcher {
|
||||
var attrValue = attrs[index++];
|
||||
if (isTerminal) {
|
||||
var terminalMap = matcher._attrValueMap;
|
||||
var terminalValuesMap = MapWrapper.get(terminalMap, attrName);
|
||||
var terminalValuesMap = terminalMap.get(attrName);
|
||||
if (isBlank(terminalValuesMap)) {
|
||||
terminalValuesMap = MapWrapper.create();
|
||||
MapWrapper.set(terminalMap, attrName, terminalValuesMap);
|
||||
terminalValuesMap = new Map();
|
||||
terminalMap.set(attrName, terminalValuesMap);
|
||||
}
|
||||
this._addTerminal(terminalValuesMap, attrValue, selectable);
|
||||
} else {
|
||||
var parttialMap = matcher._attrValuePartialMap;
|
||||
var partialValuesMap = MapWrapper.get(parttialMap, attrName);
|
||||
var partialValuesMap = parttialMap.get(attrName);
|
||||
if (isBlank(partialValuesMap)) {
|
||||
partialValuesMap = MapWrapper.create();
|
||||
MapWrapper.set(parttialMap, attrName, partialValuesMap);
|
||||
partialValuesMap = new Map();
|
||||
parttialMap.set(attrName, partialValuesMap);
|
||||
}
|
||||
matcher = this._addPartial(partialValuesMap, attrValue);
|
||||
}
|
||||
@ -222,19 +222,19 @@ export class SelectorMatcher {
|
||||
|
||||
private _addTerminal(map: Map<string, List<SelectorContext>>, name: string,
|
||||
selectable: SelectorContext) {
|
||||
var terminalList = MapWrapper.get(map, name);
|
||||
var terminalList = map.get(name);
|
||||
if (isBlank(terminalList)) {
|
||||
terminalList = [];
|
||||
MapWrapper.set(map, name, terminalList);
|
||||
map.set(name, terminalList);
|
||||
}
|
||||
terminalList.push(selectable);
|
||||
}
|
||||
|
||||
private _addPartial(map: Map<string, SelectorMatcher>, name: string): SelectorMatcher {
|
||||
var matcher = MapWrapper.get(map, name);
|
||||
var matcher = map.get(name);
|
||||
if (isBlank(matcher)) {
|
||||
matcher = new SelectorMatcher();
|
||||
MapWrapper.set(map, name, matcher);
|
||||
map.set(name, matcher);
|
||||
}
|
||||
return matcher;
|
||||
}
|
||||
@ -276,7 +276,7 @@ export class SelectorMatcher {
|
||||
var attrName = attrs[index++];
|
||||
var attrValue = attrs[index++];
|
||||
|
||||
var terminalValuesMap = MapWrapper.get(this._attrValueMap, attrName);
|
||||
var terminalValuesMap = this._attrValueMap.get(attrName);
|
||||
if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
|
||||
result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector,
|
||||
matchedCallback) ||
|
||||
@ -285,7 +285,7 @@ export class SelectorMatcher {
|
||||
result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) ||
|
||||
result;
|
||||
|
||||
var partialValuesMap = MapWrapper.get(this._attrValuePartialMap, attrName);
|
||||
var partialValuesMap = this._attrValuePartialMap.get(attrName);
|
||||
if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
|
||||
result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector,
|
||||
matchedCallback) ||
|
||||
@ -304,8 +304,8 @@ export class SelectorMatcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
var selectables = MapWrapper.get(map, name);
|
||||
var starSelectables = MapWrapper.get(map, "*");
|
||||
var selectables = map.get(name);
|
||||
var starSelectables = map.get("*");
|
||||
if (isPresent(starSelectables)) {
|
||||
selectables = ListWrapper.concat(selectables, starSelectables);
|
||||
}
|
||||
@ -326,7 +326,7 @@ export class SelectorMatcher {
|
||||
if (isBlank(map) || isBlank(name)) {
|
||||
return false;
|
||||
}
|
||||
var nestedSelector = MapWrapper.get(map, name);
|
||||
var nestedSelector = map.get(name);
|
||||
if (isBlank(nestedSelector)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
*/
|
||||
@Injectable()
|
||||
export class TemplateLoader {
|
||||
_cache: Map<string, Promise<string>> = MapWrapper.create();
|
||||
_cache: Map<string, Promise<string>> = new Map();
|
||||
|
||||
constructor(private _xhr: XHR, urlResolver: UrlResolver) {}
|
||||
|
||||
@ -52,7 +52,7 @@ export class TemplateLoader {
|
||||
}
|
||||
|
||||
private _loadText(url: string): Promise<string> {
|
||||
var response = MapWrapper.get(this._cache, url);
|
||||
var response = this._cache.get(url);
|
||||
|
||||
if (isBlank(response)) {
|
||||
// TODO(vicb): change error when TS gets fixed
|
||||
@ -62,7 +62,7 @@ export class TemplateLoader {
|
||||
this._xhr.get(url),
|
||||
_ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null));
|
||||
|
||||
MapWrapper.set(this._cache, url, response);
|
||||
this._cache.set(url, response);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
@ -30,7 +30,7 @@ export class ViewSplitter implements CompileStep {
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
var attrs = current.attrs();
|
||||
var templateBindings = MapWrapper.get(attrs, 'template');
|
||||
var templateBindings = attrs.get('template');
|
||||
var hasTemplateBinding = isPresent(templateBindings);
|
||||
|
||||
// look for template shortcuts such as *ng-if="condition" and treat them as template="if
|
||||
@ -106,11 +106,11 @@ export class ViewSplitter implements CompileStep {
|
||||
var binding = bindings[i];
|
||||
if (binding.keyIsVar) {
|
||||
compileElement.bindElement().bindVariable(dashCaseToCamelCase(binding.key), binding.name);
|
||||
MapWrapper.set(compileElement.attrs(), binding.key, binding.name);
|
||||
compileElement.attrs().set(binding.key, binding.name);
|
||||
} else if (isPresent(binding.expression)) {
|
||||
compileElement.bindElement().bindProperty(dashCaseToCamelCase(binding.key),
|
||||
binding.expression);
|
||||
MapWrapper.set(compileElement.attrs(), binding.key, binding.expression.source);
|
||||
compileElement.attrs().set(binding.key, binding.expression.source);
|
||||
} else {
|
||||
DOM.setAttribute(compileElement.element, binding.key, '');
|
||||
}
|
||||
|
@ -37,24 +37,24 @@ export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any
|
||||
*/
|
||||
export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata {
|
||||
return new DirectiveMetadata({
|
||||
id:<string>MapWrapper.get(map, 'id'),
|
||||
selector:<string>MapWrapper.get(map, 'selector'),
|
||||
compileChildren:<boolean>MapWrapper.get(map, 'compileChildren'),
|
||||
hostProperties:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostProperties')),
|
||||
hostListeners:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostListeners')),
|
||||
hostActions:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostActions')),
|
||||
hostAttributes:<Map<string, string>>_cloneIfPresent(MapWrapper.get(map, 'hostAttributes')),
|
||||
properties:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'properties')),
|
||||
readAttributes:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'readAttributes')),
|
||||
type:<number>MapWrapper.get(map, 'type'),
|
||||
exportAs:<string>MapWrapper.get(map, 'exportAs'),
|
||||
callOnDestroy:<boolean>MapWrapper.get(map, 'callOnDestroy'),
|
||||
callOnCheck:<boolean>MapWrapper.get(map, 'callOnCheck'),
|
||||
callOnChange:<boolean>MapWrapper.get(map, 'callOnChange'),
|
||||
callOnInit:<boolean>MapWrapper.get(map, 'callOnInit'),
|
||||
callOnAllChangesDone:<boolean>MapWrapper.get(map, 'callOnAllChangesDone'),
|
||||
events:<List<string>>_cloneIfPresent(MapWrapper.get(map, 'events')),
|
||||
changeDetection:<string>MapWrapper.get(map, 'changeDetection'),
|
||||
id:<string>map.get('id'),
|
||||
selector:<string>map.get('selector'),
|
||||
compileChildren:<boolean>map.get('compileChildren'),
|
||||
hostProperties:<Map<string, string>>_cloneIfPresent(map.get('hostProperties')),
|
||||
hostListeners:<Map<string, string>>_cloneIfPresent(map.get('hostListeners')),
|
||||
hostActions:<Map<string, string>>_cloneIfPresent(map.get('hostActions')),
|
||||
hostAttributes:<Map<string, string>>_cloneIfPresent(map.get('hostAttributes')),
|
||||
properties:<List<string>>_cloneIfPresent(map.get('properties')),
|
||||
readAttributes:<List<string>>_cloneIfPresent(map.get('readAttributes')),
|
||||
type:<number>map.get('type'),
|
||||
exportAs:<string>map.get('exportAs'),
|
||||
callOnDestroy:<boolean>map.get('callOnDestroy'),
|
||||
callOnCheck:<boolean>map.get('callOnCheck'),
|
||||
callOnChange:<boolean>map.get('callOnChange'),
|
||||
callOnInit:<boolean>map.get('callOnInit'),
|
||||
callOnAllChangesDone:<boolean>map.get('callOnAllChangesDone'),
|
||||
events:<List<string>>_cloneIfPresent(map.get('events')),
|
||||
changeDetection:<string>map.get('changeDetection'),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class ShadowDomCompileStep implements CompileStep {
|
||||
return;
|
||||
}
|
||||
var attrs = current.attrs();
|
||||
var selector = MapWrapper.get(attrs, 'select');
|
||||
var selector = attrs.get('select');
|
||||
selector = isPresent(selector) ? selector : '';
|
||||
|
||||
// The content tag should be replaced by a pair of marker tags (start & end).
|
||||
|
@ -5,16 +5,16 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {ShadowCss} from './shadow_css';
|
||||
|
||||
var _componentUIDs: Map<string, int> = MapWrapper.create();
|
||||
var _componentUIDs: Map<string, int> = new Map();
|
||||
var _nextComponentUID: int = 0;
|
||||
var _sharedStyleTexts: Map<string, boolean> = MapWrapper.create();
|
||||
var _sharedStyleTexts: Map<string, boolean> = new Map();
|
||||
var _lastInsertedStyleEl;
|
||||
|
||||
export function getComponentId(componentStringId: string) {
|
||||
var id = MapWrapper.get(_componentUIDs, componentStringId);
|
||||
var id = _componentUIDs.get(componentStringId);
|
||||
if (isBlank(id)) {
|
||||
id = _nextComponentUID++;
|
||||
MapWrapper.set(_componentUIDs, componentStringId, id);
|
||||
_componentUIDs.set(componentStringId, id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@ -23,7 +23,7 @@ export function insertSharedStyleText(cssText, styleHost, styleEl) {
|
||||
if (!MapWrapper.contains(_sharedStyleTexts, cssText)) {
|
||||
// Styles are unscoped and shared across components, only append them to the head
|
||||
// when there are not present yet
|
||||
MapWrapper.set(_sharedStyleTexts, cssText, true);
|
||||
_sharedStyleTexts.set(cssText, true);
|
||||
insertStyleElement(styleHost, styleEl);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import * as api from '../../api';
|
||||
import {NG_BINDING_CLASS, EVENT_TARGET_SEPARATOR} from '../util';
|
||||
|
||||
export class ProtoViewBuilder {
|
||||
variableBindings: Map<string, string> = MapWrapper.create();
|
||||
variableBindings: Map<string, string> = new Map();
|
||||
elements: List<ElementBinderBuilder> = [];
|
||||
|
||||
constructor(public rootElement, public type: api.ViewType) {}
|
||||
@ -40,7 +40,7 @@ export class ProtoViewBuilder {
|
||||
// by the "value", or exported identifier. For example, ng-for sets a view local of "index".
|
||||
// When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing
|
||||
// it.
|
||||
MapWrapper.set(this.variableBindings, value, name);
|
||||
this.variableBindings.set(value, name);
|
||||
}
|
||||
|
||||
build(setterFactory: PropertySetterFactory): api.ProtoViewDto {
|
||||
@ -49,20 +49,20 @@ export class ProtoViewBuilder {
|
||||
var apiElementBinders = [];
|
||||
var transitiveContentTagCount = 0;
|
||||
ListWrapper.forEach(this.elements, (ebb: ElementBinderBuilder) => {
|
||||
var propertySetters = MapWrapper.create();
|
||||
var hostActions = MapWrapper.create();
|
||||
var propertySetters = new Map();
|
||||
var hostActions = new Map();
|
||||
|
||||
var apiDirectiveBinders = ListWrapper.map(ebb.directives, (dbb: DirectiveBuilder) => {
|
||||
ebb.eventBuilder.merge(dbb.eventBuilder);
|
||||
|
||||
MapWrapper.forEach(dbb.hostPropertyBindings, (_, hostPropertyName) => {
|
||||
MapWrapper.set(propertySetters, hostPropertyName,
|
||||
setterFactory.createSetter(ebb.element, isPresent(ebb.componentId),
|
||||
hostPropertyName));
|
||||
propertySetters.set(hostPropertyName,
|
||||
setterFactory.createSetter(ebb.element, isPresent(ebb.componentId),
|
||||
hostPropertyName));
|
||||
});
|
||||
|
||||
ListWrapper.forEach(dbb.hostActions, (hostAction) => {
|
||||
MapWrapper.set(hostActions, hostAction.actionExpression, hostAction.expression);
|
||||
hostActions.set(hostAction.actionExpression, hostAction.expression);
|
||||
});
|
||||
|
||||
return new api.DirectiveBinder({
|
||||
@ -74,8 +74,9 @@ export class ProtoViewBuilder {
|
||||
});
|
||||
|
||||
MapWrapper.forEach(ebb.propertyBindings, (_, propertyName) => {
|
||||
MapWrapper.set(
|
||||
propertySetters, propertyName,
|
||||
|
||||
propertySetters.set(
|
||||
propertyName,
|
||||
setterFactory.createSetter(ebb.element, isPresent(ebb.componentId), propertyName));
|
||||
});
|
||||
|
||||
@ -149,14 +150,14 @@ export class ElementBinderBuilder {
|
||||
distanceToParent: number = 0;
|
||||
directives: List<DirectiveBuilder> = [];
|
||||
nestedProtoView: ProtoViewBuilder = null;
|
||||
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
variableBindings: Map<string, string> = MapWrapper.create();
|
||||
propertyBindings: Map<string, ASTWithSource> = new Map();
|
||||
variableBindings: Map<string, string> = new Map();
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
textBindingIndices: List<number> = [];
|
||||
textBindings: List<ASTWithSource> = [];
|
||||
contentTagSelector: string = null;
|
||||
readAttributes: Map<string, string> = MapWrapper.create();
|
||||
readAttributes: Map<string, string> = new Map();
|
||||
componentId: string = null;
|
||||
|
||||
constructor(public index: number, public element, description: string) {}
|
||||
@ -170,8 +171,8 @@ export class ElementBinderBuilder {
|
||||
}
|
||||
|
||||
readAttribute(attrName: string) {
|
||||
if (isBlank(MapWrapper.get(this.readAttributes, attrName))) {
|
||||
MapWrapper.set(this.readAttributes, attrName, DOM.getAttribute(this.element, attrName));
|
||||
if (isBlank(this.readAttributes.get(attrName))) {
|
||||
this.readAttributes.set(attrName, DOM.getAttribute(this.element, attrName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +190,7 @@ export class ElementBinderBuilder {
|
||||
return this.nestedProtoView;
|
||||
}
|
||||
|
||||
bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); }
|
||||
bindProperty(name, expression) { this.propertyBindings.set(name, expression); }
|
||||
|
||||
bindVariable(name, value) {
|
||||
// When current is a view root, the variable bindings are set to the *nested* proto view.
|
||||
@ -205,7 +206,7 @@ export class ElementBinderBuilder {
|
||||
// When this occurs, a lookup keyed by "index" must occur to find if there is a var
|
||||
// referencing
|
||||
// it.
|
||||
MapWrapper.set(this.variableBindings, value, name);
|
||||
this.variableBindings.set(value, name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,19 +225,17 @@ export class ElementBinderBuilder {
|
||||
}
|
||||
|
||||
export class DirectiveBuilder {
|
||||
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
hostPropertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
propertyBindings: Map<string, ASTWithSource> = new Map();
|
||||
hostPropertyBindings: Map<string, ASTWithSource> = new Map();
|
||||
hostActions: List<HostAction> = [];
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
|
||||
constructor(public directiveIndex: number) {}
|
||||
|
||||
bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); }
|
||||
bindProperty(name, expression) { this.propertyBindings.set(name, expression); }
|
||||
|
||||
bindHostProperty(name, expression) {
|
||||
MapWrapper.set(this.hostPropertyBindings, name, expression);
|
||||
}
|
||||
bindHostProperty(name, expression) { this.hostPropertyBindings.set(name, expression); }
|
||||
|
||||
bindHostAction(actionName: string, actionExpression: string, expression: ASTWithSource) {
|
||||
this.hostActions.push(new HostAction(actionName, actionExpression, expression));
|
||||
|
@ -40,20 +40,19 @@ export class DomView {
|
||||
}
|
||||
|
||||
setElementProperty(elementIndex: number, propertyName: string, value: any) {
|
||||
var setter =
|
||||
MapWrapper.get(this.proto.elementBinders[elementIndex].propertySetters, propertyName);
|
||||
var setter = this.proto.elementBinders[elementIndex].propertySetters.get(propertyName);
|
||||
setter(this.boundElements[elementIndex].element, value);
|
||||
}
|
||||
|
||||
callAction(elementIndex: number, actionExpression: string, actionArgs: any) {
|
||||
var binder = this.proto.elementBinders[elementIndex];
|
||||
var hostAction = MapWrapper.get(binder.hostActions, actionExpression);
|
||||
var hostAction = binder.hostActions.get(actionExpression);
|
||||
hostAction.eval(this.boundElements[elementIndex].element, this._localsWithAction(actionArgs));
|
||||
}
|
||||
|
||||
_localsWithAction(action: Object): Locals {
|
||||
var map = MapWrapper.create();
|
||||
MapWrapper.set(map, '$action', action);
|
||||
var map = new Map();
|
||||
map.set('$action', action);
|
||||
return new Locals(null, map);
|
||||
}
|
||||
|
||||
@ -62,8 +61,8 @@ export class DomView {
|
||||
dispatchEvent(elementIndex, eventName, event): boolean {
|
||||
var allowDefaultBehavior = true;
|
||||
if (isPresent(this.eventDispatcher)) {
|
||||
var evalLocals = MapWrapper.create();
|
||||
MapWrapper.set(evalLocals, '$event', event);
|
||||
var evalLocals = new Map();
|
||||
evalLocals.set('$event', event);
|
||||
// TODO(tbosch): reenable this when we are parsing element properties
|
||||
// out of action expressions
|
||||
// var localValues = this.proto.elementBinders[elementIndex].eventLocals.eval(null, new
|
||||
|
@ -11,7 +11,7 @@ export class MockXHR extends XHR {
|
||||
constructor() {
|
||||
super();
|
||||
this._expectations = [];
|
||||
this._definitions = MapWrapper.create();
|
||||
this._definitions = new Map();
|
||||
this._requests = [];
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export class MockXHR extends XHR {
|
||||
this._expectations.push(expectation);
|
||||
}
|
||||
|
||||
when(url: string, response: string) { MapWrapper.set(this._definitions, url, response); }
|
||||
when(url: string, response: string) { this._definitions.set(url, response); }
|
||||
|
||||
flush() {
|
||||
if (this._requests.length === 0) {
|
||||
@ -66,7 +66,7 @@ export class MockXHR extends XHR {
|
||||
}
|
||||
|
||||
if (MapWrapper.contains(this._definitions, url)) {
|
||||
var response = MapWrapper.get(this._definitions, url);
|
||||
var response = this._definitions.get(url);
|
||||
request.complete(normalizeBlank(response));
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user