FacultyCreative / ngActiveResource

Connects business objects and REST web services for Angular.js
255 stars 34 forks source link

Function.name property used - fails in IE #61

Open briebug opened 10 years ago

briebug commented 10 years ago

Love the project, not sure if anyone is actively working on issues. I am seeing that this library does not work with IE at all due to the use of the ECMAScript6 function.name which is not supported at all by IE. I see 17 instances of klass.name in the source code.

Any plans on updating this so that it will work with IE?

Cheers

nodesfactory commented 10 years ago

Hi,

I am having the same problem as you. Pending a fix for internet explorer, I have applied the following solution, to monkey patch internet explorer :

if (Function.prototype.name === undefined && Object.defineProperty !== undefined) {
    Object.defineProperty(Function.prototype, 'name', {
        get: function() {
            var funcNameRegex = /function\s([^(]{1,})\(/;
            var results = (funcNameRegex).exec((this).toString());
            return (results && results.length > 1) ? results[1].trim() : "";
        },
        set: function(value) {}
    });
}

This is certainly not ideal, but it solves the problem ;)