Skip to content

Commit

Permalink
WIP: show $compile bug
Browse files Browse the repository at this point in the history
Transclusion should not be propagated into template directives.
  • Loading branch information
vojtajina committed May 22, 2014
1 parent 5b257a5 commit 4d152c8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,26 @@ describe('$compile', function() {

}));


$compileProvider.directive('transFoo', valueFn({
template: '<div>' +
'<div no-trans-bar></div>' +
'<div ng-transclude>this one should get replaced with content</div>' +
'<div class="foo" ng-transclude></div>' +
'</div>',
transclude: true

}));

$compileProvider.directive('noTransBar', valueFn({
template: '<div>' +
// This ng-transclude is invalid. It should throw an error.
'<div ng-transclude></div>' +
'</div>',
transclude: false

}));

}));

it("should not pick up too many children when transcluding", inject(function($compile, $rootScope) {
Expand All @@ -1601,6 +1621,25 @@ describe('$compile', function() {
dealoc(element);
}));


iit('should not pass transclusion into a template directive', inject(function($compile, $rootScope) {
var elm;

expect(function() {
elm = $compile('<div trans-foo>content</div>')($rootScope);
}).toThrowMinErr('ngTransclude', 'orphan', 'Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: <div ng-transclude="">');

// This is just to demonstrate that ng-transclusion gets propagated.
if (elm) {
$rootScope.$digest();

var ngTransludeInsideNoTransBarDirective = angular.element(elm[0].querySelector('[no-trans-bar] [ng-transclude]'));
expect(ngTransludeInsideNoTransBarDirective.text()).toBe('');

dealoc(elm);
}
}));

});


Expand Down

0 comments on commit 4d152c8

Please sign in to comment.