mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
fix(ngTransclude): clear the translusion point before transcluding
when the transluded content is being teleported to the translusion point, we should ensure that the translusion point is empty before appending otherwise we end up with junk before the transcluded content
This commit is contained in:
@@ -2450,7 +2450,7 @@ describe('$compile', function() {
|
||||
element = $compile('<div parent-directive><div child-directive></div>childContentText;</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(log).toEqual('parentController; childController');
|
||||
expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;')
|
||||
expect(element.text()).toBe('childTemplateText;childContentText;')
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2554,7 +2554,7 @@ describe('$compile', function() {
|
||||
'</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(log).toEqual('parentController; childController; babyController');
|
||||
expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;babyTemplateText;')
|
||||
expect(element.text()).toBe('childContentText;babyTemplateText;')
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2825,6 +2825,24 @@ describe('$compile', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should clear contents of the ng-translude element before appending transcluded content',
|
||||
function() {
|
||||
module(function() {
|
||||
directive('trans', function() {
|
||||
return {
|
||||
transclude: true,
|
||||
template: '<div ng-transclude>old stuff! </div>'
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function(log, $rootScope, $compile) {
|
||||
element = $compile('<div trans>unicorn!</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(sortedHtml(element.html())).toEqual('<div ng-transclude=""><span>unicorn!</span></div>');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should make the result of a transclusion available to the parent directive in post-linking phase (template)',
|
||||
function() {
|
||||
module(function() {
|
||||
|
||||
Reference in New Issue
Block a user