Closes #3605 BREAKING CHANGE: - we don't mark an element as bound any more if it only contains text bindings E.g. <div>{{hello}}</div> This changes the indices when using `DebugElement.componentViewChildren` / `DebugElement.children`. - `@Directive.compileChildren` was removed, `ng-non-bindable` is now builtin and not a directive any more - angular no more adds the `ng-binding` class to elements with bindings - directives are now ordered as they are listed in the View.directives regarding change detection. Previously they had an undefined order. - the `Renderer` interface has new methods `createProtoView` and `registerComponentTemplate`. See `DomRenderer` for default implementations. - reprojection with `ng-content` is now all or nothing per `ng-content` element - angular2 transformer can't be used in tests that modify directive metadata. Use `angular2/src/transform/inliner_for_test` transformer instead.
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
|
import {Type, isPresent, stringify, isBlank, print} from 'angular2/src/core/facade/lang';
|
|
import {DirectiveMetadata, ComponentMetadata} from '../core/metadata';
|
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
|
|
|
export class MockDirectiveResolver extends DirectiveResolver {
|
|
private _bindingsOverrides = new Map<Type, any[]>();
|
|
private _viewBindingsOverrides = new Map<Type, any[]>();
|
|
|
|
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,
|
|
inputs: dm.inputs,
|
|
outputs: dm.outputs,
|
|
host: dm.host,
|
|
bindings: bindings,
|
|
exportAs: dm.exportAs,
|
|
moduleId: dm.moduleId,
|
|
queries: dm.queries,
|
|
changeDetection: dm.changeDetection,
|
|
viewBindings: viewBindings
|
|
});
|
|
}
|
|
|
|
return new DirectiveMetadata({
|
|
selector: dm.selector,
|
|
inputs: dm.inputs,
|
|
outputs: dm.outputs,
|
|
host: dm.host,
|
|
bindings: bindings,
|
|
exportAs: dm.exportAs,
|
|
moduleId: dm.moduleId,
|
|
queries: dm.queries
|
|
});
|
|
}
|
|
|
|
setBindingsOverride(type: Type, bindings: any[]): void {
|
|
this._bindingsOverrides.set(type, bindings);
|
|
}
|
|
|
|
setViewBindingsOverride(type: Type, viewBindings: any[]): void {
|
|
this._viewBindingsOverrides.set(type, viewBindings);
|
|
}
|
|
}
|