20 'accept-charset' : 12,
\r
32 cellpadding : 22, //
\r
34 cellspacing : 23, //
\r
68 frameborder : 49, //
\r
75 'http-equiv' : 55, //
\r
148 'class' : 'className',
\r
149 accesskey : 'accessKey',
\r
150 'accept-charset' : 'acceptCharset',
\r
151 bgcolor : 'bgColor',
\r
152 cellpadding : 'cellPadding',
\r
153 cellspacing : 'cellSpacing',
\r
156 codebase : 'codeBase',
\r
157 codetype : 'codeType',
\r
158 colspan : 'colSpan',
\r
159 datetime : 'dateTime',
\r
161 frameborder : 'frameBorder',
\r
162 'http-equiv' : 'httpEquiv',
\r
164 longdesc : 'longDesc',
\r
165 maxlength : 'maxLength',
\r
167 readonly : 'readOnly',
\r
168 rowspan : 'rowSpan',
\r
169 tabindex : 'tabIndex',
\r
171 valuetype : 'valueType',
\r
172 checked : 'defaultChecked'
\r
175 objToAttrText : function( obj ){
\r
176 var noValue = X.Dom.Attr.noValue, attrs = [], n = -1, p;
\r
178 attrs[ ++n ] = noValue[ p ] ? p : [ p, '="', obj[ p ], '"' ].join( '' );
\r
180 return attrs.join( ' ' );
\r
184 (function( toIndex, toName, renameForDOM, renameForTag ){
\r
186 for( name in toIndex ){
\r
187 if( typeof ( i = toIndex[ name ] ) === 'number' ){
\r
188 toName[ i ] = name;
\r
191 for( name in renameForDOM ){
\r
192 renameForTag[ renameForDOM[ name ] ] = name;
\r
194 })( X.Dom.Attr.toIndex, X.Dom.Attr.toName, X.Dom.Attr.renameForDOM, X.Dom.Attr.renameForTag );
\r
198 /* --------------------------------------
\r
200 * X.Dom.Attr.toIndex に定義されている 属性の場合
\r
202 * http://nanto.asablo.jp/blog/2005/10/29/123294
\r
203 * className, onclick等 はここで設定しない
\r
206 X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){
\r
207 var attrs, newAttrs, v, name;
\r
209 if( this._xnodeType !== 1 ) return this;
\r
211 if( nameOrObj && X.Type.isObject( nameOrObj ) ){
\r
212 if( !( attrs = this._attrs ) ) attrs = this._attrs = {};
\r
213 if( !( newAttrs = this._newAttrs ) ) newAttrs = this._newAttrs = {};
\r
215 for( p in nameOrObj ){
\r
216 this.__attr( attrs, newAttrs, p, nameOrObj[ p ] );
\r
218 delete this._attrText; // = X.Dom.Attr.objToAttrText( attrs );
\r
219 this._dirty |= X.Dom.Dirty.ATTR;
\r
220 this.parent && this._reserveUpdate();
\r
223 if( 1 < arguments.length ){
\r
225 if( !( attrs = this._attrs ) ) attrs = this._attrs = {};
\r
226 if( !( newAttrs = this._newAttrs ) ) newAttrs = this._newAttrs = {};
\r
228 this.__attr( attrs, newAttrs, nameOrObj, arguments[ 1 ] );
\r
229 delete this._attrText; // = X.Dom.Attr.objToAttrText( attrs );
\r
230 this._dirty |= X.Dom.Dirty.ATTR;
\r
231 this.parent && this._reserveUpdate();
\r
234 if( typeof nameOrObj === 'string' ){
\r
236 if( !attrs ) return;
\r
241 X.Dom.Node.prototype.__attr = function( attrs, newAttrs, name, v ){
\r
242 if( name === 'UID' ) return;
\r
243 if( name === 'id' ){
\r
244 this._id = v !== 'ie4uid' + this._uid ? v : undefined;
\r
247 if( name === 'class' ) return this.className( v );
\r
248 if( name === 'style' ) return this.cssText( v );
\r
250 if( name.indexOf( 'on' ) === 0 ){
\r
251 X.Notification.warn( 'xnode.attr("' + name + '") is wrong, xnode.listen() & xnode.unlisten().' );
\r
255 name = X.Dom.Attr.renameForTag[ name ] || name;
\r
256 if( attrs[ name ] === v ) return;
\r
259 newAttrs[ name ] = undefined;
\r
260 if( attrs.hasOwnProperty( name ) ) delete attrs[ name ];
\r
262 newAttrs[ name ] = attrs[ name ] = v;
\r