fix(DirectiveMetadata): add support for events, changeDetection
This commit is contained in:
@@ -109,6 +109,18 @@ void allTests() {
|
||||
expect(metadata.callOnAllChangesDone).toBe(true);
|
||||
});
|
||||
|
||||
it('should parse events.', () async {
|
||||
var metadata = await readMetadata('directive_metadata_extractor/'
|
||||
'directive_metadata_files/events.ng_deps.dart');
|
||||
expect(metadata.events).toEqual(['onFoo', 'onBar']);
|
||||
});
|
||||
|
||||
it('should parse changeDetection.', () async {
|
||||
var metadata = await readMetadata('directive_metadata_extractor/'
|
||||
'directive_metadata_files/changeDetection.ng_deps.dart');
|
||||
expect(metadata.changeDetection).toEqual('CHECK_ONCE');
|
||||
});
|
||||
|
||||
it('should fail when a class is annotated with multiple Directives.',
|
||||
() async {
|
||||
var ngDeps = await NgDeps.parse(reader, new AssetId('a',
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show
|
||||
bootstrap,
|
||||
Component,
|
||||
Directive,
|
||||
View,
|
||||
NgElement,
|
||||
onChange,
|
||||
onDestroy,
|
||||
onInit,
|
||||
onCheck,
|
||||
onAllChangesDone;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(changeDetection: 'CHECK_ONCE')
|
||||
]
|
||||
});
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show
|
||||
bootstrap,
|
||||
Component,
|
||||
Directive,
|
||||
View,
|
||||
NgElement,
|
||||
onChange,
|
||||
onDestroy,
|
||||
onInit,
|
||||
onCheck,
|
||||
onAllChangesDone;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(events: ['onFoo', 'onBar'])
|
||||
]
|
||||
});
|
||||
}
|
||||
+2
@@ -16,6 +16,8 @@
|
||||
"callOnInit": false,
|
||||
"callOnChange": false,
|
||||
"callOnAllChangesDone": false,
|
||||
"events": [],
|
||||
"changeDetection": null,
|
||||
"version": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user