OSDN Git Service

Version 0.6.51, add logger.html, fix for NF3.4.
[pettanr/clientJs.git] / 0.6.x / js / dom / 14_XDomAttr.js
index a0009ff..77d8600 100644 (file)
@@ -45,7 +45,8 @@ X.Dom.Attr = {
        HAS_VALUE : {\r
                INPUT    : true,\r
                TEXTAREA : true,\r
-               SELECT   : true\r
+               SELECT   : true,\r
+               BUTTON   : true\r
        },\r
        \r
        renameForTag : {},\r
@@ -86,7 +87,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,16 +114,35 @@ 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
-               return attrs[ nameOrObj ];\r
+               switch( nameOrObj ){\r
+                       case 'id' :\r
+                               return this._tag;\r
+                       case 'class' :\r
+                       case 'className' :\r
+                               return this._className;\r
+                       case 'tag' :\r
+                       case 'tagName' :\r
+                               return this._tag;\r
+                       case 'style' :\r
+                       case 'cssText' :\r
+                               return this.cssText();\r
+                       case 'value' :\r
+                       case 'checked' :\r
+                       case 'selected' :\r
+                       case 'disabled' :                       \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 && attrs[ X.Dom.Attr.renameForTag[ nameOrObj ] || nameOrObj ];\r
        };\r
 };\r
 X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){\r