OSDN Git Service

Version 0.6.49, fix for xnode.attr(name).
[pettanr/clientJs.git] / 0.6.x / js / dom / 14_XDomAttr.js
index cecb84c..af1b6ac 100644 (file)
@@ -86,7 +86,7 @@ X.Dom.Attr = {
  * \r
  */\r
 X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){\r
-       var attrs = this._attrs, newAttrs, f, p, elm;\r
+       var attrs = this._attrs, newAttrs, f, p, elm, v;\r
        \r
        if( this._xnodeType !== 1 ) return this;\r
        \r
@@ -113,14 +113,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){
                };\r
                return this;\r
        } else\r
-       if( nameOrObj === 'value' && X.Dom.Attr.HAS_VALUE[ this._tag.toUpperCase() ] ){\r
-               if( this._newAttrs && this._newAttrs.value ) return this._newAttrs.value;\r
-               if( elm = X.Dom.DOM_IE4 ? this._rawNode || this._ie4getRawNode() : this._rawNode ){\r
-                       attrs.value = elm.value;\r
-               };\r
-               return attrs.value;\r
-       } else\r
-       if( typeof nameOrObj === 'string' && attrs ){\r
+       if( typeof nameOrObj === 'string' ){\r
                // getter\r
                switch( nameOrObj ){\r
                        case 'id' :\r
@@ -134,8 +127,18 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){
                        case 'style' :\r
                        case 'cssText' :\r
                                return this.cssText();\r
+                       case 'value' :\r
+                       case 'selectedIndex' :\r
+                               if( X.Dom.Attr.HAS_VALUE[ this._tag ] ){\r
+                                       if( this._newAttrs && X.inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ];\r
+                                       if( elm = X.Dom.DOM_IE4 ? this._rawNode || this._ie4getRawNode() : this._rawNode ){\r
+                                               attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )?\r
+                                       };\r
+                                       return attrs[ nameOrObj ];\r
+                               };\r
+                               break;\r
                };\r
-               return attrs[ X.Dom.Attr.renameForTag[ nameOrObj ] || nameOrObj ];\r
+               return attrs && attrs[ X.Dom.Attr.renameForTag[ nameOrObj ] || nameOrObj ];\r
        };\r
 };\r
 X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){\r