feat(transformers): directive aliases in Dart transformers (fix #1747)

This commit is contained in:
Sigmund Cherem
2015-07-17 13:21:37 -07:00
parent 46502e4d61
commit fd46b49ea6
43 changed files with 910 additions and 287 deletions
@@ -36,6 +36,21 @@ void changeDetectorTests() {
var output = await (process(new AssetId('a', inputPath)));
expect(output).toContain('notifyOnBinding');
});
it('should include directives mentioned in directive aliases.', () async {
// Input 2 is the same as input1, but contains the directive aliases
// inlined.
var input1Path =
'template_compiler/directive_aliases_files/hello1.ng_deps.dart';
var input2Path =
'template_compiler/directive_aliases_files/hello2.ng_deps.dart';
// Except for the directive argument in the View annotation, the generated
// change detectors are identical.
var output1 = (await process(new AssetId('a', input1Path))).replaceFirst(
'directives: const [alias1]', 'directives: const [GoodbyeCmp]');
var output2 = await process(new AssetId('a', input2Path));
_formatThenExpectEquals(output1, output2);
});
}
void noChangeDetectorTests() {
@@ -0,0 +1,28 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [alias1])
]
})
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye')
]
});
}
@@ -0,0 +1,35 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
},
"GoodbyeCmp":{
"kind": "type",
"value": {
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
},
"aliases1":{
"kind": "alias",
"value": [
"GoodbyeCmp"
]
}
}
@@ -0,0 +1,28 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
]
})
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye')
]
});
}
@@ -0,0 +1,29 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
},
"GoodbyeCmp":{
"kind": "type",
"value": {
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,23 +1,29 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
},
"GoodbyeCmp":{
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,12 +1,15 @@
{
"GoodbyeCmp":{
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,13 +1,16 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}
}
@@ -1,12 +1,15 @@
{
"MyApp":{
"id":"MyApp",
"selector":"my-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
"kind": "type",
"value": {
"id":"MyApp",
"selector":"my-app",
"compileChildren":true,
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
"version":1
}
}
}