From 7961963ac2f6f982ef2ec517785193f9780a54ee Mon Sep 17 00:00:00 2001 From: Simone Baruzza Date: Tue, 2 Feb 2016 16:07:46 +0100 Subject: [PATCH] Fix resume event passed to updateTextZoom as callback argument Wrapped resume event handler to avoid event argument being passed to updateTextZoom and hence being called .apply() onto. --- www/mobile-accessibility.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/www/mobile-accessibility.js b/www/mobile-accessibility.js index 7af1314..8065b6a 100644 --- a/www/mobile-accessibility.js +++ b/www/mobile-accessibility.js @@ -255,11 +255,19 @@ MobileAccessibility.prototype.usePreferredTextZoom = function(bool) { window.localStorage.setItem("MobileAccessibility.usePreferredTextZoom", bool); } - document.removeEventListener("resume", mobileAccessibility.updateTextZoom); + var callback = function(){ + // Wrapping updateTextZoom call in a function to stop + // the event parameter propagation. This fixes an error + // on resume where cordova tried to call apply() on the + // event, expecting a function. + mobileAccessibility.updateTextZoom(); + }; + + document.removeEventListener("resume", callback); if (bool) { // console.log("We should update the text zoom at this point: " + bool) - document.addEventListener("resume", mobileAccessibility.updateTextZoom, false); + document.addEventListener("resume", callback, false); mobileAccessibility.updateTextZoom(); } else { mobileAccessibility.setTextZoom(100);