2 * http://pettanr.sourceforge.jp/test/type.html
\r
8 isObject : function( v ){
\r
9 return v && typeof v === 'object'; // typeof null === 'object' に対策
\r
12 isFunction : function( v ){
\r
13 return typeof v === 'function';
\r
16 isUnknown : function( v ){
\r
17 return typeof v === 'unknown'; // ie の XHR.open など
\r
23 'return v&&v.push===Array.prototype.push' : // win ie5-, MacIE5.2
\r
25 'return v&&Object.prototype.toString.call(v)==="[object Array]"' :
\r
26 'return v instanceof Array'
\r
29 isBoolean : function( v ){
\r
30 return v === true || v === false;
\r
33 isString : function( v ){
\r
34 return typeof v === 'string'; // v === v + '';
\r
37 isNumber : function( v ){
\r
38 return typeof v === 'number'; // v !== v || v + 0 === v;
\r
41 isFinite : function( v ){
\r
42 return typeof v === 'number' && isFinite( v ); // isFinite( '123' ) === true に対策
\r
45 isNaN : function( v ){
\r
46 return v !== v; // isNaN( 'NaN' ) === true に対策
\r
51 ( X_UA.IE4 || X_UA.MacIE ) ?
\r
52 'return v&&v.tagName&&v.insertAdjacentHTML&&true' : // ie4 or MacIE5.23, v.all <- error
\r
53 window[ 'HTMLElement' ] ?
\r
54 'return v instanceof HTMLElement' :
\r
55 //window[ 'Element' ] ?
\r
56 // 'return v instanceof Element' : // error @ie8
\r
57 'return v&&v.appendChild&&v.nodeType===1'
\r
61 * new Image した場合に HTMLElement の img が作られるブラウザもある
\r
65 if( v && v.constructor === window.Image ) return true;
\r
66 if( v && window.HTMLImageElement && v.constructor === window.HTMLImageElement ) return true; // ie6- は constructor が undef、HTMLImageElement が undef なので、HTMLElement の存在確認が必要
\r
67 if( X_UA.WebKit < 525.13 ){ // Safari3-
\r
68 if( v && v.src !== undefined && v.onload !== undefined && X.Type.isNumber( v.height ) && X.Type.isNumber( v.width ) && X.Type.isBoolean( v.complete ) ){
\r
75 isElementCollection : function(v) {
\r
76 return (Object.prototype.toString.call(v) === "[object HTMLCollection]");
\r
79 isNull : function( v ){
\r
83 isUndefined : function( v ){
\r
84 return v === void 0;
\r
88 console.log( 'X.Core.Type' );
\r