fix(shims): function.name to return empty string when no name
This commit is contained in:
@ -3,7 +3,8 @@
|
||||
if (!Object.hasOwnProperty('name')) {
|
||||
Object.defineProperty(Function.prototype, 'name', {
|
||||
get: function() {
|
||||
var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
|
||||
var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/);
|
||||
var name = matches && matches.length > 1 ? matches[1] : "";
|
||||
// For better performance only parse once, and then cache the
|
||||
// result through a new accessor for repeated access.
|
||||
Object.defineProperty(this, 'name', {value: name});
|
||||
|
Reference in New Issue
Block a user