mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-26 19:56:49 +00:00
Make ve.dm.Surface.{start,stop}HistoryTracking idempotent.
Add a little robustness, guaranteeing that we don't end up with multiple history tracking tasks running, leaking one, or try to clear a non-running interval. Change-Id: I41db2d6fefc7f45f150aa14ecefc648760ad6200
This commit is contained in:
parent
3f7761d242
commit
4fee78227d
|
@ -101,7 +101,9 @@ ve.dm.Surface.prototype.startHistoryTracking = function () {
|
|||
if ( !this.enabled ) {
|
||||
return;
|
||||
}
|
||||
if ( this.historyTrackingInterval === null ) {
|
||||
this.historyTrackingInterval = setInterval( ve.bind( this.breakpoint, this ), 750 );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -113,7 +115,10 @@ ve.dm.Surface.prototype.stopHistoryTracking = function () {
|
|||
if ( !this.enabled ) {
|
||||
return;
|
||||
}
|
||||
if ( this.historyTrackingInterval !== null ) {
|
||||
clearInterval( this.historyTrackingInterval );
|
||||
this.historyTrackingInterval = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue