feat: remove MapWrapper.contains().
This commit is contained in:
parent
be7ac9fd41
commit
dfd30910aa
|
@ -5,7 +5,7 @@ export class Locals {
|
||||||
constructor(public parent: Locals, public current: Map<any, any>) {}
|
constructor(public parent: Locals, public current: Map<any, any>) {}
|
||||||
|
|
||||||
contains(name: string): boolean {
|
contains(name: string): boolean {
|
||||||
if (MapWrapper.contains(this.current, name)) {
|
if (this.current.has(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export class Locals {
|
||||||
}
|
}
|
||||||
|
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
if (MapWrapper.contains(this.current, name)) {
|
if (this.current.has(name)) {
|
||||||
return this.current.get(name);
|
return this.current.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export class Locals {
|
||||||
// TODO(rado): consider removing this check if we can guarantee this is not
|
// TODO(rado): consider removing this check if we can guarantee this is not
|
||||||
// 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 (this.current.has(name)) {
|
||||||
this.current.set(name, value);
|
this.current.set(name, value);
|
||||||
} else {
|
} else {
|
||||||
throw new BaseException(
|
throw new BaseException(
|
||||||
|
|
|
@ -105,7 +105,7 @@ export class KeyValueChanges extends Pipe {
|
||||||
this._removeFromSeq(lastOldSeqRecord, oldSeqRecord);
|
this._removeFromSeq(lastOldSeqRecord, oldSeqRecord);
|
||||||
this._addToRemovals(oldSeqRecord);
|
this._addToRemovals(oldSeqRecord);
|
||||||
}
|
}
|
||||||
if (MapWrapper.contains(records, key)) {
|
if (records.has(key)) {
|
||||||
newSeqRecord = records.get(key);
|
newSeqRecord = records.get(key);
|
||||||
} else {
|
} else {
|
||||||
newSeqRecord = new KVChangeRecord(key);
|
newSeqRecord = new KVChangeRecord(key);
|
||||||
|
|
|
@ -421,7 +421,7 @@ export class ProtoElementInjector {
|
||||||
var visitedIds: Map<number, boolean> = new Map();
|
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 (visitedIds.has(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)}"`);
|
||||||
}
|
}
|
||||||
|
@ -730,7 +730,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
|
||||||
|
|
||||||
hasVariableBinding(name: string): boolean {
|
hasVariableBinding(name: string): boolean {
|
||||||
var vb = this._proto.directiveVariableBindings;
|
var vb = this._proto.directiveVariableBindings;
|
||||||
return isPresent(vb) && MapWrapper.contains(vb, name);
|
return isPresent(vb) && vb.has(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
getVariableBinding(name: string): any {
|
getVariableBinding(name: string): any {
|
||||||
|
@ -891,7 +891,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) && attributes.has(dep.attributeName)) {
|
||||||
return attributes.get(dep.attributeName);
|
return attributes.get(dep.attributeName);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -115,7 +115,7 @@ class BindingRecordsCreator {
|
||||||
directiveMetadata: renderApi.DirectiveMetadata): DirectiveRecord {
|
directiveMetadata: renderApi.DirectiveMetadata): DirectiveRecord {
|
||||||
var id = boundElementIndex * 100 + directiveIndex;
|
var id = boundElementIndex * 100 + directiveIndex;
|
||||||
|
|
||||||
if (!MapWrapper.contains(this._directiveRecordsMap, id)) {
|
if (!this._directiveRecordsMap.has(id)) {
|
||||||
this._directiveRecordsMap.set(
|
this._directiveRecordsMap.set(
|
||||||
id, new DirectiveRecord({
|
id, new DirectiveRecord({
|
||||||
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
|
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class AppView implements ChangeDispatcher, EventDispatcher {
|
||||||
|
|
||||||
setLocal(contextName: string, value): void {
|
setLocal(contextName: string, value): void {
|
||||||
if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.');
|
if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.');
|
||||||
if (!MapWrapper.contains(this.proto.variableBindings, contextName)) {
|
if (!this.proto.variableBindings.has(contextName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var templateName = this.proto.variableBindings.get(contextName);
|
var templateName = this.proto.variableBindings.get(contextName);
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class TestabilityRegistry {
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (MapWrapper.contains(this._applications, elem)) {
|
if (this._applications.has(elem)) {
|
||||||
return this._applications.get(elem);
|
return this._applications.get(elem);
|
||||||
}
|
}
|
||||||
if (DOM.isShadowRoot(elem)) {
|
if (DOM.isShadowRoot(elem)) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class KeyRegistry {
|
||||||
}
|
}
|
||||||
token = theToken;
|
token = theToken;
|
||||||
|
|
||||||
if (MapWrapper.contains(this._allKeys, token)) {
|
if (this._allKeys.has(token)) {
|
||||||
return this._allKeys.get(token);
|
return this._allKeys.get(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ class MapWrapper {
|
||||||
m[p[0]] = p[1];
|
m[p[0]] = p[1];
|
||||||
return m;
|
return m;
|
||||||
});
|
});
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ export class MapWrapper {
|
||||||
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 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; }
|
||||||
static delete<K>(m: Map<K, any>, k: K) { m.delete(k); }
|
static delete<K>(m: Map<K, any>, k: K) { m.delete(k); }
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class Headers {
|
||||||
|
|
||||||
get(header: string): string { return ListWrapper.first(this._headersMap.get(header)); }
|
get(header: string): string { return ListWrapper.first(this._headersMap.get(header)); }
|
||||||
|
|
||||||
has(header: string) { return MapWrapper.contains(this._headersMap, header); }
|
has(header: string) { return this._headersMap.has(header); }
|
||||||
|
|
||||||
keys() { return MapWrapper.keys(this._headersMap); }
|
keys() { return MapWrapper.keys(this._headersMap); }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class URLSearchParams {
|
||||||
paramsMap: Map<string, List<string>>;
|
paramsMap: Map<string, List<string>>;
|
||||||
constructor(public rawParams: string) { this.paramsMap = paramParser(rawParams); }
|
constructor(public rawParams: string) { this.paramsMap = paramParser(rawParams); }
|
||||||
|
|
||||||
has(param: string): boolean { return MapWrapper.contains(this.paramsMap, param); }
|
has(param: string): boolean { return this.paramsMap.has(param); }
|
||||||
|
|
||||||
get(param: string): string { return ListWrapper.first(this.paramsMap.get(param)); }
|
get(param: string): string { return ListWrapper.first(this.paramsMap.get(param)); }
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters(typeOrFunc): List<any> {
|
parameters(typeOrFunc): List<any> {
|
||||||
if (MapWrapper.contains(this._typeInfo, typeOrFunc)) {
|
if (this._typeInfo.has(typeOrFunc)) {
|
||||||
return this._getTypeInfoField(typeOrFunc, "parameters", []);
|
return this._getTypeInfoField(typeOrFunc, "parameters", []);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.parameters(typeOrFunc);
|
return this.reflectionCapabilities.parameters(typeOrFunc);
|
||||||
|
@ -60,7 +60,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations(typeOrFunc): List<any> {
|
annotations(typeOrFunc): List<any> {
|
||||||
if (MapWrapper.contains(this._typeInfo, typeOrFunc)) {
|
if (this._typeInfo.has(typeOrFunc)) {
|
||||||
return this._getTypeInfoField(typeOrFunc, "annotations", []);
|
return this._getTypeInfoField(typeOrFunc, "annotations", []);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.annotations(typeOrFunc);
|
return this.reflectionCapabilities.annotations(typeOrFunc);
|
||||||
|
@ -68,7 +68,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
interfaces(type): List<any> {
|
interfaces(type): List<any> {
|
||||||
if (MapWrapper.contains(this._typeInfo, type)) {
|
if (this._typeInfo.has(type)) {
|
||||||
return this._getTypeInfoField(type, "interfaces", []);
|
return this._getTypeInfoField(type, "interfaces", []);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.interfaces(type);
|
return this.reflectionCapabilities.interfaces(type);
|
||||||
|
@ -76,7 +76,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
getter(name: string): GetterFn {
|
getter(name: string): GetterFn {
|
||||||
if (MapWrapper.contains(this._getters, name)) {
|
if (this._getters.has(name)) {
|
||||||
return this._getters.get(name);
|
return this._getters.get(name);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.getter(name);
|
return this.reflectionCapabilities.getter(name);
|
||||||
|
@ -84,7 +84,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
setter(name: string): SetterFn {
|
setter(name: string): SetterFn {
|
||||||
if (MapWrapper.contains(this._setters, name)) {
|
if (this._setters.has(name)) {
|
||||||
return this._setters.get(name);
|
return this._setters.get(name);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.setter(name);
|
return this.reflectionCapabilities.setter(name);
|
||||||
|
@ -92,7 +92,7 @@ export class Reflector {
|
||||||
}
|
}
|
||||||
|
|
||||||
method(name: string): MethodFn {
|
method(name: string): MethodFn {
|
||||||
if (MapWrapper.contains(this._methods, name)) {
|
if (this._methods.has(name)) {
|
||||||
return this._methods.get(name);
|
return this._methods.get(name);
|
||||||
} else {
|
} else {
|
||||||
return this.reflectionCapabilities.method(name);
|
return this.reflectionCapabilities.method(name);
|
||||||
|
@ -104,7 +104,7 @@ export class Reflector {
|
||||||
return isPresent(res) ? res : defaultValue;
|
return isPresent(res) ? res : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_containsTypeInfo(typeOrFunc) { return MapWrapper.contains(this._typeInfo, typeOrFunc); }
|
_containsTypeInfo(typeOrFunc) { return this._typeInfo.has(typeOrFunc); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {
|
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export function getComponentId(componentStringId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function insertSharedStyleText(cssText, styleHost, styleEl) {
|
export function insertSharedStyleText(cssText, styleHost, styleEl) {
|
||||||
if (!MapWrapper.contains(_sharedStyleTexts, cssText)) {
|
if (!_sharedStyleTexts.has(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
|
||||||
_sharedStyleTexts.set(cssText, true);
|
_sharedStyleTexts.set(cssText, true);
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class MockXHR extends XHR {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MapWrapper.contains(this._definitions, url)) {
|
if (this._definitions.has(url)) {
|
||||||
var response = this._definitions.get(url);
|
var response = this._definitions.get(url);
|
||||||
request.complete(normalizeBlank(response));
|
request.complete(normalizeBlank(response));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class RouteRecognizer {
|
||||||
return solutions;
|
return solutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasRoute(name: string): boolean { return MapWrapper.contains(this.names, name); }
|
hasRoute(name: string): boolean { return this.names.has(name); }
|
||||||
|
|
||||||
generate(name: string, params: any): string {
|
generate(name: string, params: any): string {
|
||||||
var pathRecognizer = this.names.get(name);
|
var pathRecognizer = this.names.get(name);
|
||||||
|
|
|
@ -69,7 +69,7 @@ export class RouteRegistry {
|
||||||
|
|
||||||
// Don't read the annotations from a type more than once –
|
// Don't read the annotations from a type more than once –
|
||||||
// this prevents an infinite loop if a component routes recursively.
|
// this prevents an infinite loop if a component routes recursively.
|
||||||
if (MapWrapper.contains(this._rules, component)) {
|
if (this._rules.has(component)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var annotations = reflector.annotations(component);
|
var annotations = reflector.annotations(component);
|
||||||
|
|
|
@ -198,7 +198,7 @@ class MockStep implements CompileStep {
|
||||||
export class IgnoreChildrenStep implements CompileStep {
|
export class IgnoreChildrenStep implements CompileStep {
|
||||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||||
var attributeMap = DOM.attributeMap(current.element);
|
var attributeMap = DOM.attributeMap(current.element);
|
||||||
if (MapWrapper.contains(attributeMap, 'ignore-children')) {
|
if (attributeMap.has('ignore-children')) {
|
||||||
current.compileChildren = false;
|
current.compileChildren = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ export class IgnoreChildrenStep implements CompileStep {
|
||||||
class IgnoreCurrentElementStep implements CompileStep {
|
class IgnoreCurrentElementStep implements CompileStep {
|
||||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||||
var attributeMap = DOM.attributeMap(current.element);
|
var attributeMap = DOM.attributeMap(current.element);
|
||||||
if (MapWrapper.contains(attributeMap, 'ignore-current')) {
|
if (attributeMap.has('ignore-current')) {
|
||||||
control.ignoreCurrentElement();
|
control.ignoreCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,9 @@ export function main() {
|
||||||
var manager = new EventManager([plugin1, plugin2], new FakeNgZone());
|
var manager = new EventManager([plugin1, plugin2], new FakeNgZone());
|
||||||
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(plugin1._nonBubbleEventHandlers.has('click')).toBe(false);
|
||||||
expect(plugin2._nonBubbleEventHandlers.get('click')).toBe(clickHandler);
|
expect(plugin2._nonBubbleEventHandlers.get('click')).toBe(clickHandler);
|
||||||
expect(MapWrapper.contains(plugin2._nonBubbleEventHandlers, 'dblclick')).toBe(false);
|
expect(plugin2._nonBubbleEventHandlers.has('dblclick')).toBe(false);
|
||||||
expect(plugin1._nonBubbleEventHandlers.get('dblclick')).toBe(dblClickHandler);
|
expect(plugin1._nonBubbleEventHandlers.get('dblclick')).toBe(dblClickHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue