Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit a7e702d

Browse files
committed
Node injector should provide both BoundBlockFactory and BlockFactory for transcluding directives.
1 parent c1e9ee8 commit a7e702d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/block.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Block implements ElementWrapper {
8787
if (directiveRefs == null || directiveRefs.length == 0) return parentInjector;
8888
var nodeModule = new Module();
8989
var blockHoleFactory = () => null;
90+
var blockFactory = () => null;
9091
var boundBlockFactory = () => null;
9192
var nodeAttrs = new NodeAttrs(node);
9293

@@ -118,11 +119,13 @@ class Block implements ElementWrapper {
118119
}
119120
nodeAttrs[ref.directive.$name] = ref.value;
120121
if (ref.directive.isStructural) {
121-
blockHoleFactory = (Injector injector) => new BlockHole([node]);
122+
blockHoleFactory = () => new BlockHole([node]);
123+
blockFactory = () => ref.blockFactory;
122124
boundBlockFactory = (Injector injector) => ref.blockFactory.bind(injector);
123125
}
124126
});
125127
nodeModule.factory(BlockHole, blockHoleFactory);
128+
nodeModule.factory(BlockFactory, blockFactory);
126129
nodeModule.factory(BoundBlockFactory, boundBlockFactory);
127130
var nodeInjector = parentInjector.createChild([nodeModule]);
128131
directiveRefs.forEach((ref) => nodeInjector.get(ref.directive.type));

test/block_spec.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import "_specs.dart";
22

33
@NgDirective(transclude: true, selector: 'foo')
44
class LoggerBlockDirective {
5-
LoggerBlockDirective(BlockHole hole, BoundBlockFactory boundBlockFactory, Logger logger) {
5+
LoggerBlockDirective(BlockHole hole, BlockFactory blockFactory,
6+
BoundBlockFactory boundBlockFactory, Logger logger) {
67
if (hole == null) {
78
throw new ArgumentError('BlockHole must be injected.');
89
}
10+
if (boundBlockFactory == null) {
11+
throw new ArgumentError('BoundBlockFactory must be injected.');
12+
}
13+
if (blockFactory == null) {
14+
throw new ArgumentError('BlockFactory must be injected.');
15+
}
916
logger.add(hole);
1017
logger.add(boundBlockFactory);
18+
logger.add(blockFactory);
1119
}
1220
}
1321

0 commit comments

Comments
 (0)