Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7a2c1ef

Browse files
committed
fixup
1 parent a2f1c58 commit 7a2c1ef

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

src/ngMessages/messages.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ function ngMessageDirectiveFactory() {
654654
assignRecords(staticExp);
655655
}
656656

657-
var currentElement, currentScope, messageCtrl;
657+
var currentElement, messageCtrl;
658658
ngMessagesCtrl.register(commentNode, messageCtrl = {
659659
test: function(name) {
660660
return contains(records, name);
@@ -664,7 +664,6 @@ function ngMessageDirectiveFactory() {
664664
$transclude(function(elm, newScope) {
665665
$animate.enter(elm, null, element);
666666
currentElement = elm;
667-
currentScope = newScope;
668667

669668
// Each time we attach this node to a message we get a new id that we can match
670669
// when we are destroying the node later.
@@ -678,6 +677,7 @@ function ngMessageDirectiveFactory() {
678677
ngMessagesCtrl.deregister(commentNode);
679678
messageCtrl.detach();
680679
}
680+
newScope.$destroy();
681681
});
682682
});
683683
}
@@ -687,8 +687,6 @@ function ngMessageDirectiveFactory() {
687687
var elm = currentElement;
688688
currentElement = null;
689689
$animate.leave(elm);
690-
currentScope && currentScope.$destroy();
691-
currentScope = null;
692690
}
693691
}
694692
});

test/ngMessages/messagesSpec.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
fdescribe('ngMessages', function() {
3+
describe('ngMessages', function() {
44
beforeEach(inject.strictDi());
55
beforeEach(module('ngMessages'));
66

@@ -488,23 +488,6 @@ fdescribe('ngMessages', function() {
488488

489489
it('should clean-up the ngMessage scope when a message is removed',
490490
inject(function($compile, $rootScope) {
491-
function countWatchers() {
492-
var scope = $rootScope;
493-
var watchers = 0;
494-
495-
while (scope) {
496-
watchers += scope.$$watchers.length;
497-
if (scope.$$childHead) {
498-
scope = scope.$$childHead;
499-
} else if (scope.$$nextSibling) {
500-
scope = scope.$$nextSibling;
501-
} else {
502-
scope = null;
503-
}
504-
}
505-
506-
return watchers;
507-
}
508491

509492
var html =
510493
'<div ng-messages="items">' +
@@ -518,14 +501,14 @@ fdescribe('ngMessages', function() {
518501
});
519502

520503
expect(element.text()).toBe('A');
521-
var watchers = countWatchers();
504+
var watchers = $rootScope.$countWatchers();
522505

523506
$rootScope.$apply('items.a = false');
524507

525508
expect(element.text()).toBe('');
526509
// We don't know exactly how many watchers are on the scope, only that there should be
527510
// one less now
528-
expect(countWatchers()).toBe(watchers-1);
511+
expect($rootScope.$countWatchers()).toBe(watchers-1);
529512
})
530513
);
531514

0 commit comments

Comments
 (0)