mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-28 21:05:43 +08:00
fix($compile): don't pass transcludes to non-transclude templateUrl directives
This commit is contained in:
committed by
Vojta Jina
parent
e3003d5342
commit
2ee29c5da8
@@ -1336,7 +1336,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode,
|
nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode,
|
||||||
templateAttrs, jqCollection, childTranscludeFn, preLinkFns, postLinkFns, {
|
templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, {
|
||||||
controllerDirectives: controllerDirectives,
|
controllerDirectives: controllerDirectives,
|
||||||
newIsolateScopeDirective: newIsolateScopeDirective,
|
newIsolateScopeDirective: newIsolateScopeDirective,
|
||||||
templateDirective: templateDirective,
|
templateDirective: templateDirective,
|
||||||
|
|||||||
@@ -4021,6 +4021,42 @@ describe('$compile', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should not pass transclusion into a templateUrl directive', function() {
|
||||||
|
|
||||||
|
module(function($compileProvider) {
|
||||||
|
|
||||||
|
$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({
|
||||||
|
templateUrl: 'noTransBar.html',
|
||||||
|
transclude: false
|
||||||
|
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
inject(function($compile, $rootScope, $templateCache) {
|
||||||
|
$templateCache.put('noTransBar.html',
|
||||||
|
'<div>' +
|
||||||
|
// This ng-transclude is invalid. It should throw an error.
|
||||||
|
'<div class="bar" ng-transclude></div>' +
|
||||||
|
'</div>');
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
element = $compile('<div trans-foo>content</div>')($rootScope);
|
||||||
|
$rootScope.$apply();
|
||||||
|
}).toThrowMinErr('ngTransclude', 'orphan',
|
||||||
|
'Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: <div class="bar" ng-transclude="">');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should make the result of a transclusion available to the parent directive in post-linking phase' +
|
it('should make the result of a transclusion available to the parent directive in post-linking phase' +
|
||||||
'(template)', function() {
|
'(template)', function() {
|
||||||
module(function() {
|
module(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user