fix Ox.typeOf

This commit is contained in:
rolux 2012-05-25 21:19:27 +02:00
parent f46ff46da8
commit 5ad848c563

View file

@ -303,7 +303,7 @@ Ox.isUndefined = function(value) {
Ox.typeOf <f> Returns the type of a value Ox.typeOf <f> Returns the type of a value
(value) -> <s> Type (value) -> <s> Type
value <*> Any value value <*> Any value
> (function() { return Ox.typeOf(arguments); }()) > Ox.typeOf((function() { return arguments; }()))
'arguments' 'arguments'
> Ox.typeOf([]) > Ox.typeOf([])
'array' 'array'
@ -341,33 +341,31 @@ Ox.typeOf = function(value) {
// Internet Explorer 8 returns 'Object' instead of 'NodeList', // Internet Explorer 8 returns 'Object' instead of 'NodeList',
// Internet Explorer 9 returns 'HTMLCollection' instead of 'NodeList', // Internet Explorer 9 returns 'HTMLCollection' instead of 'NodeList',
// Mobile Safari doesn't like null and undefined // Mobile Safari doesn't like null and undefined
(function() { if (
if ( Ox.typeOf((function() { return arguments; }())) != 'arguments'
Ox.typeOf(arguments) != 'arguments' || Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist'
|| Ox.typeOf(document.getElementsByTagName('a')) != 'nodelist' || Ox.typeOf(null) != 'null'
|| Ox.typeOf(null) != 'null' || Ox.typeOf() != 'undefined'
|| Ox.typeOf() != 'undefined' ) {
) { Ox.typeOf = function(value) {
Ox.typeOf = function(value) { var ret = Object.prototype.toString.call(
var ret = Object.prototype.toString.call( value
value ).slice(8, -1).toLowerCase();
).slice(8, -1).toLowerCase(); if (ret == 'object' && typeof value.callee == 'function') {
if (typeof value.callee == 'function') { ret = 'arguments';
ret = 'arguments'; } else if (
} else if ( ret == 'htmlcollection' || (
ret == 'htmlcollection' || ( ret == 'object'
ret == 'object' && typeof value.item != 'undefined'
&& typeof value.item != 'undefined' && typeof value.length == 'number'
&& typeof value.length == 'number' )
) ) {
) { ret = 'nodelist';
ret = 'nodelist'; } else if (value === null) {
} else if (value === null) { ret = 'null';
ret = 'null'; } else if (value === void 0) {
} else if (value === void 0) { ret = 'undefined'
ret = 'undefined' }
} return ret;
return ret; };
}; }
}
})();