feat(core): support properties and events in addition to inputs and outputs to make transition easier
Closes #4482
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import {resolveForwardRef, Injectable} from 'angular2/src/core/di';
|
||||
import {Type, isPresent, stringify} from 'angular2/src/core/facade/lang';
|
||||
import {Type, isPresent, isBlank, stringify} from 'angular2/src/core/facade/lang';
|
||||
import {BaseException} from 'angular2/src/core/facade/exceptions';
|
||||
import {ListWrapper, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {
|
||||
@ -110,6 +110,10 @@ export class DirectiveResolver {
|
||||
var mergedQueries =
|
||||
isPresent(dm.queries) ? StringMapWrapper.merge(dm.queries, queries) : queries;
|
||||
|
||||
// TODO: remove after migrating from properties to inputs
|
||||
if (mergedInputs.length == 0 && isPresent(dm.properties)) mergedInputs = dm.properties;
|
||||
if (mergedOutputs.length == 0 && isPresent(dm.events)) mergedOutputs = dm.events;
|
||||
|
||||
if (dm instanceof ComponentMetadata) {
|
||||
return new ComponentMetadata({
|
||||
selector: dm.selector,
|
||||
|
@ -15,13 +15,18 @@ export './metadata/view.dart';
|
||||
*/
|
||||
class Directive extends DirectiveMetadata {
|
||||
const Directive({String selector, List<String> inputs,
|
||||
List<String> outputs, Map<String, String> host,
|
||||
List<String> outputs,
|
||||
@deprecated List<String> properties,
|
||||
@deprecated List<String> events,
|
||||
Map<String, String> host,
|
||||
List bindings, String exportAs, String moduleId,
|
||||
Map<String, dynamic> queries})
|
||||
: super(
|
||||
selector: selector,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
bindings: bindings,
|
||||
exportAs: exportAs,
|
||||
@ -34,7 +39,10 @@ class Directive extends DirectiveMetadata {
|
||||
*/
|
||||
class Component extends ComponentMetadata {
|
||||
const Component({String selector, List<String> inputs,
|
||||
List<String> outputs, Map<String, String> host,
|
||||
List<String> outputs,
|
||||
@deprecated List<String> properties,
|
||||
@deprecated List<String> events,
|
||||
Map<String, String> host,
|
||||
List bindings, String exportAs, String moduleId,
|
||||
Map<String, dynamic> queries,
|
||||
List viewBindings, ChangeDetectionStrategy changeDetection})
|
||||
@ -42,6 +50,8 @@ class Component extends ComponentMetadata {
|
||||
selector: selector,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
bindings: bindings,
|
||||
exportAs: exportAs,
|
||||
|
@ -149,6 +149,8 @@ export interface DirectiveFactory {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
@ -159,6 +161,8 @@ export interface DirectiveFactory {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
@ -215,6 +219,8 @@ export interface ComponentFactory {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
@ -227,6 +233,8 @@ export interface ComponentFactory {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
|
@ -467,6 +467,12 @@ export class DirectiveMetadata extends InjectableMetadata {
|
||||
*/
|
||||
inputs: string[];
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Same as `inputs`. This is to enable easier migration.
|
||||
*/
|
||||
properties: string[];
|
||||
|
||||
/**
|
||||
* Enumerates the set of event-bound output properties.
|
||||
*
|
||||
@ -514,6 +520,12 @@ export class DirectiveMetadata extends InjectableMetadata {
|
||||
*/
|
||||
outputs: string[];
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Same as `outputs`. This is to enable easier migration.
|
||||
*/
|
||||
events: string[];
|
||||
|
||||
/**
|
||||
* Specify the events, actions, properties and attributes related to the host element.
|
||||
*
|
||||
@ -738,10 +750,13 @@ export class DirectiveMetadata extends InjectableMetadata {
|
||||
*/
|
||||
queries: StringMap<string, any>;
|
||||
|
||||
constructor({selector, inputs, outputs, host, bindings, exportAs, moduleId, queries}: {
|
||||
constructor({selector, inputs, outputs, properties, events, host, bindings, exportAs, moduleId,
|
||||
queries}: {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
@ -753,6 +768,11 @@ export class DirectiveMetadata extends InjectableMetadata {
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
this.host = host;
|
||||
|
||||
// TODO: remove this once properties and events are removed.
|
||||
this.properties = properties;
|
||||
this.events = events;
|
||||
|
||||
this.exportAs = exportAs;
|
||||
this.moduleId = moduleId;
|
||||
this.queries = queries;
|
||||
@ -856,11 +876,13 @@ export class ComponentMetadata extends DirectiveMetadata {
|
||||
*/
|
||||
viewBindings: any[];
|
||||
|
||||
constructor({selector, inputs, outputs, host, exportAs, moduleId, bindings, viewBindings,
|
||||
changeDetection = ChangeDetectionStrategy.Default, queries}: {
|
||||
constructor({selector, inputs, outputs, properties, events, host, exportAs, moduleId, bindings,
|
||||
viewBindings, changeDetection = ChangeDetectionStrategy.Default, queries}: {
|
||||
selector?: string,
|
||||
inputs?: string[],
|
||||
outputs?: string[],
|
||||
properties?: string[],
|
||||
events?: string[],
|
||||
host?: StringMap<string, string>,
|
||||
bindings?: any[],
|
||||
exportAs?: string,
|
||||
@ -873,6 +895,8 @@ export class ComponentMetadata extends DirectiveMetadata {
|
||||
selector: selector,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
exportAs: exportAs,
|
||||
moduleId: moduleId,
|
||||
|
Reference in New Issue
Block a user