Skip to content

Commit

Permalink
fix(ncyBreadcrumb): Prevent memory leak when label is a binding
Browse files Browse the repository at this point in the history
Releases collection of watchers, preventing a leak when the label is a binding and not a string
  • Loading branch information
tghamm committed May 2, 2015
1 parent ef73525 commit 264e10f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dist/angular-breadcrumb.js
@@ -1,4 +1,4 @@
/*! angular-breadcrumb - v0.3.3-dev-2015-04-21
/*! angular-breadcrumb - v0.3.3-dev-2015-05-02
* http://ncuillery.github.io/angular-breadcrumb
* Copyright (c) 2015 Nicolas Cuillery; Licensed MIT */

Expand Down Expand Up @@ -177,7 +177,6 @@ var deregisterWatchers = function(labelWatcherArray) {
angular.forEach(labelWatcherArray, function(deregisterWatch) {
deregisterWatch();
});
labelWatcherArray = [];
};

function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
Expand Down Expand Up @@ -209,6 +208,8 @@ function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {

var renderBreadcrumb = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
scope.steps = $breadcrumb.getStatesChain();
angular.forEach(scope.steps, function (step) {
Expand Down Expand Up @@ -255,6 +256,8 @@ function BreadcrumbLastDirective($interpolate, $breadcrumb, $rootScope) {

var renderLabel = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
var lastStep = $breadcrumb.getLastStep();
if(lastStep) {
Expand Down Expand Up @@ -318,6 +321,7 @@ function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope) {

var renderLabel = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
var steps = $breadcrumb.getStatesChain();
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-breadcrumb.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/angular-breadcrumb.js
Expand Up @@ -172,7 +172,6 @@ var deregisterWatchers = function(labelWatcherArray) {
angular.forEach(labelWatcherArray, function(deregisterWatch) {
deregisterWatch();
});
labelWatcherArray = [];
};

function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
Expand Down Expand Up @@ -204,6 +203,8 @@ function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {

var renderBreadcrumb = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
scope.steps = $breadcrumb.getStatesChain();
angular.forEach(scope.steps, function (step) {
Expand Down Expand Up @@ -250,6 +251,8 @@ function BreadcrumbLastDirective($interpolate, $breadcrumb, $rootScope) {

var renderLabel = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
var lastStep = $breadcrumb.getLastStep();
if(lastStep) {
Expand Down Expand Up @@ -313,6 +316,7 @@ function BreadcrumbTextDirective($interpolate, $breadcrumb, $rootScope) {

var renderLabel = function() {
deregisterWatchers(labelWatchers);
labelWatchers = [];

var viewScope = $breadcrumb.$getLastViewScope();
var steps = $breadcrumb.getStatesChain();
Expand Down

0 comments on commit 264e10f

Please sign in to comment.