From 5ad848c563bacb2ca76f5badcb7d47af9e1cafcd Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 25 May 2012 21:19:27 +0200 Subject: [PATCH] fix Ox.typeOf --- source/Ox/js/Type.js | 60 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/source/Ox/js/Type.js b/source/Ox/js/Type.js index 331ee625..5e8f707f 100644 --- a/source/Ox/js/Type.js +++ b/source/Ox/js/Type.js @@ -303,7 +303,7 @@ Ox.isUndefined = function(value) { Ox.typeOf Returns the type of a value (value) -> Type value <*> Any value - > (function() { return Ox.typeOf(arguments); }()) + > Ox.typeOf((function() { return arguments; }())) 'arguments' > Ox.typeOf([]) 'array' @@ -341,33 +341,31 @@ Ox.typeOf = function(value) { // Internet Explorer 8 returns 'Object' instead of 'NodeList', // Internet Explorer 9 returns 'HTMLCollection' instead of 'NodeList', // Mobile Safari doesn't like null and undefined -(function() { - if ( - Ox.typeOf(arguments) != 'arguments' - || Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist' - || Ox.typeOf(null) != 'null' - || Ox.typeOf() != 'undefined' - ) { - Ox.typeOf = function(value) { - var ret = Object.prototype.toString.call( - value - ).slice(8, -1).toLowerCase(); - if (typeof value.callee == 'function') { - ret = 'arguments'; - } else if ( - ret == 'htmlcollection' || ( - ret == 'object' - && typeof value.item != 'undefined' - && typeof value.length == 'number' - ) - ) { - ret = 'nodelist'; - } else if (value === null) { - ret = 'null'; - } else if (value === void 0) { - ret = 'undefined' - } - return ret; - }; - } -})(); +if ( + Ox.typeOf((function() { return arguments; }())) != 'arguments' + || Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist' + || Ox.typeOf(null) != 'null' + || Ox.typeOf() != 'undefined' +) { + Ox.typeOf = function(value) { + var ret = Object.prototype.toString.call( + value + ).slice(8, -1).toLowerCase(); + if (ret == 'object' && typeof value.callee == 'function') { + ret = 'arguments'; + } else if ( + ret == 'htmlcollection' || ( + ret == 'object' + && typeof value.item != 'undefined' + && typeof value.length == 'number' + ) + ) { + ret = 'nodelist'; + } else if (value === null) { + ret = 'null'; + } else if (value === void 0) { + ret = 'undefined' + } + return ret; + }; +}