feat(Directive): convert properties to an array
fixes #2013 BREAKING CHANGE: Before @Directive(properties: { 'sameName': 'sameName', 'directiveProp': 'elProp | pipe' }) After @Directive(properties: [ 'sameName', 'directiveProp: elProp | pipe' ])
This commit is contained in:
@ -219,7 +219,7 @@ export function main() {
|
||||
it('should set directive.bind', inject([AsyncTestCompleter], (async) => {
|
||||
captureDirective(DirectiveWithBind)
|
||||
.then((renderDir) => {
|
||||
expect(renderDir.properties).toEqual(MapWrapper.createFromStringMap({'a': 'b'}));
|
||||
expect(renderDir.properties).toEqual(['a: b']);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -478,7 +478,7 @@ class DirectiveWithEvents {
|
||||
class DirectiveWithProperties {
|
||||
}
|
||||
|
||||
@Directive({properties: {'a': 'b'}})
|
||||
@Directive({properties: ['a: b']})
|
||||
class DirectiveWithBind {
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ class NoPropertyAccess {
|
||||
selector: 'on-change',
|
||||
// TODO: needed because of https://github.com/angular/angular/issues/2120
|
||||
lifecycle: const [onChange],
|
||||
properties: const { 'prop': 'prop' }
|
||||
properties: const ['prop']
|
||||
)
|
||||
@View(template: '')
|
||||
class OnChangeComponent implements OnChange {
|
||||
|
@ -1173,14 +1173,14 @@ class DynamicViewport {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({selector: '[my-dir]', properties: {'dirProp': 'elprop'}})
|
||||
@Directive({selector: '[my-dir]', properties: ['dirProp: elprop']})
|
||||
@Injectable()
|
||||
class MyDir {
|
||||
dirProp: string;
|
||||
constructor() { this.dirProp = ''; }
|
||||
}
|
||||
|
||||
@Component({selector: 'push-cmp', properties: {'prop': 'prop'}, changeDetection: ON_PUSH})
|
||||
@Component({selector: 'push-cmp', properties: ['prop'], changeDetection: ON_PUSH})
|
||||
@View({template: '{{field}}'})
|
||||
@Injectable()
|
||||
class PushCmp {
|
||||
@ -1195,7 +1195,7 @@ class PushCmp {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'push-cmp-with-ref', properties: {'prop': 'prop'}, changeDetection: ON_PUSH})
|
||||
@Component({selector: 'push-cmp-with-ref', properties: ['prop'], changeDetection: ON_PUSH})
|
||||
@View({template: '{{field}}'})
|
||||
@Injectable()
|
||||
class PushCmpWithRef {
|
||||
@ -1230,7 +1230,7 @@ class MyComp {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'component-with-pipes', properties: {"prop": "prop | double"}})
|
||||
@Component({selector: 'component-with-pipes', properties: ["prop: prop | double"]})
|
||||
@View({template: ''})
|
||||
@Injectable()
|
||||
class ComponentWithPipes {
|
||||
@ -1412,7 +1412,7 @@ class DirectiveListeningDomEventNoPrevent {
|
||||
onEvent(event) { return true; }
|
||||
}
|
||||
|
||||
@Directive({selector: '[id]', properties: {'id': 'id'}})
|
||||
@Directive({selector: '[id]', properties: ['id']})
|
||||
@Injectable()
|
||||
class IdDir {
|
||||
id: string;
|
||||
@ -1459,7 +1459,7 @@ class ToolbarPart {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({selector: '[toolbar-vc]', properties: {'toolbarVc': 'toolbarVc'}})
|
||||
@Directive({selector: '[toolbar-vc]', properties: ['toolbarVc']})
|
||||
@Injectable()
|
||||
class ToolbarViewContainer {
|
||||
vc: ViewContainerRef;
|
||||
@ -1487,7 +1487,7 @@ class ToolbarComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({selector: '[two-way]', properties: {value: 'control'}, events: ['control']})
|
||||
@Directive({selector: '[two-way]', properties: ['value: control'], events: ['control']})
|
||||
@Injectable()
|
||||
class DirectiveWithTwoWayBinding {
|
||||
control: EventEmitter;
|
||||
|
@ -87,7 +87,7 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Directive({selector: '[text]', properties: {'text': 'text'}})
|
||||
@Directive({selector: '[text]', properties: ['text']})
|
||||
@Injectable()
|
||||
class TextDirective {
|
||||
text: string;
|
||||
|
@ -48,11 +48,8 @@ export function main() {
|
||||
}
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: "[lifecycle]",
|
||||
properties: {'field': 'field'},
|
||||
lifecycle: [onChange, onCheck, onInit]
|
||||
})
|
||||
@Directive(
|
||||
{selector: "[lifecycle]", properties: ['field'], lifecycle: [onChange, onCheck, onInit]})
|
||||
class LifecycleDir {
|
||||
field;
|
||||
log: List<string>;
|
||||
@ -69,4 +66,4 @@ class LifecycleDir {
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({directives: []})
|
||||
class MyComp {
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +239,7 @@ var decoratorWithMultipleAttrs = new DirectiveMetadata({
|
||||
|
||||
var someDirectiveWithProps = new DirectiveMetadata({
|
||||
selector: '[some-decor-props]',
|
||||
properties:
|
||||
MapWrapper.createFromStringMap({'dirProp': 'elProp', 'doubleProp': 'elProp | double'}),
|
||||
properties: ['dirProp: elProp', 'doubleProp: elProp | double'],
|
||||
readAttributes: ['some-attr']
|
||||
});
|
||||
|
||||
|
@ -12,7 +12,7 @@ export function main() {
|
||||
hostProperties: MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']]),
|
||||
hostActions: MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']]),
|
||||
id: 'someComponent',
|
||||
properties: MapWrapper.createFromPairs([['propKey', 'propVal']]),
|
||||
properties: ['propKey: propVal'],
|
||||
readAttributes: ['read1', 'read2'],
|
||||
selector: 'some-comp',
|
||||
type: DirectiveMetadata.COMPONENT_TYPE
|
||||
@ -26,8 +26,7 @@ export function main() {
|
||||
expect(MapWrapper.get(map, 'hostActions'))
|
||||
.toEqual(MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']]));
|
||||
expect(MapWrapper.get(map, 'id')).toEqual('someComponent');
|
||||
expect(MapWrapper.get(map, 'properties'))
|
||||
.toEqual(MapWrapper.createFromPairs([['propKey', 'propVal']]));
|
||||
expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']);
|
||||
expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']);
|
||||
expect(MapWrapper.get(map, 'selector')).toEqual('some-comp');
|
||||
expect(MapWrapper.get(map, 'type')).toEqual(DirectiveMetadata.COMPONENT_TYPE);
|
||||
@ -40,7 +39,7 @@ export function main() {
|
||||
['hostProperties', MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']])],
|
||||
['hostActions', MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']])],
|
||||
['id', 'testId'],
|
||||
['properties', MapWrapper.createFromPairs([['propKey', 'propVal']])],
|
||||
['properties', ['propKey: propVal']],
|
||||
['readAttributes', ['readTest1', 'readTest2']],
|
||||
['selector', 'testSelector'],
|
||||
['type', DirectiveMetadata.DIRECTIVE_TYPE]
|
||||
@ -53,7 +52,7 @@ export function main() {
|
||||
expect(meta.hostActions)
|
||||
.toEqual(MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']]));
|
||||
expect(meta.id).toEqual('testId');
|
||||
expect(meta.properties).toEqual(MapWrapper.createFromPairs([['propKey', 'propVal']]));
|
||||
expect(meta.properties).toEqual(['propKey: propVal']);
|
||||
expect(meta.readAttributes).toEqual(['readTest1', 'readTest2']);
|
||||
expect(meta.selector).toEqual('testSelector');
|
||||
expect(meta.type).toEqual(DirectiveMetadata.DIRECTIVE_TYPE);
|
||||
|
@ -43,7 +43,7 @@ class Logger {
|
||||
add(thing: string) { ListWrapper.push(this.log, thing); }
|
||||
}
|
||||
|
||||
@Directive({selector: '[message]', properties: {'message': 'message'}})
|
||||
@Directive({selector: '[message]', properties: ['message']})
|
||||
@Injectable()
|
||||
class MessageDir {
|
||||
logger: Logger;
|
||||
|
@ -13,7 +13,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Directive(
|
||||
selector: '[tool-tip]', properties: const {'text': 'tool-tip'})
|
||||
selector: '[tool-tip]', properties: const ['text: tool-tip'])
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Directive(
|
||||
selector: '[tool-tip]', properties: const {'text': 'tool-tip'})
|
||||
selector: '[tool-tip]', properties: const ['text: tool-tip'])
|
||||
]
|
||||
})
|
||||
..registerSetters({'text': (o, v) => o.text = v});
|
||||
|
@ -14,13 +14,13 @@ void initReflector(reflector) {
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
properties: const {'menu': 'menu'})
|
||||
properties: const ['menu'])
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(properties: const {'menu': 'menu'})]
|
||||
'annotations': const [const Component(properties: const ['menu'])]
|
||||
})
|
||||
..registerSetters({'menu': (o, v) => o.menu = v});
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ void initReflector(reflector) {
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
properties: const {'menu': 'menu'})
|
||||
properties: const ['menu'])
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(properties: const {'menu': 'menu'})]
|
||||
'annotations': const [const Component(properties: const ['menu'])]
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void initReflector(reflector) {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(properties: const {'key1': 'val1', 'key2': 'val2'})
|
||||
const Component(properties: const ['key1: val1', 'key2: val2'])
|
||||
]
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user