From aa822b670c8137bd069f75de990cb82668133020 Mon Sep 17 00:00:00 2001 From: Cris Ward Date: Sat, 7 May 2016 14:03:33 +0100 Subject: [PATCH] added polyfill for travis --- test/bind-polyfill.js | 27 +++++++++++++++++++++++++++ test/parents.coffee | 1 + 2 files changed, 28 insertions(+) create mode 100644 test/bind-polyfill.js diff --git a/test/bind-polyfill.js b/test/bind-polyfill.js new file mode 100644 index 0000000..4175610 --- /dev/null +++ b/test/bind-polyfill.js @@ -0,0 +1,27 @@ +if (!Function.prototype.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 + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + if (this.prototype) { + // Function.prototype doesn't have a prototype property + fNOP.prototype = this.prototype; + } + fBound.prototype = new fNOP(); + + return fBound; + }; +} \ No newline at end of file diff --git a/test/parents.coffee b/test/parents.coffee index 1b7ed97..d7c13d8 100644 --- a/test/parents.coffee +++ b/test/parents.coffee @@ -1,3 +1,4 @@ +require './bind-polyfill.js' window.riot = require 'riot' parents = require '../lib/parents.js' simulant = require 'simulant'