From b25443d142375fedc9020e98ee940e80ec9b5130 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Tue, 7 Apr 2015 09:46:31 +0200 Subject: [PATCH] foosel/Octoprint #841: Can't login using IE Add computed property "name" to function objects if not provided by the browser, to avoid dropping out of main.js before it is finished. (cherry picked from commit 68215c6) --- src/octoprint/static/js/app/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index ed33b1c9..cbf69503 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -57,6 +57,16 @@ $(function() { // the view model map is our basic look up table for dependencies that may be injected into other view models var viewModelMap = {}; + // Fix Function#name on browsers that do not support it (IE): + // see: http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie + if (!(function f() {}).name) { + Object.defineProperty(Function.prototype, 'name', { + get: function() { + return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; + } + }); + } + // helper to create a view model instance with injected constructor parameters from the view model map var _createViewModelInstance = function(viewModel, viewModelMap){ var viewModelClass = viewModel[0];