X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F03_XType.js;h=84bca3d2c863746bd796adea4ce1dcc41512a823;hb=24f935c7a129b0a00d800e4983da6491a913aeef;hp=fdf181c8642c7d2d1b209d29f2a108cf06e913f9;hpb=a130cabd01fde8865990a59d849f5d5d08ed2119;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_core/03_XType.js b/0.6.x/js/01_core/03_XType.js index fdf181c..84bca3d 100644 --- a/0.6.x/js/01_core/03_XType.js +++ b/0.6.x/js/01_core/03_XType.js @@ -1,10 +1,9 @@ -var /** * Array ãï¼å¤å®ãããargumnets çã®ãã§ã¤ã¯ Array 㯠false ãªã®ã§æ³¨æã - * @funciton - * @alias X.Type._isArray + * @function + * @alias X.Type.isArray */ - X_Type_isArray = +var X_Type_isArray = new Function( 'v', X_UA[ 'IE' ] < 5.5 || X_UA[ 'NetFront' ] < 4 ? // netfront3.4 㯠html ã« instanceof ããã㨠error ã«ãªã 'return v&&v.push===Array.prototype.push' : // win ie5-, MacIE5.2 @@ -15,13 +14,13 @@ var /** * HTMLElement ãï¼å¤å®ãããã¡ãªã¿ã« return v instanceof Element 㯠ie8 ã§ã¨ã©ã¼ã - * @funciton + * @function * @alias X.Type.isHTMLElement */ X_Type_isHTMLElement = new Function( 'v', ( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ) ? - 'return v&&v.tagName&&v.insertAdjacentHTML&&true' : // ie4 or MacIE5.23, v.all <- error + 'return v&&v.tagName&&v.insertAdjacentHTML&&!0' : // ie4 or MacIE5.23, v.all <- error X_UA[ 'NetFront' ] < 4 ? 'return v&&v.nodeType===1' : // instanceof not a function. netfront3.4 㯠html ã« instanceof ããã㨠error ã«ãªã window[ 'HTMLElement' ] ? @@ -32,9 +31,8 @@ var /** - * http://pettanr.sourceforge.jp/test/type.html - * ãã«ãã¤ã³æ¹ã®å¤å®ã«ä½¿ç¨ããé¢æ°ãéãããã®ããã©ã¦ã¶ã®ãã¤ãã£ããªå¤å®é¢æ°ã«ã¯ä¸å¯è§£ãªæåãããã®ã§ãX.Type ã使ç¨ããã»ããããã - * + *
ãã«ãã¤ã³åã®å¤å®ã«ä½¿ç¨ããé¢æ°ãéãããã®ããã©ã¦ã¶ã®ãã¤ãã£ããªå¤å®é¢æ°ã«ã¯ä¸å¯è§£ãªæåãããã®ã§ãX.Type ã使ç¨ããã»ããããã + * http://pettanr.sourceforge.jp/test/type.html * @namespace X.Type * @alias X.Type */ @@ -55,11 +53,13 @@ X[ 'Type' ] = { }; /** - * Object ãï¼å¤å®ãããtypeof null === 'object' ã«å¯¾çæ¸ãªã®ã§ null 㯠Object ã§ã¯ãªãã + *
Object ãï¼å¤å®ããã + *
typeof null === 'object' ã«å¯¾çæ¸ãªã®ã§ null 㯠Object ã§ã¯ãªãã + *
new String(), new Number(), new Boolean() ã typeof object ãªã®ã§å¯¾ç * @alias X.Type.isObject */ function X_Type_isObject( v ){ - return v && typeof v === 'object'; // typeof null === 'object' ã«å¯¾ç + return v && typeof v === 'object' && v !== v + '' && v !== v + 0 && v !== true; // typeof null === 'object' ã«å¯¾ç }; /** * Function ãï¼å¤å®ããã @@ -88,21 +88,21 @@ X[ 'Type' ] = { * @alias X.Type.isString */ function X_Type_isString( v ){ - return typeof v === 'string'; // v === v + '';ã// æååã®å ç®ã¯ IE ã§é ãããã + return /* typeof v === 'string'; */ v === v + ''; // æååã®å ç®ã¯ IE ã§é ãããã }; /** - * æ°å¤å¤ãï¼å¤å®ããã + * æ°å¤ãï¼å¤å®ããã * @alias X.Type.isNumber */ function X_Type_isNumber( v ){ - return typeof v === 'number'; // v !== v || v + 0 === v; + return /* typeof v === 'number'; */ v + 0 === v || v !== v; }; /** * finite ãï¼å¤å®ãããisFinite( '123' ) === true ã«å¯¾çæ¸ã * @alias X.Type.isFinite */ function X_Type_isFinite( v ){ - return typeof v === 'number' && isFinite( v ); + return v + 0 === v && isFinite( v ); }; /** * NaN ãï¼å¤å®ãããisNaN( 'NaN' ) === true ã«å¯¾çæ¸ã @@ -119,7 +119,7 @@ X[ 'Type' ] = { */ function X_Type_isImage( v ){ if( v && v.constructor === window.Image ) return true; - if( v && window.HTMLImageElement && v.constructor === window.HTMLImageElement ) return true; // ie6- 㯠constructor ããundefãHTMLImageElement ããundef ãªã®ã§ãHTMLElement ã®åå¨ç¢ºèªãå¿ è¦ + if( v && window.HTMLImageElement && v.constructor === window.HTMLImageElement ) return true; // ie6- 㯠constructor ã undefãHTMLImageElement ã undef ãªã®ã§ãHTMLElement ã®åå¨ç¢ºèªãå¿ è¦ if( X_UA[ 'WebKit' ] < 525.13 ){ // Safari3- if( v && v.src !== undefined && v.onload !== undefined && X_Type_isNumber( v.height ) && X_Type_isNumber( v.width ) && X_Type_isBoolean( v.complete ) ){ return true; @@ -144,7 +144,7 @@ X[ 'Type' ] = { * @alias X.Type.isUndefined */ function X_Type_isUndefined( v ){ - return v === void 0; + return v === undefined; }; console.log( 'X.Core.Type' );