OSDN Git Service

Version 0.6.129, fix X.Node.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 04_XBoxModel.js
index d89ca64..4ba6478 100644 (file)
@@ -69,8 +69,8 @@ Node.prototype.width = function(){
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject.offsetWidth;\r
+               // TODO width : length + overflow : hidden ならそれを返す? <- block or inline\r
+               return this._rawObject ? this._rawObject.offsetWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetWidth;\r
@@ -86,7 +86,7 @@ Node.prototype.height = function(){
        \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'height' );\r
-               return this._rawObject.offsetHeight;\r
+               return this._rawObject ? this._rawObject.offsetHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetHeight;\r
@@ -102,7 +102,7 @@ Node.prototype.clientWidth = function(){
        \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject.clientWidth;\r
+               return this._rawObject ? this._rawObject.clientWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientWidth;\r
@@ -118,7 +118,7 @@ Node.prototype.clientHeight = function(){
 \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'height' );\r
-               return this._rawObject.clientHeight;\r
+               return this._rawObject ? this._rawObject.clientHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientHeight;\r
@@ -134,7 +134,7 @@ Node.prototype.scrollWidth = function(){
 \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject.scrollWidth;\r
+               return this._rawObject ? this._rawObject.scrollWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollWidth;\r
@@ -149,7 +149,7 @@ Node.prototype.scrollHeight = function(){
        X_Node_updateTimerID && X_Node_startUpdate();\r
 \r
        if( X_UA_DOM.W3C ){\r
-               return this._rawObject.scrollHeight;\r
+               return this._rawObject ? this._rawObject.scrollHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollHeight;\r
@@ -165,7 +165,7 @@ Node.prototype.scrollLeft = function(){
 \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject.scrollLeft;\r
+               return this._rawObject ? this._rawObject.scrollLeft : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollLeft;\r
@@ -181,7 +181,7 @@ Node.prototype.scrollTop = function(){
        \r
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject.scrollTop;\r
+               return this._rawObject ? this._rawObject.scrollTop : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollTop;\r
@@ -206,7 +206,7 @@ Node.prototype.x = function(){
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'left' );\r
                // this.css( X_Node_CSS_Unit.px, 'translateX' );\r
-               return this._rawObject.offsetLeft;\r
+               return this._rawObject ? this._rawObject.offsetLeft : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                // pixelLeft http://www.din.or.jp/~hagi3/JavaScript/JSTips/DHTML/ProbIE5.htm\r
@@ -224,7 +224,7 @@ Node.prototype.y = function(){
        if( X_UA_DOM.W3C ){\r
                // this.css( X_Node_CSS_Unit.px, 'top' );\r
                // this.css( X_Node_CSS_Unit.px, 'transisitonY' );\r
-               return this._rawObject.offsetTop;\r
+               return this._rawObject ? this._rawObject.offsetTop : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetTop;          \r
@@ -244,7 +244,7 @@ Node.prototype.offset = function( /* xnodeParent */ ){
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               return X_Node_getPosition( this._rawObject );\r
+               return this._rawObject ? X_Node_getPosition( this._rawObject ) : { x : 0, y : 0 };\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                return X_Node_getPosition( this._rawObject || X_Node__ie4getRawNode( this ) );\r