Fix a breakage when changing diff revisions while loading diffs.
Review Request #9118 — Created Aug. 3, 2017 and submitted — Latest diff uploaded
When loading a large diff, users could trigger a page crash by
attempting to change the pagination page or the diff revision. They'd
hit an error in the console and no new diffs would load.This was caused by an assumption in the load callback handler that the
container for the diff would exist by the time the data was loaded from
the server. If this assumption failed, an invalid attribute would be
accessed, leading to a crash. This would also prevent the next queued
load from occurring, and in turn prevent the queue from ever finishing.
The new page of diffs wouldn't be able to load.The load handler now checks for the existence of the container, aborting
the load if it no longer exists. Switching pages/diff revisions also now
starts off by clearing the queue to ensure it can start fresh.
Tried switching the set of diffs being shown while diffs were loading.
I no longer experienced the crash, and the new diffs successfully loaded.