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; // Callback to fire after each timeout;
// update bounds and schedule another timeout // update bounds and schedule another timeout
function onInterval() { function onInterval() {
if (!active) {
return;
}
fireEval({ fireEval({
width: element[0].offsetWidth, width: element[0].offsetWidth,
height: element[0].offsetHeight height: element[0].offsetHeight
}); });
if (active) { $timeout(onInterval, currentInterval(), false);
$timeout(onInterval, currentInterval(), false);
}
} }
// Stop running in the background // Stop running in the background

View File

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