From ebc1855483d4ba59cd2d25d206b30bab4c80e6c6 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 16 May 2012 17:10:26 +0100 Subject: [PATCH] Another tweak for "evaluateAsync". Making sure all the parameters are passed on correctly. http://code.google.com/p/phantomjs/issues/detail?id=593 --- src/modules/webpage.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/webpage.js b/src/modules/webpage.js index d2b2a087..2cbb753e 100644 --- a/src/modules/webpage.js +++ b/src/modules/webpage.js @@ -220,14 +220,15 @@ exports.create = function (opts) { * @param {...} args function arguments */ page.evaluateAsync = function (func, timeMs, args) { - var funcAsync; + var args = Array.prototype.splice.call(arguments, 0); if (!(func instanceof Function || typeof func === 'string' || func instanceof String)) { throw "Wrong use of WebPage#evaluateAsync"; } - funcAsync = "function() { setTimeout(" + func.toString() + ", " + timeMs + "); }"; + // Wrapping the "func" argument into a setTimeout + args.splice(0, 0, "function() { setTimeout(" + func.toString() + ", " + timeMs + "); }"); - this.evaluate(funcAsync, arguments); + this.evaluate.apply(this, args); }; // Copy options into page