feat(core): renames Property into Input and Event into Output

BREACKING CHANGE:

Before: @Directive({properties: ['one'], events: ['two']})
After: @Directive({inputs: ['one'], outputs: ['two']})

Before: @Component({properties: ['one'], events: ['two']})
After: @Componet({inputs: ['one'], outputs: ['two']})

Before: class A {@Property() one; @Event() two;}
After: class A {@Input() one; @Output() two;}
This commit is contained in:
vsavkin
2015-09-30 20:59:23 -07:00
parent 33593cf8a2
commit adbfd29fd7
89 changed files with 405 additions and 423 deletions

View File

@ -276,7 +276,7 @@ export function main() {
it('should set directive.bind', inject([AsyncTestCompleter], (async) => {
captureDirective(DirectiveWithBind)
.then((renderDir) => {
expect(renderDir.properties).toEqual(['a: b']);
expect(renderDir.inputs).toEqual(['a: b']);
async.done();
});
}));
@ -685,7 +685,7 @@ class DirectiveWithEvents {
class DirectiveWithProperties {
}
@Directive({properties: ['a: b']})
@Directive({inputs: ['a: b']})
class DirectiveWithBind {
}

View File

@ -3,8 +3,8 @@ import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
import {
DirectiveMetadata,
Directive,
Property,
Event,
Input,
Output,
HostBinding,
HostListener,
ContentChildren,
@ -25,31 +25,31 @@ class SomeDirective {
class SomeChildDirective extends SomeDirective {
}
@Directive({selector: 'someDirective', properties: ['c']})
@Directive({selector: 'someDirective', inputs: ['c']})
class SomeDirectiveWithProperties {
@Property() a;
@Property("renamed") b;
@Input() a;
@Input("renamed") b;
c;
}
@Directive({selector: 'someDirective', events: ['c']})
class SomeDirectiveWithEvents {
@Event() a;
@Event("renamed") b;
@Directive({selector: 'someDirective', outputs: ['c']})
class SomeDirectiveWithOutputs {
@Output() a;
@Output("renamed") b;
c;
}
@Directive({selector: 'someDirective'})
class SomeDirectiveWithSetterProps {
@Property("renamed")
@Input("renamed")
set a(value) {
}
}
@Directive({selector: 'someDirective'})
class SomeDirectiveWithGetterEvents {
@Event("renamed")
class SomeDirectiveWithGetterOutputs {
@Output("renamed")
get a() {
return null;
}
@ -108,7 +108,7 @@ export function main() {
var directiveMetadata = resolver.resolve(SomeDirective);
expect(directiveMetadata)
.toEqual(new DirectiveMetadata(
{selector: 'someDirective', properties: [], events: [], host: {}, queries: {}}));
{selector: 'someDirective', inputs: [], outputs: [], host: {}, queries: {}}));
});
it('should throw if not matching metadata is found', () => {
@ -120,30 +120,30 @@ export function main() {
var directiveMetadata = resolver.resolve(SomeChildDirective);
expect(directiveMetadata)
.toEqual(new DirectiveMetadata(
{selector: 'someChildDirective', properties: [], events: [], host: {}, queries: {}}));
{selector: 'someChildDirective', inputs: [], outputs: [], host: {}, queries: {}}));
});
describe('properties', () => {
it('should append directive properties', () => {
describe('inputs', () => {
it('should append directive inputs', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithProperties);
expect(directiveMetadata.properties).toEqual(['c', 'a', 'b: renamed']);
expect(directiveMetadata.inputs).toEqual(['c', 'a', 'b: renamed']);
});
it('should work with getters and setters', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithSetterProps);
expect(directiveMetadata.properties).toEqual(['a: renamed']);
expect(directiveMetadata.inputs).toEqual(['a: renamed']);
});
});
describe('events', () => {
it('should append directive events', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithEvents);
expect(directiveMetadata.events).toEqual(['c', 'a', 'b: renamed']);
describe('outputs', () => {
it('should append directive outputs', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithOutputs);
expect(directiveMetadata.outputs).toEqual(['c', 'a', 'b: renamed']);
});
it('should work with getters and setters', () => {
var directiveMetadata = resolver.resolve(SomeDirectiveWithGetterEvents);
expect(directiveMetadata.events).toEqual(['a: renamed']);
var directiveMetadata = resolver.resolve(SomeDirectiveWithGetterOutputs);
expect(directiveMetadata.outputs).toEqual(['a: renamed']);
});
});

View File

@ -345,7 +345,7 @@ export function main() {
describe('event emitters', () => {
it('should return a list of event accessors', () => {
var binding = DirectiveBinding.createFromType(HasEventEmitter,
new DirectiveMetadata({events: ['emitter']}));
new DirectiveMetadata({outputs: ['emitter']}));
var inj = createPei(null, 0, [binding]);
expect(inj.eventEmitterAccessors.length).toEqual(1);
@ -357,7 +357,7 @@ export function main() {
it('should allow a different event vs field name', () => {
var binding = DirectiveBinding.createFromType(HasEventEmitter,
new DirectiveMetadata({events: ['emitter: publicEmitter']}));
new DirectiveMetadata({outputs: ['emitter: publicEmitter']}));
var inj = createPei(null, 0, [binding]);
expect(inj.eventEmitterAccessors.length).toEqual(1);

View File

@ -266,7 +266,7 @@ class NoPropertyAccess {
@Component(
selector: 'on-change',
properties: const ['prop'])
inputs: const ['prop'])
@View(template: '')
class OnChangeComponent implements OnChanges {
Map changes;
@ -281,7 +281,7 @@ class OnChangeComponent implements OnChanges {
@Component(
selector: 'component-with-observable-list',
changeDetection: ChangeDetectionStrategy.OnPush,
properties: const ['list'],
inputs: const ['list'],
bindings: const [
const Binding(IterableDiffers,
toValue: const IterableDiffers(const [

View File

@ -75,8 +75,8 @@ import {
Attribute,
Query,
Pipe,
Property,
Event,
Input,
Output,
HostBinding,
HostListener
} from 'angular2/src/core/metadata';
@ -1733,25 +1733,25 @@ class DynamicViewport {
}
}
@Directive({selector: '[my-dir]', properties: ['dirProp: elprop'], exportAs: 'mydir'})
@Directive({selector: '[my-dir]', inputs: ['dirProp: elprop'], exportAs: 'mydir'})
@Injectable()
class MyDir {
dirProp: string;
constructor() { this.dirProp = ''; }
}
@Directive({selector: '[title]', properties: ['title']})
@Directive({selector: '[title]', inputs: ['title']})
class DirectiveWithTitle {
title: string;
}
@Directive({selector: '[title]', properties: ['title'], host: {'[title]': 'title'}})
@Directive({selector: '[title]', inputs: ['title'], host: {'[title]': 'title'}})
class DirectiveWithTitleAndHostProperty {
title: string;
}
@Component(
{selector: 'push-cmp', properties: ['prop'], changeDetection: ChangeDetectionStrategy.OnPush})
{selector: 'push-cmp', inputs: ['prop'], changeDetection: ChangeDetectionStrategy.OnPush})
@View({template: '{{field}}'})
@Injectable()
class PushCmp {
@ -1768,7 +1768,7 @@ class PushCmp {
@Component({
selector: 'push-cmp-with-ref',
properties: ['prop'],
inputs: ['prop'],
changeDetection: ChangeDetectionStrategy.OnPush
})
@View({template: '{{field}}'})
@ -1828,7 +1828,7 @@ class MyComp {
throwError() { throw 'boom'; }
}
@Component({selector: 'child-cmp', properties: ['dirProp'], viewBindings: [MyService]})
@Component({selector: 'child-cmp', inputs: ['dirProp'], viewBindings: [MyService]})
@View({directives: [MyDir], template: '{{ctxProp}}'})
@Injectable()
class ChildComp {
@ -1896,7 +1896,7 @@ class DoublePipe implements PipeTransform {
transform(value, args = null) { return `${value}${value}`; }
}
@Directive({selector: '[emitter]', events: ['event']})
@Directive({selector: '[emitter]', outputs: ['event']})
@Injectable()
class DirectiveEmitingEvent {
msg: string;
@ -1985,7 +1985,7 @@ class DirectiveListeningDomEventNoPrevent {
onEvent(event) { return true; }
}
@Directive({selector: '[id]', properties: ['id']})
@Directive({selector: '[id]', inputs: ['id']})
@Injectable()
class IdDir {
id: string;
@ -2031,7 +2031,7 @@ class ToolbarPart {
constructor(templateRef: TemplateRef) { this.templateRef = templateRef; }
}
@Directive({selector: '[toolbar-vc]', properties: ['toolbarVc']})
@Directive({selector: '[toolbar-vc]', inputs: ['toolbarVc']})
@Injectable()
class ToolbarViewContainer {
vc: ViewContainerRef;
@ -2059,7 +2059,7 @@ class ToolbarComponent {
}
}
@Directive({selector: '[two-way]', properties: ['value: control'], events: ['control']})
@Directive({selector: '[two-way]', inputs: ['value: control'], outputs: ['control']})
@Injectable()
class DirectiveWithTwoWayBinding {
control: EventEmitter;
@ -2199,7 +2199,7 @@ class ChildConsumingEventBus {
constructor(@SkipSelf() bus: EventBus) { this.bus = bus; }
}
@Directive({selector: '[some-impvp]', properties: ['someImpvp']})
@Directive({selector: '[some-impvp]', inputs: ['someImpvp']})
@Injectable()
class SomeImperativeViewport {
view: ViewRef;
@ -2256,8 +2256,8 @@ class DirectiveThrowingAnError {
class DirectiveWithPropDecorators {
target;
@Property("elProp") dirProp: string;
@Event('elEvent') event = new EventEmitter();
@Input("elProp") dirProp: string;
@Output('elEvent') event = new EventEmitter();
@HostBinding("attr.my-attr") myAttr: string;
@HostListener("click", ["$event.target"])

View File

@ -470,7 +470,7 @@ class MainComp {
text: string = '';
}
@Component({selector: 'simple', properties: ['stringProp']})
@Component({selector: 'simple', inputs: ['stringProp']})
@View({template: 'SIMPLE(<ng-content></ng-content>)', directives: []})
class Simple {
stringProp: string = '';
@ -570,7 +570,7 @@ class ConditionalTextComponent {
class Tab {
}
@Component({selector: 'tree', properties: ['depth']})
@Component({selector: 'tree', inputs: ['depth']})
@View({
template: 'TREE({{depth}}:<tree *manual [depth]="depth+1"></tree>)',
directives: [ManualViewportDirective, Tree]

View File

@ -672,7 +672,7 @@ export function main() {
});
}
@Directive({selector: '[text]', properties: ['text'], exportAs: 'textDir'})
@Directive({selector: '[text]', inputs: ['text'], exportAs: 'textDir'})
@Injectable()
class TextDirective {
text: string;