Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit edb4fa1

Browse files
committed
fix(ui-ace): call $destroy when removed
1 parent da28851 commit edb4fa1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

test/ace.spec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ describe('uiAce', function () {
156156
expect(compileWithObject).toThrow();
157157
});
158158
});
159+
160+
it('should call destroy when the element is removed', function () {
161+
var element = $compile('<div ui-ace ng-model="foo">')(scope);
162+
spyOn(_ace, 'destroy').andCallThrough();
163+
spyOn(_ace.session, '$stopWorker').andCallThrough();
164+
165+
element.remove();
166+
scope.$apply();
167+
168+
expect(_ace.session.$stopWorker).toHaveBeenCalled();
169+
expect(_ace.destroy).toHaveBeenCalled();
170+
});
159171
});
160172

161173
describe('when the model is an object or an array', function () {
@@ -177,5 +189,4 @@ describe('uiAce', function () {
177189
});
178190
});
179191

180-
181-
});
192+
});

ui-ace.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ angular.module('ui.ace', [])
9494
// EVENTS
9595
session.on('change', onChange(opts.onChange));
9696

97+
elm.on('$destroy', function() {
98+
acee.session.$stopWorker();
99+
acee.destroy();
100+
});
97101
}
98102
};
99103
}]);

0 commit comments

Comments
 (0)