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

Commit ca07ad7

Browse files
committed
fix(carousel): change to avoid references to debug info
- Change usage of `.scope()` and `.isolateScope()` to grab metadata from elements Closes #3795 Fixes #3794
1 parent a5a2514 commit ca07ad7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/carousel/carousel.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
*
88
*/
99
angular.module('ui.bootstrap.carousel', [])
10-
.controller('CarouselController', ['$scope', '$interval', '$animate', function ($scope, $interval, $animate) {
10+
.controller('CarouselController', ['$scope', '$element', '$interval', '$animate', function ($scope, $element, $interval, $animate) {
1111
var self = this,
1212
slides = self.slides = $scope.slides = [],
13+
NO_TRANSITION = 'uib-noTransition',
14+
SLIDE_DIRECTION = 'uib-slideDirection',
1315
currentIndex = -1,
1416
currentInterval, isPlaying;
1517
self.currentSlide = null;
@@ -36,6 +38,7 @@ angular.module('ui.bootstrap.carousel', [])
3638
angular.extend(self.currentSlide || {}, {direction: direction, active: false});
3739
if ($animate.enabled() && !$scope.noTransition && !$scope.$currentTransition &&
3840
slide.$element) {
41+
slide.$element.data(SLIDE_DIRECTION, slide.direction);
3942
$scope.$currentTransition = true;
4043
slide.$element.one('$animate:close', function closeFn() {
4144
$scope.$currentTransition = null;
@@ -167,6 +170,10 @@ angular.module('ui.bootstrap.carousel', [])
167170
}
168171
};
169172

173+
$scope.$watch('noTransition', function(noTransition) {
174+
$element.data(NO_TRANSITION, noTransition);
175+
});
176+
170177
}])
171178

172179
/**
@@ -295,13 +302,16 @@ function CarouselDemoCtrl($scope) {
295302
.animation('.item', [
296303
'$animate',
297304
function ($animate) {
305+
var NO_TRANSITION = 'uib-noTransition',
306+
SLIDE_DIRECTION = 'uib-slideDirection';
307+
298308
return {
299309
beforeAddClass: function (element, className, done) {
300310
// Due to transclusion, noTransition property is on parent's scope
301311
if (className == 'active' && element.parent() &&
302-
!element.parent().scope().noTransition) {
312+
!element.parent().data(NO_TRANSITION)) {
303313
var stopped = false;
304-
var direction = element.isolateScope().direction;
314+
var direction = element.data(SLIDE_DIRECTION);
305315
var directionClass = direction == 'next' ? 'left' : 'right';
306316
element.addClass(direction);
307317
$animate.addClass(element, directionClass).then(function () {
@@ -320,9 +330,9 @@ function ($animate) {
320330
beforeRemoveClass: function (element, className, done) {
321331
// Due to transclusion, noTransition property is on parent's scope
322332
if (className == 'active' && element.parent() &&
323-
!element.parent().scope().noTransition) {
333+
!element.parent().data(NO_TRANSITION)) {
324334
var stopped = false;
325-
var direction = element.isolateScope().direction;
335+
var direction = element.data(SLIDE_DIRECTION);
326336
var directionClass = direction == 'next' ? 'left' : 'right';
327337
$animate.addClass(element, directionClass).then(function () {
328338
if (!stopped) {

src/carousel/test/carousel.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ describe('carousel', function() {
349349

350350
beforeEach(function() {
351351
scope = $rootScope.$new();
352-
ctrl = $controller('CarouselController', {$scope: scope, $element: null});
352+
ctrl = $controller('CarouselController', {$scope: scope, $element: angular.element('<div></div>')});
353353
for(var i = 0;i < slides.length;i++){
354354
ctrl.addSlide(slides[i]);
355355
}

0 commit comments

Comments
 (0)