X Tutup
Skip to content

Commit adbfd29

Browse files
committed
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;}
1 parent 33593cf commit adbfd29

File tree

89 files changed

+405
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+405
-423
lines changed

modules/angular2/src/compiler/change_definition_factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class ProtoViewVisitor implements TemplateAstVisitor {
7777
if (ast.isBound()) {
7878
this.boundElementCount++;
7979
}
80-
templateVisitAll(this, ast.properties, null);
81-
templateVisitAll(this, ast.events);
80+
templateVisitAll(this, ast.inputs, null);
81+
templateVisitAll(this, ast.outputs);
8282
templateVisitAll(this, ast.exportAsVars);
8383
for (var i = 0; i < ast.directives.length; i++) {
8484
ast.directives[i].visit(this, i);
@@ -158,7 +158,7 @@ class ProtoViewVisitor implements TemplateAstVisitor {
158158
});
159159
this.directiveRecords.push(directiveRecord);
160160

161-
templateVisitAll(this, ast.properties, directiveRecord);
161+
templateVisitAll(this, ast.inputs, directiveRecord);
162162
var bindingRecords = this.bindingRecords;
163163
if (directiveRecord.callOnChanges) {
164164
bindingRecords.push(BindingRecord.createDirectiveOnChanges(directiveRecord));

modules/angular2/src/compiler/command_compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class CommandBuilderVisitor<R> implements TemplateAstVisitor {
246246
}
247247
visitElement(ast: ElementAst, context: any): any {
248248
var component = ast.getComponent();
249-
var eventTargetAndNames = visitAndReturnContext(this, ast.events, []);
249+
var eventTargetAndNames = visitAndReturnContext(this, ast.outputs, []);
250250
var variableNameAndValues = [];
251251
if (isBlank(component)) {
252252
ast.exportAsVars.forEach((varAst) => {

modules/angular2/src/compiler/directive_metadata.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ export class CompileTemplateMetadata {
9494
}
9595

9696
export class CompileDirectiveMetadata {
97-
static create({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection,
98-
properties, events, host, lifecycleHooks, template}: {
97+
static create({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection, inputs,
98+
outputs, host, lifecycleHooks, template}: {
9999
type?: CompileTypeMetadata,
100100
isComponent?: boolean,
101101
dynamicLoadable?: boolean,
102102
selector?: string,
103103
exportAs?: string,
104104
changeDetection?: ChangeDetectionStrategy,
105-
properties?: string[],
106-
events?: string[],
105+
inputs?: string[],
106+
outputs?: string[],
107107
host?: StringMap<string, string>,
108108
lifecycleHooks?: LifecycleHooks[],
109109
template?: CompileTemplateMetadata
@@ -123,22 +123,22 @@ export class CompileDirectiveMetadata {
123123
}
124124
});
125125
}
126-
var propsMap = {};
127-
if (isPresent(properties)) {
128-
properties.forEach((bindConfig: string) => {
126+
var inputsMap = {};
127+
if (isPresent(inputs)) {
128+
inputs.forEach((bindConfig: string) => {
129129
// canonical syntax: `dirProp: elProp`
130130
// if there is no `:`, use dirProp = elProp
131131
var parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
132-
propsMap[parts[0]] = parts[1];
132+
inputsMap[parts[0]] = parts[1];
133133
});
134134
}
135-
var eventsMap = {};
136-
if (isPresent(events)) {
137-
events.forEach((bindConfig: string) => {
135+
var outputsMap = {};
136+
if (isPresent(outputs)) {
137+
outputs.forEach((bindConfig: string) => {
138138
// canonical syntax: `dirProp: elProp`
139139
// if there is no `:`, use dirProp = elProp
140140
var parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
141-
eventsMap[parts[0]] = parts[1];
141+
outputsMap[parts[0]] = parts[1];
142142
});
143143
}
144144

@@ -149,8 +149,8 @@ export class CompileDirectiveMetadata {
149149
selector: selector,
150150
exportAs: exportAs,
151151
changeDetection: changeDetection,
152-
properties: propsMap,
153-
events: eventsMap,
152+
inputs: inputsMap,
153+
outputs: outputsMap,
154154
hostListeners: hostListeners,
155155
hostProperties: hostProperties,
156156
hostAttributes: hostAttributes,
@@ -164,23 +164,23 @@ export class CompileDirectiveMetadata {
164164
selector: string;
165165
exportAs: string;
166166
changeDetection: ChangeDetectionStrategy;
167-
properties: StringMap<string, string>;
168-
events: StringMap<string, string>;
167+
inputs: StringMap<string, string>;
168+
outputs: StringMap<string, string>;
169169
hostListeners: StringMap<string, string>;
170170
hostProperties: StringMap<string, string>;
171171
hostAttributes: StringMap<string, string>;
172172
lifecycleHooks: LifecycleHooks[];
173173
template: CompileTemplateMetadata;
174-
constructor({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection, properties,
175-
events, hostListeners, hostProperties, hostAttributes, lifecycleHooks, template}: {
174+
constructor({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection, inputs,
175+
outputs, hostListeners, hostProperties, hostAttributes, lifecycleHooks, template}: {
176176
type?: CompileTypeMetadata,
177177
isComponent?: boolean,
178178
dynamicLoadable?: boolean,
179179
selector?: string,
180180
exportAs?: string,
181181
changeDetection?: ChangeDetectionStrategy,
182-
properties?: StringMap<string, string>,
183-
events?: StringMap<string, string>,
182+
inputs?: StringMap<string, string>,
183+
outputs?: StringMap<string, string>,
184184
hostListeners?: StringMap<string, string>,
185185
hostProperties?: StringMap<string, string>,
186186
hostAttributes?: StringMap<string, string>,
@@ -193,8 +193,8 @@ export class CompileDirectiveMetadata {
193193
this.selector = selector;
194194
this.exportAs = exportAs;
195195
this.changeDetection = changeDetection;
196-
this.properties = properties;
197-
this.events = events;
196+
this.inputs = inputs;
197+
this.outputs = outputs;
198198
this.hostListeners = hostListeners;
199199
this.hostProperties = hostProperties;
200200
this.hostAttributes = hostAttributes;
@@ -212,8 +212,8 @@ export class CompileDirectiveMetadata {
212212
changeDetection: isPresent(data['changeDetection']) ?
213213
CHANGE_DECTION_STRATEGY_VALUES[data['changeDetection']] :
214214
data['changeDetection'],
215-
properties: data['properties'],
216-
events: data['events'],
215+
inputs: data['inputs'],
216+
outputs: data['outputs'],
217217
hostListeners: data['hostListeners'],
218218
hostProperties: data['hostProperties'],
219219
hostAttributes: data['hostAttributes'],
@@ -233,8 +233,8 @@ export class CompileDirectiveMetadata {
233233
'type': isPresent(this.type) ? this.type.toJson() : this.type,
234234
'changeDetection': isPresent(this.changeDetection) ? serializeEnum(this.changeDetection) :
235235
this.changeDetection,
236-
'properties': this.properties,
237-
'events': this.events,
236+
'inputs': this.inputs,
237+
'outputs': this.outputs,
238238
'hostListeners': this.hostListeners,
239239
'hostProperties': this.hostProperties,
240240
'hostAttributes': this.hostAttributes,
@@ -253,8 +253,8 @@ export function createHostComponentMeta(componentType: CompileTypeMetadata,
253253
template: new CompileTemplateMetadata(
254254
{template: template, templateUrl: '', styles: [], styleUrls: [], ngContentSelectors: []}),
255255
changeDetection: ChangeDetectionStrategy.Default,
256-
properties: [],
257-
events: [],
256+
inputs: [],
257+
outputs: [],
258258
host: {},
259259
lifecycleHooks: [],
260260
isComponent: true,

modules/angular2/src/compiler/runtime_metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export class RuntimeMetadataResolver {
5858
{name: stringify(directiveType), moduleId: moduleId, runtime: directiveType}),
5959
template: templateMeta,
6060
changeDetection: changeDetectionStrategy,
61-
properties: directiveAnnotation.properties,
62-
events: directiveAnnotation.events,
61+
inputs: directiveAnnotation.inputs,
62+
outputs: directiveAnnotation.outputs,
6363
host: directiveAnnotation.host,
6464
lifecycleHooks: ListWrapper.filter(LIFECYCLE_HOOKS_VALUES,
6565
hook => hasLifecycleHook(hook, directiveType))

modules/angular2/src/compiler/template_ast.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class VariableAst implements TemplateAst {
5656

5757
export class ElementAst implements TemplateAst {
5858
constructor(public name: string, public attrs: AttrAst[],
59-
public properties: BoundElementPropertyAst[], public events: BoundEventAst[],
59+
public inputs: BoundElementPropertyAst[], public outputs: BoundEventAst[],
6060
public exportAsVars: VariableAst[], public directives: DirectiveAst[],
6161
public children: TemplateAst[], public ngContentIndex: number,
6262
public sourceInfo: string) {}
@@ -65,7 +65,7 @@ export class ElementAst implements TemplateAst {
6565
}
6666

6767
isBound(): boolean {
68-
return (this.properties.length > 0 || this.events.length > 0 || this.exportAsVars.length > 0 ||
68+
return (this.inputs.length > 0 || this.outputs.length > 0 || this.exportAsVars.length > 0 ||
6969
this.directives.length > 0);
7070
}
7171

@@ -95,7 +95,7 @@ export class BoundDirectivePropertyAst implements TemplateAst {
9595

9696
export class DirectiveAst implements TemplateAst {
9797
constructor(public directive: CompileDirectiveMetadata,
98-
public properties: BoundDirectivePropertyAst[],
98+
public inputs: BoundDirectivePropertyAst[],
9999
public hostProperties: BoundElementPropertyAst[], public hostEvents: BoundEventAst[],
100100
public exportAsVars: VariableAst[], public sourceInfo: string) {}
101101
visit(visitor: TemplateAstVisitor, context: any): any {

modules/angular2/src/compiler/template_compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class TemplateCompiler {
6565
selector: directive.selector,
6666
exportAs: directive.exportAs,
6767
changeDetection: directive.changeDetection,
68-
properties: directive.properties,
69-
events: directive.events,
68+
inputs: directive.inputs,
69+
outputs: directive.outputs,
7070
hostListeners: directive.hostListeners,
7171
hostProperties: directive.hostProperties,
7272
hostAttributes: directive.hostAttributes,

modules/angular2/src/compiler/template_parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class TemplateParseVisitor implements HtmlAstVisitor {
415415
this._createDirectiveHostPropertyAsts(elementName, directive.hostProperties, sourceInfo,
416416
hostProperties);
417417
this._createDirectiveHostEventAsts(directive.hostListeners, sourceInfo, hostEvents);
418-
this._createDirectivePropertyAsts(directive.properties, props, directiveProperties);
418+
this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties);
419419
var exportAsVars = [];
420420
possibleExportAsVars.forEach((varAst) => {
421421
if ((varAst.value.length === 0 && directive.isComponent) ||
@@ -489,7 +489,7 @@ class TemplateParseVisitor implements HtmlAstVisitor {
489489
var boundElementProps: BoundElementPropertyAst[] = [];
490490
var boundDirectivePropsIndex = new Map<string, BoundDirectivePropertyAst>();
491491
directives.forEach((directive: DirectiveAst) => {
492-
directive.properties.forEach((prop: BoundDirectivePropertyAst) => {
492+
directive.inputs.forEach((prop: BoundDirectivePropertyAst) => {
493493
boundDirectivePropsIndex.set(prop.templateName, prop);
494494
});
495495
});

modules/angular2/src/core/change_detection/change_detector_ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class ChangeDetectorRef {
157157
* }
158158
* }
159159
*
160-
* @Component({selector: 'live-data', properties: ['live']})
160+
* @Component({selector: 'live-data', inputs: ['live']})
161161
* @View({
162162
* template: `Data: {{dataProvider.data}}`
163163
* })

modules/angular2/src/core/change_detection/exceptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {BaseException, WrappedException} from "angular2/src/core/facade/exceptio
2121
* parentProp = "init";
2222
* }
2323
*
24-
* @Directive({selector: 'child', properties: ['prop']})
24+
* @Directive({selector: 'child', inputs: ['prop']})
2525
* class Child {
2626
* constructor(public parent: Parent) {}
2727
*
@@ -49,7 +49,7 @@ export class ExpressionChangedAfterItHasBeenCheckedException extends BaseExcepti
4949
* ### Example ([live demo](http://plnkr.co/edit/2Kywoz?p=preview))
5050
*
5151
* ```typescript
52-
* @Directive({selector: 'child', properties: ['prop']})
52+
* @Directive({selector: 'child', inputs: ['prop']})
5353
* class Child {
5454
* prop;
5555
* }

modules/angular2/src/core/compiler/directive_resolver.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {ListWrapper, StringMap, StringMapWrapper} from 'angular2/src/core/facade
55
import {
66
DirectiveMetadata,
77
ComponentMetadata,
8-
PropertyMetadata,
9-
EventMetadata,
8+
InputMetadata,
9+
OutputMetadata,
1010
HostBindingMetadata,
1111
HostListenerMetadata,
1212
ContentChildrenMetadata,
@@ -45,26 +45,26 @@ export class DirectiveResolver {
4545
private _mergeWithPropertyMetadata(dm: DirectiveMetadata,
4646
propertyMetadata:
4747
StringMap<string, any[]>): DirectiveMetadata {
48-
var properties = [];
49-
var events = [];
48+
var inputs = [];
49+
var outputs = [];
5050
var host = {};
5151
var queries = {};
5252

5353
StringMapWrapper.forEach(propertyMetadata, (metadata: any[], propName: string) => {
5454
metadata.forEach(a => {
55-
if (a instanceof PropertyMetadata) {
55+
if (a instanceof InputMetadata) {
5656
if (isPresent(a.bindingPropertyName)) {
57-
properties.push(`${propName}: ${a.bindingPropertyName}`);
57+
inputs.push(`${propName}: ${a.bindingPropertyName}`);
5858
} else {
59-
properties.push(propName);
59+
inputs.push(propName);
6060
}
6161
}
6262

63-
if (a instanceof EventMetadata) {
63+
if (a instanceof OutputMetadata) {
6464
if (isPresent(a.bindingPropertyName)) {
65-
events.push(`${propName}: ${a.bindingPropertyName}`);
65+
outputs.push(`${propName}: ${a.bindingPropertyName}`);
6666
} else {
67-
events.push(propName);
67+
outputs.push(propName);
6868
}
6969
}
7070

@@ -98,24 +98,23 @@ export class DirectiveResolver {
9898
}
9999
});
100100
});
101-
return this._merge(dm, properties, events, host, queries);
101+
return this._merge(dm, inputs, outputs, host, queries);
102102
}
103103

104-
private _merge(dm: DirectiveMetadata, properties: string[], events: string[],
104+
private _merge(dm: DirectiveMetadata, inputs: string[], outputs: string[],
105105
host: StringMap<string, string>,
106106
queries: StringMap<string, any>): DirectiveMetadata {
107-
var mergedProperties =
108-
isPresent(dm.properties) ? ListWrapper.concat(dm.properties, properties) : properties;
109-
var mergedEvents = isPresent(dm.events) ? ListWrapper.concat(dm.events, events) : events;
107+
var mergedInputs = isPresent(dm.inputs) ? ListWrapper.concat(dm.inputs, inputs) : inputs;
108+
var mergedOutputs = isPresent(dm.outputs) ? ListWrapper.concat(dm.outputs, outputs) : outputs;
110109
var mergedHost = isPresent(dm.host) ? StringMapWrapper.merge(dm.host, host) : host;
111110
var mergedQueries =
112111
isPresent(dm.queries) ? StringMapWrapper.merge(dm.queries, queries) : queries;
113112

114113
if (dm instanceof ComponentMetadata) {
115114
return new ComponentMetadata({
116115
selector: dm.selector,
117-
properties: mergedProperties,
118-
events: mergedEvents,
116+
inputs: mergedInputs,
117+
outputs: mergedOutputs,
119118
host: mergedHost,
120119
bindings: dm.bindings,
121120
exportAs: dm.exportAs,
@@ -129,8 +128,8 @@ export class DirectiveResolver {
129128
} else {
130129
return new DirectiveMetadata({
131130
selector: dm.selector,
132-
properties: mergedProperties,
133-
events: mergedEvents,
131+
inputs: mergedInputs,
132+
outputs: mergedOutputs,
134133
host: mergedHost,
135134
bindings: dm.bindings,
136135
exportAs: dm.exportAs,

0 commit comments

Comments
 (0)
X Tutup