fixed `each()` method which was broken
regression occured in dd5c9fda
Showing
1 changed file
with
6 additions
and
8 deletions
... | @@ -226,11 +226,7 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { | ... | @@ -226,11 +226,7 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { |
226 | clearInterval(self.checker); | 226 | clearInterval(self.checker); |
227 | self.emit('run.complete'); | 227 | self.emit('run.complete'); |
228 | if (utils.isFunction(onComplete)) { | 228 | if (utils.isFunction(onComplete)) { |
229 | try { | 229 | onComplete.call(self, self); |
230 | onComplete.call(self, self); | ||
231 | } catch (err) { | ||
232 | self.log("Could not complete final step: " + err, "error"); | ||
233 | } | ||
234 | } else { | 230 | } else { |
235 | // default behavior is to exit | 231 | // default behavior is to exit |
236 | self.exit(); | 232 | self.exit(); |
... | @@ -375,9 +371,11 @@ Casper.prototype.each = function each(array, fn) { | ... | @@ -375,9 +371,11 @@ Casper.prototype.each = function each(array, fn) { |
375 | this.log("each() only works with arrays", "error"); | 371 | this.log("each() only works with arrays", "error"); |
376 | return this; | 372 | return this; |
377 | } | 373 | } |
378 | array.forEach.call(this, function _forEach(item, i) { | 374 | (function _each(self) { |
379 | fn.call(this, this, item, i); | 375 | array.forEach(function _forEach(item, i) { |
380 | }); | 376 | fn.call(self, self, item, i); |
377 | }); | ||
378 | })(this); | ||
381 | return this; | 379 | return this; |
382 | }; | 380 | }; |
383 | 381 | ... | ... |
-
Please register or sign in to post a comment