2015-09-08 13:14:57 -04:00
|
|
|
import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
2015-09-10 18:25:36 -04:00
|
|
|
import {Type, isPresent, stringify, isBlank, print} from 'angular2/src/core/facade/lang';
|
2015-09-08 13:14:57 -04:00
|
|
|
import {DirectiveMetadata, ComponentMetadata} from '../core/metadata';
|
2015-10-02 10:37:23 -04:00
|
|
|
import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver';
|
2015-09-08 13:14:57 -04:00
|
|
|
|
|
|
|
export class MockDirectiveResolver extends DirectiveResolver {
|
2015-09-29 14:11:06 -04:00
|
|
|
private _bindingsOverrides = new Map<Type, any[]>();
|
|
|
|
private _viewBindingsOverrides = new Map<Type, any[]>();
|
2015-09-08 13:14:57 -04:00
|
|
|
|
|
|
|
resolve(type: Type): DirectiveMetadata {
|
|
|
|
var dm = super.resolve(type);
|
|
|
|
|
|
|
|
var bindingsOverride = this._bindingsOverrides.get(type);
|
|
|
|
var viewBindingsOverride = this._viewBindingsOverrides.get(type);
|
|
|
|
|
|
|
|
var bindings = dm.bindings;
|
|
|
|
if (isPresent(bindingsOverride)) {
|
|
|
|
bindings = dm.bindings.concat(bindingsOverride);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dm instanceof ComponentMetadata) {
|
|
|
|
var viewBindings = dm.viewBindings;
|
|
|
|
if (isPresent(viewBindingsOverride)) {
|
|
|
|
viewBindings = dm.viewBindings.concat(viewBindingsOverride);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ComponentMetadata({
|
|
|
|
selector: dm.selector,
|
2015-09-30 23:59:23 -04:00
|
|
|
inputs: dm.inputs,
|
|
|
|
outputs: dm.outputs,
|
2015-09-08 13:14:57 -04:00
|
|
|
host: dm.host,
|
|
|
|
bindings: bindings,
|
|
|
|
exportAs: dm.exportAs,
|
2015-09-14 18:59:09 -04:00
|
|
|
moduleId: dm.moduleId,
|
2015-09-17 21:45:14 -04:00
|
|
|
queries: dm.queries,
|
2015-09-08 13:14:57 -04:00
|
|
|
changeDetection: dm.changeDetection,
|
|
|
|
viewBindings: viewBindings
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return new DirectiveMetadata({
|
|
|
|
selector: dm.selector,
|
2015-09-30 23:59:23 -04:00
|
|
|
inputs: dm.inputs,
|
|
|
|
outputs: dm.outputs,
|
2015-09-08 13:14:57 -04:00
|
|
|
host: dm.host,
|
|
|
|
bindings: bindings,
|
|
|
|
exportAs: dm.exportAs,
|
2015-09-14 18:59:09 -04:00
|
|
|
moduleId: dm.moduleId,
|
2015-09-17 21:45:14 -04:00
|
|
|
queries: dm.queries
|
2015-09-08 13:14:57 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setBindingsOverride(type: Type, bindings: any[]): void {
|
|
|
|
this._bindingsOverrides.set(type, bindings);
|
|
|
|
}
|
|
|
|
|
|
|
|
setViewBindingsOverride(type: Type, viewBindings: any[]): void {
|
|
|
|
this._viewBindingsOverrides.set(type, viewBindings);
|
|
|
|
}
|
|
|
|
}
|