From 266274a9612ab8b6e61b63961e5f528cb02d6000 Mon Sep 17 00:00:00 2001 From: dubejf Date: Thu, 2 Jul 2015 09:35:34 -0400 Subject: [PATCH] Polyfill for es6 Function.Name Gets the name of a function (missing in IE9-11). This is useful during serialization, to extract the name the constructor function. ``` type = attribute.array.constructor.name; // e.g. "Float32Array" ``` Fixes #6349. --- src/Three.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Three.js b/src/Three.js index 8cf7d7b50a..ab74bb59a6 100644 --- a/src/Three.js +++ b/src/Three.js @@ -26,6 +26,23 @@ if ( Math.sign === undefined ) { } +if ( Function.prototype.name === undefined && Object.defineProperty !== undefined ) { + + // Missing in IE9-11. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name + + Object.defineProperty( Function.prototype, 'name', { + + get: function() { + + var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; + return name; + + } + + }); +} + // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 }; -- GitLab