feat(core): support properties and events in addition to inputs and outputs to make transition easier

Closes #4482
This commit is contained in:
vsavkin
2015-10-02 16:21:49 -07:00
committed by Victor Savkin
parent 5ea6dc844c
commit c9901c5fe0
8 changed files with 93 additions and 8 deletions

View File

@ -26,7 +26,7 @@ class SomeChildDirective extends SomeDirective {
}
@Directive({selector: 'someDirective', inputs: ['c']})
class SomeDirectiveWithProperties {
class SomeDirectiveWithInputs {
@Input() a;
@Input("renamed") b;
c;
@ -39,6 +39,15 @@ class SomeDirectiveWithOutputs {
c;
}
@Directive({selector: 'someDirective', properties: ['a']})
class SomeDirectiveWithProperties {
}
@Directive({selector: 'someDirective', events: ['a']})
class SomeDirectiveWithEvents {
}
@Directive({selector: 'someDirective'})
class SomeDirectiveWithSetterProps {
@ -125,7 +134,7 @@ export function main() {
describe('inputs', () => {
it('should append directive inputs', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithProperties);
var directiveMetadata = resolver.resolve(SomeDirectiveWithInputs);
expect(directiveMetadata.inputs).toEqual(['c', 'a', 'b: renamed']);
});
@ -133,6 +142,12 @@ export function main() {
var directiveMetadata = resolver.resolve(SomeDirectiveWithSetterProps);
expect(directiveMetadata.inputs).toEqual(['a: renamed']);
});
it('should use properties as inputs', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithProperties);
expect(directiveMetadata.inputs).toEqual(['a']);
});
});
describe('outputs', () => {
@ -145,6 +160,11 @@ export function main() {
var directiveMetadata = resolver.resolve(SomeDirectiveWithGetterOutputs);
expect(directiveMetadata.outputs).toEqual(['a: renamed']);
});
it('should use events as outputs', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithEvents);
expect(directiveMetadata.outputs).toEqual(['a']);
});
});
describe('host', () => {

View File

@ -157,10 +157,12 @@ var NG_API = [
'Component.bindings',
'Component.changeDetection',
'Component.outputs',
'Component.events',
'Component.exportAs',
'Component.host',
'Component.moduleId',
'Component.inputs',
'Component.properties',
'Component.queries',
'Component.selector',
'Component.viewBindings',
@ -168,10 +170,12 @@ var NG_API = [
'ComponentMetadata.bindings',
'ComponentMetadata.changeDetection',
'ComponentMetadata.outputs',
'ComponentMetadata.events',
'ComponentMetadata.exportAs',
'ComponentMetadata.host',
'ComponentMetadata.moduleId',
'ComponentMetadata.inputs',
'ComponentMetadata.properties',
'ComponentMetadata.queries',
'ComponentMetadata.selector',
'ComponentMetadata.viewBindings',
@ -370,19 +374,23 @@ var NG_API = [
'Directive',
'Directive.bindings',
'Directive.outputs',
'Directive.events',
'Directive.exportAs',
'Directive.host',
'Directive.moduleId',
'Directive.inputs',
'Directive.properties',
'Directive.queries',
'Directive.selector',
'DirectiveMetadata',
'DirectiveMetadata.bindings',
'DirectiveMetadata.outputs',
'DirectiveMetadata.events',
'DirectiveMetadata.exportAs',
'DirectiveMetadata.host',
'DirectiveMetadata.moduleId',
'DirectiveMetadata.inputs',
'DirectiveMetadata.properties',
'DirectiveMetadata.queries',
'DirectiveMetadata.selector',
'DirectiveResolver',