mirror of
https://github.com/nasa/openmct.git
synced 2025-06-05 09:00:49 +00:00
Merge pull request #1640 from nasa/fix-error-on-table-destroy
[Resize] don't trigger callback after being destroyed
This commit is contained in:
commit
0794c0edf7
@ -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
|
||||||
|
@ -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 () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user