refactor(compiler): cleanup and preparation for integration
- Rename `DirectiveMetadata` into `CompileDirectiveMetadata`, merge with `NormalizedDirectiveMetadata` and remove `ChangeDetectionMetadata` - Store change detector factories not as array but directly at the `CompiledTemplate` or the embedded template to make instantiation easier later on - Already analyze variable values and map them to `Directive.exportAs` - Keep the directive sort order as specified in the `@View()` annotation - Allow to clear the runtime cache in `StyleCompiler` and `TemplateCompiler` - Ignore `script` elements to match the semantics of the current compiler - Make all components dynamically loadable and remove the previously introduced property `@Component#dynamicLoadable` for now until we find a better option to configure this - Don’t allow to specify bindings in `@View#directives` and `@View#pipes` as this was never supported by the transformer (see below for the breaking change) BREAKING CHANGE: - don't support DI bindings in `@View#directives` and `@View@pipes` any more in preparation of integrating the new compiler. Use `@Directive#bindings` to reexport directives under a different token instead. Part of #3605 Closes #4314
This commit is contained in:
@ -397,23 +397,6 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should use the last directive binding per directive',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<p no-duplicate></p>',
|
||||
directives: [
|
||||
bind(DuplicateDir)
|
||||
.toClass(DuplicateDir),
|
||||
bind(DuplicateDir).toClass(OtherDuplicateDir)
|
||||
]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('othernoduplicate');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support directives where a selector matches property binding',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata(
|
||||
@ -436,27 +419,11 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow specifying directives as bindings',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp></child-cmp>',
|
||||
directives: [bind(ChildComp).toClass(ChildComp)]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should read directives metadata from their binding token',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<div public-api><div needs-public-api></div></div>',
|
||||
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
|
||||
directives: [PrivateImpl, NeedsPublicApi]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
@ -2043,12 +2010,14 @@ class NeedsAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({selector: '[public-api]'})
|
||||
@Injectable()
|
||||
class PublicApi {
|
||||
}
|
||||
|
||||
@Directive({selector: '[private-impl]'})
|
||||
@Directive({
|
||||
selector: '[public-api]',
|
||||
bindings: [new Binding(PublicApi, {toAlias: PrivateImpl, deps: []})]
|
||||
})
|
||||
@Injectable()
|
||||
class PrivateImpl extends PublicApi {
|
||||
}
|
||||
|
Reference in New Issue
Block a user