From 9c854e7ae3c7657cf3db9e60f92a0f9ff3e522f9 Mon Sep 17 00:00:00 2001 From: remojansen Date: Sun, 18 Oct 2015 21:22:29 +0100 Subject: [PATCH] working on #23 --- dist/inversify.js | 4 ++-- source/kernel.ts | 9 ++------- test/inversify.test.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dist/inversify.js b/dist/inversify.js index 97a0d4c2e..23ef60c71 100644 --- a/dist/inversify.js +++ b/dist/inversify.js @@ -1,7 +1,7 @@ /** - * inversify v.1.0.1 - A lightweight IoC container written in TypeScript. + * inversify v.1.0.2 - A lightweight IoC container written in TypeScript. * Copyright (c) 2015 Remo H. Jansen * MIT inversify.io/LICENSE * http://inversify.io */ -!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.inversify=n()}}(function(){return function n(e,t,i){function r(u,p){if(!t[u]){if(!e[u]){var c="function"==typeof require&&require;if(!p&&c)return c(u,!0);if(o)return o(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=t[u]={exports:{}};e[u][0].call(f.exports,function(n){var t=e[u][1][n];return r(t?t:n)},f,f.exports,n,e,t,i)}return t[u].exports}for(var o="function"==typeof require&&require,u=0;u( constr : { new(): TImplementationType ;}, args : Object[]) : TImplementationType { - - function F() : void { - constr.apply(this, args); - } - - F.prototype = constr.prototype; - return new F(); + return new (Function.prototype.bind.apply(constr, [null].concat(args))); } + } export { Kernel }; diff --git a/test/inversify.test.ts b/test/inversify.test.ts index 171135a29..291fb76a8 100644 --- a/test/inversify.test.ts +++ b/test/inversify.test.ts @@ -6,6 +6,36 @@ var expect = chai.expect; declare var Map; +// Polyfill for Function.prototype.bind more details at +// https://github.com/ariya/phantomjs/issues/10522 +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) { + // native functions don't have a prototype + fNOP.prototype = this.prototype; + } + fBound.prototype = new fNOP(); + + return fBound; + }; +} + //****************************************************************************** //* MOCKS AND STUBS //******************************************************************************