18 'class' : 'className',
\r
19 accesskey : 'accessKey',
\r
20 'accept-charset' : 'acceptCharset',
\r
21 bgcolor : 'bgColor',
\r
22 cellpadding : 'cellPadding',
\r
23 cellspacing : 'cellSpacing',
\r
26 codebase : 'codeBase',
\r
27 codetype : 'codeType',
\r
28 colspan : 'colSpan',
\r
29 datetime : 'dateTime',
\r
31 frameborder : 'frameBorder',
\r
32 'http-equiv' : 'httpEquiv',
\r
34 longdesc : 'longDesc',
\r
35 maxlength : 'maxLength',
\r
37 readonly : 'readOnly',
\r
38 rowspan : 'rowSpan',
\r
39 tabindex : 'tabIndex',
\r
41 valuetype : 'valueType',
\r
42 checked : 'defaultChecked'
\r
52 // http://nanto.asablo.jp/blog/2005/10/29/123294
\r
53 // checked -> defaultChecked
\r
54 // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される
\r
56 objToAttrText : function( obj ){
\r
57 var noValue = X.Dom.Attr.noValue,
\r
58 attrs = [ '' ], n = 0, p, v;
\r
61 if( p === 'value' ){
\r
62 v = v.split( '"' ).join( '"' ).split( '>' ).join( '>' ).split( '<' ).join( '<' );
\r
64 attrs[ ++n ] = noValue[ p ] ? p : [ p, '="', v, '"' ].join( '' );
\r
66 return 0 < n ? attrs.join( ' ' ) : ' ';
\r
70 (function( renameForDOM, renameForTag ){
\r
72 for( name in renameForDOM ){
\r
73 renameForTag[ renameForDOM[ name ] ] = name;
\r
75 })( X.Dom.Attr.renameForDOM, X.Dom.Attr.renameForTag );
\r
79 /* --------------------------------------
\r
81 * X.Dom.Attr.toIndex に定義されている 属性の場合
\r
83 * http://nanto.asablo.jp/blog/2005/10/29/123294
\r
84 * className, onclick等 はここで設定しない
\r
87 X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){
\r
88 var attrs = this._attrs, newAttrs, f, p, elm;
\r
90 if( this._xnodeType !== 1 ) return this;
\r
92 if( nameOrObj && X.Type.isObject( nameOrObj ) ){
\r
93 attrs || ( attrs = this._attrs = {} );
\r
94 newAttrs = this._newAttrs || ( this._newAttrs = {} );
\r
96 for( p in nameOrObj ){
\r
97 if( this._setAttr( attrs, newAttrs, p, nameOrObj[ p ] ) === true ) f = true;
\r
100 this._attrText = false;
\r
101 this._dirty |= X.Dom.Dirty.ATTR;
\r
102 this._root && this._reserveUpdate();
\r
106 if( 1 < arguments.length ){
\r
108 if( this._setAttr( attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){
\r
109 this._attrText = false;
\r
110 this._dirty |= X.Dom.Dirty.ATTR;
\r
111 this._root && this._reserveUpdate();
\r
115 if( nameOrObj === 'value' && X.Dom.Attr.HAS_VALUE[ this._tag.toUpperCase() ] ){
\r
116 if( this._newAttrs && this._newAttrs.value ) return this._newAttrs.value;
\r
117 if( elm = X.Dom.DOM_IE4 ? this._rawNode || this._ie4getRawNode() : this._rawNode ){
\r
118 attrs.value = elm.value;
\r
120 return attrs.value;
\r
122 if( typeof nameOrObj === 'string' && attrs ){
\r
124 return attrs[ nameOrObj ];
\r
127 X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){
\r
128 if( name === 'UID' ) return;
\r
129 if( name === 'id' ){
\r
130 v = ( v !== 'ie4uid' + this._uid ) ? v : undefined;
\r
131 if( v !== this._id ){
\r
133 this._dirty |= X.Dom.Dirty.ID;
\r
134 this._root && this._reserveUpdate();
\r
138 if( name === 'class' ) return this.className( v );
\r
139 if( name === 'style' ) return this.cssText( v );
\r
141 if( name.indexOf( 'on' ) === 0 ){
\r
142 X.Notification.warn( 'xnode.attr("' + name + '") is wrong, xnode.listen() & xnode.unlisten().' );
\r
146 name = X.Dom.Attr.renameForTag[ name ] || name;
\r
147 if( attrs[ name ] === v ) return;
\r
150 newAttrs[ name ] = undefined;
\r
151 if( attrs.hasOwnProperty( name ) ) delete attrs[ name ];
\r
153 newAttrs[ name ] = attrs[ name ] = v;
\r