Updated Branches: refs/heads/wicket-1.5.x e9375d2cd -> df78e455f
WICKET-5026 wicket-event.js defined Function.prototype.bind doesn't support prepended arguments Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/df78e455 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/df78e455 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/df78e455 Branch: refs/heads/wicket-1.5.x Commit: df78e455ff5449394511a2db88b759586bf5fc8d Parents: e9375d2 Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Authored: Tue Feb 19 18:01:49 2013 +0200 Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Committed: Tue Feb 19 18:01:49 2013 +0200 ---------------------------------------------------------------------- .../org/apache/wicket/markup/html/wicket-event.js | 28 +++++++++++--- 1 files changed, 22 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/df78e455/wicket-core/src/main/java/org/apache/wicket/markup/html/wicket-event.js ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/wicket-event.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/wicket-event.js index 688e74f..aad8d4f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/wicket-event.js +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/wicket-event.js @@ -22,13 +22,29 @@ * @author Matej Knopp */ -if (Function.prototype.bind == null) { - Function.prototype.bind = function(object) { - var __method = this; - return function() { - return __method.apply(object, arguments); +if (!Function.prototype.bind) { + // taken from https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } - } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; } // Wicket Namespace