From 9d9ec75abeefa5628b2a0ad7b6b8a2978d1a551f Mon Sep 17 00:00:00 2001 From: Dan Clarizio Date: Wed, 5 Oct 2016 08:54:07 -0700 Subject: [PATCH] Merge pull request #11707 from himdel/fix-qe Fix QE JS helpers' debounce not preserving this (cherry picked from commit f1b91c10a47375d149f73575934427d07f2b1146) --- app/assets/javascripts/miq_qe.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/miq_qe.js b/app/assets/javascripts/miq_qe.js index eab1325c3d8..799eff8e4f0 100644 --- a/app/assets/javascripts/miq_qe.js +++ b/app/assets/javascripts/miq_qe.js @@ -3,7 +3,7 @@ ManageIQ.qe.get_debounce_index = function () { ManageIQ.qe.debounce_counter = 0; } return ManageIQ.qe.debounce_counter++; -} +}; if (typeof _ !== 'undefined' && typeof _.debounce !== 'undefined') { var orig_debounce = _.debounce; @@ -14,21 +14,21 @@ if (typeof _ !== 'undefined' && typeof _.debounce !== 'undefined') { // We make sure that once this fn is actually run, it decreases the counter var new_func = function() { try { - return func.apply({}, arguments); + return func.apply(this, arguments); } finally { // this is run before the return above, always delete ManageIQ.qe.debounced[debounce_index]; } - } + }; // Override the newly-created fn (prepended wait + original fn) // We have to increase the counter before the waiting is initiated var debounced_func = orig_debounce.call(this, new_func, wait, options); var new_debounced_func = function() { ManageIQ.qe.debounced[debounce_index] = 1; return debounced_func.apply(this, arguments); - } + }; return new_debounced_func; - } + }; } ManageIQ.qe.xpath = function(root, xpath) {