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

Commit 23d6bde

Browse files
committed
fixup
1 parent 1441560 commit 23d6bde

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
@@ -665,7 +665,7 @@ function ngMessageDirectiveFactory() {
665665
assignRecords(staticExp);
666666
}
667667

668-
var currentElement, currentScope, messageCtrl;
668+
var currentElement, messageCtrl;
669669
ngMessagesCtrl.register(commentNode, messageCtrl = {
670670
test: function(name) {
671671
return contains(records, name);
@@ -675,7 +675,6 @@ function ngMessageDirectiveFactory() {
675675
$transclude(function(elm, newScope) {
676676
$animate.enter(elm, null, element);
677677
currentElement = elm;
678-
currentScope = newScope;
679678

680679
// Each time we attach this node to a message we get a new id that we can match
681680
// when we are destroying the node later.
@@ -689,6 +688,7 @@ function ngMessageDirectiveFactory() {
689688
ngMessagesCtrl.deregister(commentNode);
690689
messageCtrl.detach();
691690
}
691+
newScope.$destroy();
692692
});
693693
});
694694
}
@@ -698,8 +698,6 @@ function ngMessageDirectiveFactory() {
698698
var elm = currentElement;
699699
currentElement = null;
700700
$animate.leave(elm);
701-
currentScope && currentScope.$destroy();
702-
currentScope = null;
703701
}
704702
}
705703
});

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

@@ -608,23 +608,6 @@ fdescribe('ngMessages', function() {
608608

609609
it('should clean-up the ngMessage scope when a message is removed',
610610
inject(function($compile, $rootScope) {
611-
function countWatchers() {
612-
var scope = $rootScope;
613-
var watchers = 0;
614-
615-
while (scope) {
616-
watchers += scope.$$watchers.length;
617-
if (scope.$$childHead) {
618-
scope = scope.$$childHead;
619-
} else if (scope.$$nextSibling) {
620-
scope = scope.$$nextSibling;
621-
} else {
622-
scope = null;
623-
}
624-
}
625-
626-
return watchers;
627-
}
628611

629612
var html =
630613
'<div ng-messages="items">' +
@@ -638,14 +621,14 @@ fdescribe('ngMessages', function() {
638621
});
639622

640623
expect(element.text()).toBe('A');
641-
var watchers = countWatchers();
624+
var watchers = $rootScope.$countWatchers();
642625

643626
$rootScope.$apply('items.a = false');
644627

645628
expect(element.text()).toBe('');
646629
// We don't know exactly how many watchers are on the scope, only that there should be
647630
// one less now
648-
expect(countWatchers()).toBe(watchers-1);
631+
expect($rootScope.$countWatchers()).toBe(watchers - 1);
649632
})
650633
);
651634

0 commit comments

Comments
 (0)