X Tutup
Skip to content

Commit 5103f08

Browse files
committed
fix(test): function.name is not available (IE11)
1 parent 1f20ef9 commit 5103f08

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

karma-js.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module.exports = function(config) {
2424
'node_modules/reflect-metadata/Reflect.js',
2525
'tools/build/file2modulename.js',
2626
'test-main.js',
27-
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
27+
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false},
28+
'modules/angular2/src/test_lib/shims_for_IE.es6'
2829
],
2930

3031
exclude: [
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//function.name
2+
/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/
3+
if (!(function f() {}).name) {
4+
Object.defineProperty(Function.prototype, 'name', {
5+
get: function() {
6+
var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
7+
// For better performance only parse once, and then cache the
8+
// result through a new accessor for repeated access.
9+
Object.defineProperty(this, 'name', { value: name });
10+
return name;
11+
}
12+
});
13+
}

0 commit comments

Comments
 (0)
X Tutup