From ff3df2d9b2c01c1ca0d12c1fcaf136528287fb6d Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 6 Sep 2017 11:44:48 +0200 Subject: [PATCH] fix: RestoreScroll was running out of sync (#508) --- lib/core/public/run-rules.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js index a358afaa26..1d7ad954df 100644 --- a/lib/core/public/run-rules.js +++ b/lib/core/public/run-rules.js @@ -28,18 +28,18 @@ function runRules(context, options, resolve, reject) { axe.utils.collectResultsFromFrames(context, options, 'rules', null, res, rej); }); } + let scrollState; q.defer(function (res, rej) { if (options.restoreScroll) { - const scrollState = axe.utils.getScrollState(); - audit.run(context, options, res, rej); - axe.utils.setScrollState(scrollState); - - } else { - audit.run(context, options, res, rej); + scrollState = axe.utils.getScrollState(); } + audit.run(context, options, res, rej); }); q.then(function (data) { try { + if (scrollState) { + axe.utils.setScrollState(scrollState); + } if (options.performanceTimer) { axe.utils.performanceTimer.auditEnd(); }