Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 1cbd73d

Browse files
Anthony Cleaverwesleycho
Anthony Cleaver
authored andcommitted
feat(modal): append using $animate
- Use $animate.enter to append transcluded content Closes #6023 Closes #6029
1 parent 433e536 commit 1cbd73d

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

src/modal/modal.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
230230
};
231231
})
232232

233-
.directive('uibModalTransclude', function() {
233+
.directive('uibModalTransclude', ['$animate', function($animate) {
234234
return {
235235
link: function(scope, element, attrs, controller, transclude) {
236236
transclude(scope.$parent, function(clone) {
237237
element.empty();
238-
element.append(clone);
238+
$animate.enter(clone, element);
239239
});
240240
}
241241
};
242-
})
242+
}])
243243

244244
.factory('$uibModalStack', ['$animate', '$animateCss', '$document',
245245
'$compile', '$rootScope', '$q', '$$multiMap', '$$stackedMap', '$uibPosition',

src/modal/test/modal.spec.js

+56
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,62 @@ describe('$uibResolve', function() {
4646
});
4747
});
4848

49+
describe('uibModalTransclude', function() {
50+
var uibModalTranscludeDDO,
51+
$animate;
52+
53+
beforeEach(module('ui.bootstrap.modal'));
54+
beforeEach(module(function($provide) {
55+
$animate = jasmine.createSpyObj('$animate', ['enter']);
56+
$provide.value('$animate', $animate);
57+
}));
58+
59+
beforeEach(inject(function(uibModalTranscludeDirective) {
60+
uibModalTranscludeDDO = uibModalTranscludeDirective[0];
61+
}));
62+
63+
describe('when initialised', function() {
64+
var scope,
65+
element,
66+
transcludeSpy,
67+
transcludeFn;
68+
69+
beforeEach(function() {
70+
scope = {
71+
$parent: 'parentScope'
72+
};
73+
74+
element = jasmine.createSpyObj('containerElement', ['empty']);
75+
transcludeSpy = jasmine.createSpy('transcludeSpy').and.callFake(function(scope, fn) {
76+
transcludeFn = fn;
77+
});
78+
79+
uibModalTranscludeDDO.link(scope, element, {}, {}, transcludeSpy);
80+
});
81+
82+
it('should call the transclusion function', function() {
83+
expect(transcludeSpy).toHaveBeenCalledWith(scope.$parent, jasmine.any(Function));
84+
});
85+
86+
describe('transclusion callback', function() {
87+
var transcludedContent;
88+
89+
beforeEach(function() {
90+
transcludedContent = 'my transcluded content';
91+
transcludeFn(transcludedContent);
92+
});
93+
94+
it('should empty the element', function() {
95+
expect(element.empty).toHaveBeenCalledWith();
96+
});
97+
98+
it('should append the transcluded content', function() {
99+
expect($animate.enter).toHaveBeenCalledWith(transcludedContent, element);
100+
});
101+
});
102+
});
103+
});
104+
49105
describe('$uibModal', function() {
50106
var $animate, $controllerProvider, $rootScope, $document, $compile, $templateCache, $timeout, $q;
51107
var $uibModal, $uibModalStack, $uibModalProvider;

0 commit comments

Comments
 (0)