Merge pull request #1640 from nasa/fix-error-on-table-destroy

[Resize] don't trigger callback after being destroyed
This commit is contained in:
Luis-Johannes Schubert 2017-07-05 17:24:16 -07:00 committed by GitHub
commit 0794c0edf7
2 changed files with 9 additions and 3 deletions

View File

@ -83,13 +83,14 @@ define(
// Callback to fire after each timeout;
// update bounds and schedule another timeout
function onInterval() {
if (!active) {
return;
}
fireEval({
width: element[0].offsetWidth,
height: element[0].offsetHeight
});
if (active) {
$timeout(onInterval, currentInterval(), false);
}
$timeout(onInterval, currentInterval(), false);
}
// Stop running in the background

View File

@ -102,11 +102,16 @@ define(
// Broadcast a destroy event
mockScope.$on.mostRecentCall.args[1]();
testElement.offsetWidth = 300;
testElement.offsetHeight = 350;
mockScope.$eval.reset();
// Fire the timeout
mockTimeout.mostRecentCall.args[0]();
// Should NOT have scheduled another timeout
expect(mockTimeout.calls.length).toEqual(2);
expect(mockScope.$eval).not.toHaveBeenCalled();
});
it("triggers a digest cycle when size changes", function () {