fix(test): function.name is not available (IE11)

This commit is contained in:
Marc Laval 2015-05-21 11:30:56 +02:00
parent 1f20ef9787
commit 5103f080e9
2 changed files with 15 additions and 1 deletions

View File

@ -24,7 +24,8 @@ module.exports = function(config) {
'node_modules/reflect-metadata/Reflect.js',
'tools/build/file2modulename.js',
'test-main.js',
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false},
'modules/angular2/src/test_lib/shims_for_IE.es6'
],
exclude: [

View File

@ -0,0 +1,13 @@
//function.name
/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/
if (!(function f() {}).name) {
Object.defineProperty(Function.prototype, 'name', {
get: function() {
var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[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 });
return name;
}
});
}