Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fe21450

Browse files
committed
fix($compile): don't terminate compilation for regular transclusion directives
Previously we would stop the compilation for both regular and element transclusion directives which was wrong. Only element transclusion directives should be terminal.
1 parent a27b4cf commit fe21450

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/ng/compile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,9 @@ function $CompileProvider($provide) {
816816
if (directiveValue = directive.transclude) {
817817
assertNoDuplicate('transclusion', transcludeDirective, directive, $compileNode);
818818
transcludeDirective = directive;
819-
terminalPriority = directive.priority;
819+
820820
if (directiveValue == 'element') {
821+
terminalPriority = directive.priority;
821822
$template = groupScan(compileNode, attrStart, attrEnd)
822823
$compileNode = templateAttrs.$$element =
823824
jqLite(document.createComment(' ' + directiveName + ': ' + templateAttrs[directiveName] + ' '));

test/ng/compileSpec.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -2905,6 +2905,30 @@ describe('$compile', function() {
29052905
expect(log).toEqual('pre(); post(unicorn!)');
29062906
});
29072907
});
2908+
2909+
2910+
it('should terminate compilation only for element trasclusion', function() {
2911+
module(function() {
2912+
directive('elementTrans', function(log) {
2913+
return {
2914+
transclude: 'element',
2915+
priority: 50,
2916+
compile: log.fn('compile:elementTrans')
2917+
};
2918+
});
2919+
directive('regularTrans', function(log) {
2920+
return {
2921+
transclude: true,
2922+
priority: 50,
2923+
compile: log.fn('compile:regularTrans')
2924+
};
2925+
});
2926+
});
2927+
inject(function(log, $compile, $rootScope) {
2928+
$compile('<div><div element-trans log="elem"></div><div regular-trans log="regular"></div></div>')($rootScope);
2929+
expect(log).toEqual('compile:elementTrans; compile:regularTrans; regular');
2930+
});
2931+
});
29082932
});
29092933

29102934

@@ -3256,7 +3280,7 @@ describe('$compile', function() {
32563280
$rootScope.dataOnVar = 'data-on text';
32573281
$rootScope.$apply();
32583282
expect(element.attr('data-on')).toEqual('data-on text');
3259-
3283+
32603284
element = $compile('<button on="{{onVar}}"></script>')($rootScope);
32613285
$rootScope.onVar = 'on text';
32623286
$rootScope.$apply();

0 commit comments

Comments
 (0)