Fix Function#name on browsers that don't support it.

Closes #236.
This commit is contained in:
Jürg Lehni 2013-06-11 19:07:25 -07:00
parent 18383875eb
commit 2e565dcfce

View file

@ -10,6 +10,15 @@
* All rights reserved.
*/
// First check if Function#name works, and if not, fix it by injecting a getter
if (!(function f() {}).name) {
Base.define(Function.prototype, 'name', {
get: function() {
return this.toString().match(/^function\s?(\w*)\(/)[1];
}
});
}
/**
* @name Base
* @class