OSDN Git Service

Version 0.6.41, fix for Opera8 & NN7.2+.
[pettanr/clientJs.git] / 0.6.x / js / dom / 20_XDomImage.js
index 7de759a..f2209e7 100644 (file)
@@ -37,7 +37,7 @@ X.Dom.Image = {
                        };\r
                        if( ret = X.Dom.Image._actualSize[ img.src ] ) return ret;\r
                };\r
-       \r
+\r
                // for Firefox, Safari, Google Chrome\r
                if( img.naturalWidth ) return [ img.naturalWidth, img.naturalHeight ];\r
        \r
@@ -56,17 +56,22 @@ X.Dom.Image = {
                        // restore\r
                        run.height = memH;\r
                } else {// for Opera and Other\r
-       \r
-                       memW = img.width;\r
-                       memH = img.height;\r
-                       // keep current style\r
-                       img.removeAttribute( 'width' );\r
-                       img.removeAttribute( 'height' );\r
-                       w = img.width;\r
-                       h = img.height;\r
-                       img.width  = memW;\r
-                       // restore\r
-                       img.height = memH;\r
+                       \r
+                       memW = w = img.width;\r
+                       memH = h = img.height;\r
+                       \r
+                       if( img.removeAttribute ){ // Safari1.3 の Image は removeAttribute がない\r
+                               // keep current style\r
+                               img.removeAttribute( 'width' );\r
+                               img.removeAttribute( 'height' );\r
+                               \r
+                               w = img.width;\r
+                               h = img.height;\r
+                               \r
+                               // restore\r
+                               img.width  = memW;\r
+                               img.height = memH;\r
+                       };\r
                };\r
                \r
                ret = X.Dom.Image._actualSize[ img.src ] = [ w, h ];\r
@@ -103,7 +108,7 @@ X.Dom.Image = {
                                this.timeout = timeout || 10000;\r
                                this.xnode =\r
                                        (\r
-                                               window.Image ?\r
+                                               window[ 'Image' ] ?\r
                                                        X.Dom.Node( img = new Image() ) :\r
                                                        X.Dom.Node._systemNode.create( 'img', { src : abspath } )\r
                                        )\r
@@ -112,9 +117,7 @@ X.Dom.Image = {
                                        .listen( 'abort', this )\r
                                        .listen( X.Dom.Event.LOAD_ASSET_COMPLETE, this )\r
                                        .listen( X.Dom.Event.LOAD_ASSET_ERROR, this );\r
-       \r
                                img && ( img.src = abspath );\r
-\r
                                this._detect();\r
                        },\r
                        handleEvent : function( e ){\r
@@ -152,7 +155,7 @@ X.Dom.Image = {
                        },      \r
                        _detect : function(){\r
                                if( this.finish === true ) return;\r
-                               if( this.xnode._rawNode.complete ){\r
+                               if( this.xnode._rawNode && this.xnode._rawNode.complete ){\r
                                        this.finish = true;\r
                                        if( this.xnode._rawNode.width ) return;\r
                                        this.timerID = this.asyncDispatch( 0, { type : X.Dom.Event.LOAD_ASSET_ERROR } );\r
@@ -160,7 +163,7 @@ X.Dom.Image = {
                                };\r
                                if( ( this.tick += this.delay ) > this.timeout ){\r
                                        this.finish = true;\r
-                                       this.timerID = this.asyncDispatch( 0, { type : X.Dom.Event.LOAD_ASSET_ERROR } );\r
+                                       this.timerID = this.asyncDispatch( 0, { type : X.Dom.Event.LOAD_ASSET_ERROR, msg : 'timeout' } );\r
                                        return;\r
                                };\r
                                this.timerID = X.Timer.once( this.delay, this, this._detect );\r