diff --git a/source/Ox/js/Type.js b/source/Ox/js/Type.js index 9191beac..1f44fa91 100644 --- a/source/Ox/js/Type.js +++ b/source/Ox/js/Type.js @@ -337,11 +337,18 @@ Ox.typeOf Returns the type of a value Ox.typeOf = function(value) { return Object.prototype.toString.call(value).slice(8, -1).toLowerCase(); }; -if (Ox.typeOf() != 'undefined') { - // Handle Mobile Safari - Ox.typeOf = function(value) { - return value === null ? 'null' - : value === void 0 ? 'undefined' - : Object.prototype.toString.call(value).slice(8, -1).toLowerCase(); - }; -} +(function() { + // Internet Explorer returns 'HTMLCollection' instead of 'NodeList', + // Mobile Safari doesn't like null and undefined + var nodelist = Ox.typeOf(document.getElementsByTagName('a')); + if (nodelist != 'nodelist' || Ox.typeOf() != 'undefined') { + Ox.typeOf = function(value) { + var type = value === null ? 'null' + : value === void 0 ? 'undefined' + : Object.prototype.toString.call( + value + ).slice(8, -1).toLowerCase(); + return type == nodelist ? 'nodelist' : type; + }; + } +})();