feat(transformers): directive aliases in Dart transformers (fix #1747)
This commit is contained in:
@@ -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() {
|
||||
|
||||
+28
@@ -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')
|
||||
]
|
||||
});
|
||||
}
|
||||
+35
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
+28
@@ -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')
|
||||
]
|
||||
});
|
||||
}
|
||||
+29
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-17
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-8
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user