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

Commit

Permalink
fix($compile): don't terminate compilation for regular transclusion d…
Browse files Browse the repository at this point in the history
…irectives

Previously we would stop the compilation for both regular and element
transclusion directives which was wrong. Only element transclusion directives
should be terminal.
  • Loading branch information
IgorMinar committed Oct 4, 2013
1 parent a27b4cf commit fe21450
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/ng/compile.js
Expand Up @@ -816,8 +816,9 @@ function $CompileProvider($provide) {
if (directiveValue = directive.transclude) {
assertNoDuplicate('transclusion', transcludeDirective, directive, $compileNode);
transcludeDirective = directive;
terminalPriority = directive.priority;

if (directiveValue == 'element') {
terminalPriority = directive.priority;
$template = groupScan(compileNode, attrStart, attrEnd)
$compileNode = templateAttrs.$$element =
jqLite(document.createComment(' ' + directiveName + ': ' + templateAttrs[directiveName] + ' '));
Expand Down
26 changes: 25 additions & 1 deletion test/ng/compileSpec.js
Expand Up @@ -2905,6 +2905,30 @@ describe('$compile', function() {
expect(log).toEqual('pre(); post(unicorn!)');
});
});


it('should terminate compilation only for element trasclusion', function() {
module(function() {
directive('elementTrans', function(log) {
return {
transclude: 'element',
priority: 50,
compile: log.fn('compile:elementTrans')
};
});
directive('regularTrans', function(log) {
return {
transclude: true,
priority: 50,
compile: log.fn('compile:regularTrans')
};
});
});
inject(function(log, $compile, $rootScope) {
$compile('<div><div element-trans log="elem"></div><div regular-trans log="regular"></div></div>')($rootScope);
expect(log).toEqual('compile:elementTrans; compile:regularTrans; regular');
});
});
});


Expand Down Expand Up @@ -3256,7 +3280,7 @@ describe('$compile', function() {
$rootScope.dataOnVar = 'data-on text';
$rootScope.$apply();
expect(element.attr('data-on')).toEqual('data-on text');

element = $compile('<button on="{{onVar}}"></script>')($rootScope);
$rootScope.onVar = 'on text';
$rootScope.$apply();
Expand Down

0 comments on commit fe21450

Please sign in to comment.