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)
This commit is contained in:
Mark Walker 2015-04-07 09:46:31 +02:00 committed by Gina Häußge
parent 354e064969
commit b25443d142

View file

@ -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];