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 attrs = [], noValue = X.Dom.Attr.noValue, p;
\r
178 attrs[ attrs.length ] = 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 = this._attrs,
\r
210 if( this._nodeType !== 1 ) return this;
\r
212 if( nameOrObj && X.Type.isObject( nameOrObj ) ){
\r
213 if( !attrs ) attrs = this._attrs = {};
\r
214 node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
\r
215 for( p in nameOrObj ){
\r
216 this.__attr( node, attrs, p, nameOrObj[ p ] );
\r
218 this._attrText = X.Dom.Attr.objToAttrText( this._attrs );
\r
221 if( 1 < arguments.length ){
\r
223 // this._attrText use when Node.create()
\r
224 if( !attrs ) attrs = this._attrs = {};
\r
226 this._ie4getRawNode ? ( this._rawNode || this._ie4getRawNode() ) : this._rawNode,
\r
227 attrs, nameOrObj, arguments[ 1 ]
\r
229 //if( !attrs[ name ] ){
\r
230 // !this._attrText ? ( this._attrText = '' ) : ( this._attrText += ' ' );
\r
231 // this._attrText += X.Dom.Attr.noValue[ name ] ? name : name + '="' + v + '"';
\r
232 // attrs[ name ] = v;
\r
234 // attrs[ name ] = v;
\r
235 this._attrText = X.Dom.Attr.objToAttrText( attrs );
\r
239 if( typeof nameOrObj === 'string' ){
\r
241 if( !attrs ) return;
\r
246 X.Dom.Node.prototype.__attr = function( node, attrs, name, v ){
\r
247 name = X.Dom.Attr.renameForTag[ name ] || name;
\r
249 if( attrs[ name ] === v ) return;
\r
250 if( name === 'style' ){
\r
251 return this.cssText( v );
\r
253 if( name.indexOf( 'on' ) === 0 ){
\r
254 X.Notification.warn( 'xnode.attr("' + name + '") is wrong, xnode.listen() & xnode.unlisten().' );
\r
258 if( name === 'class' ) return this.className( v );
\r
261 this._ie4getRawNode ?
\r
262 v ? node.setAttribute( name, v ) : node.removeAttribute( name ) : // val
\r
263 ( node[ X.Dom.Attr.renameForDOM[ name ] || name ] = v || undefined ); // val
\r
266 if( name === 'id' ){
\r
267 this._id = v === 'ie4uid' + this._uid ? undefined : !v ? undefined : v;
\r
270 // update this._attrs
\r
272 delete attrs[ name ];
\r