2 * Node( rawElement | rawTextnode | htmlString | textString )
5 * @class Node HTMLElement、TextNode をラップし jQuery 風な API で操作できます。
7 * @extends {EventDispatcher}
9 var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ](
17 * @alias Node.prototype._uid
25 * @alias Node.prototype._flags
27 '_flags' : X_NodeFlags_DESTROYED,
29 '_rect' : null, // TODO
32 * 最後に計測したフォントサイズを保持している。ツリーが変更されると削除される。
35 * @alias Node.prototype._fontSize
40 * NodeList と動作を一致させるためのプロパティ。常に 1。
43 * @alias Node.prototype.length
50 * @alias Node.prototype.parent
52 parent : null, // remove された枝も親子構造は維持している。
58 * @alias Node.prototype._xnodes
63 * GPU レイヤーに転送されている場合、その一番親となっている Node。未実装。
66 * @alias Node.prototype._gpuParent
71 * タグ名。テキストノードの場合は空文字列。
74 * @alias Node.prototype._tag
79 * テキストコンテンツ。テキストノードで使用。
82 * @alias Node.prototype._text
90 * @alias Node.prototype._id
95 * クラス名。複数のクラスが設定されている場合、スペース区切り。
98 * @alias Node.prototype._className
100 '_className' : '', //
106 * @alias Node.prototype._attrs
108 '_attrs' : null, // see X_Node_Attr
114 * @alias Node.prototype._newAttrs
119 * 属性を文字列にしたもの。 color="red" size="8"
122 * @alias Node.prototype._attrText
130 * @alias Node.prototype._css
138 * @alias Node.prototype._cssText
146 * @alias Node.prototype._anime
151 * TODO Node の継承ができない!
153 'Constructor' : function( v ){
154 // TODO uid = X_Node_CHASHE.indexOf( null ), uid === -1 ? X_Node_CHASHE.length : uid;
155 var uid = X_Node_CHASHE.length,
156 css, xnodes, xnode, parent;
158 if( X_Node_newByTag ){
159 X_Node_newByTag = false;
160 this[ '_tag' ] = v.toUpperCase();
161 arguments[ 1 ] && this[ 'attr' ]( arguments[ 1 ] );
162 css = arguments[ 2 ];
163 css && this[ X_Type_isString( css ) ? 'cssText' : 'css' ]( css );
165 if( X_Node_newByText ){
166 X_Node_newByText = false;
169 if( 1 < arguments.length ) return new X_NodeList( arguments );
170 if( X_Type_isArray( v ) && v.length ) return new X_NodeList( v );
172 switch( X_Node_getType( v ) ){
173 case X_NodeType_XNODE :
174 case X_NodeType_XNODE_LIST :
177 case X_NodeType_RAW_HTML :
178 if( xnode = X_Node_getXNode( v ) ) return xnode;
179 // v.parentNode || v.parentElement : dom1 || dom0
180 this.parent = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && X_Node_getXNode( parent );
181 this[ '_rawObject' ] = v;
182 this[ '_tag' ] = v.tagName.toUpperCase();
183 this[ '_id' ] = v.id;
184 this[ '_className' ] = v.className;
186 this[ 'cssText' ]( v.style.cssText );
187 this[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY; // X_NodeFlags_DIRTY_CSS を落とす
189 // TODO attr の回収は不可能、、、?
191 v.setAttribute( 'UID', '' + uid );
198 case X_NodeType_RAW_TEXT :
199 if( xnode = X_Node_getXNode( v ) ) return xnode;
200 this.parent = X_Node_getXNode( v.parentNode );
201 this[ '_rawObject' ] = v;
202 this[ '_text' ] = v.data;
206 case X_NodeType_HTML_STRING :
207 case X_NodeType_STRING :
208 if( xnodes = X_HtmlParser_parse( v, true ) && 1 < xnodes.length ) return new X_NodeList( xnodes );
209 if( xnodes.length ) return xnodes[ 0 ];
213 if( X_Node_none ) return X_Node_none;
219 if( this.parent && ( this.parent[ '_flags' ] & X_NodeFlags_IN_TREE ) ){
220 this[ '_flags' ] |= X_NodeFlags_IN_TREE;
222 this[ '_flags' ] |= X_NodeFlags_EXIST;
223 X_Node_CHASHE[ this[ '_uid' ] = uid ] = this;
226 'width' : X_Node_width,
227 'height' : X_Node_height,
228 'clientWidth' : X_Node_clientWidth,
229 'clientHeight' : X_Node_clientHeight,
230 'scrollWidth' : X_Node_scrollWidth,
231 'scrollHeight' : X_Node_scrollHeight,
232 'scrollLeft' : X_Node_scrollLeft,
233 'scrollTop' : X_Node_scrollTop,
236 'offset' : X_Node_offset,
238 'attr' : X_Node_attr,
240 'cssText' : X_Node_cssText,
242 'find' : X_Node_find,
244 'animate' : X_Node_animate,
245 'stop' : X_Node_stop,
248 'create' : X_Node_create,
250 'createAt' : X_Node_createAt,
252 'createText' : X_Node_createText,
254 'createTextAt' : X_Node_createTextAt,
256 'clone' : X_Node_clone,
258 'append' : X_Node_append,
260 'appendAt' : X_Node_appendAt,
262 'appendTo' : X_Node_appendTo,
264 'prev' : X_Node_prev,
266 'next' : X_Node_next,
268 'swap' : X_Node_swap,
270 'remove' : X_Node_remove,
272 'empty' : X_Node_empty,
274 'contains' : X_Node_contains,
276 'getChildAt' : X_Node_getChildAt,
278 'numChildren' : X_Node_numChildren,
280 'firstChild' : X_Node_firstChild,
282 'lastChild' : X_Node_lastChild,
284 'getOrder' : X_Node_getOrder,
286 'className' : X_Node_className,
287 'addClass' : X_Node_addClass,
288 'removeClass' : X_Node_removeClass,
289 'toggleClass' : X_Node_toggleClass,
290 'hasClass' : X_Node_hasClass,
292 'html' : X_Node_html,
293 'text' : X_Node_text,
294 'call' : X_Node_call,
300 var X_NodeType_XNODE = 1,
301 X_NodeType_RAW_HTML = 2,
302 X_NodeType_RAW_TEXT = 3,
303 X_NodeType_HTML_STRING = 4,
304 X_NodeType_STRING = 5,
306 X_NodeType_XNODE_LIST = 7,
307 X_NodeType_WINDOW = 8,
308 X_NodeType_DOCUMENT = 9,
309 X_NodeType_IMAGE = 10,
311 X_Node_strictElmCreation = !X_UA[ 'MacIE' ] && X_UA[ 'IE' ] <= 8,
313 X_Node_documentFragment = document.createDocumentFragment && ( !X_UA[ 'IE' ] || 5.5 <= X_UA[ 'IE' ] ) && document.createDocumentFragment(),
315 // 子の生成後に リアル文書 tree に追加する
316 X_Node_addTreeAfterChildren = !( X_UA[ 'IE' ] < 9 ),
318 X_Node_displayNoneFixForIE5 = !!X_NodeFlags_IE5_DISPLAY_NONE_FIX,
320 X_Node_newByTag = false,
322 X_Node_newByText = false,
324 X_Node_outerXNode = null,
326 X_Node_updateTimerID = 0,
329 X_Node_isXmlDocument =
333 if( X_Type_isBoolean( root.isXML ) ) return root.isXML;
334 return root.isXML = root[ '_rawObject' ].createElement( 'p' ).tagName !== root[ '_rawObject' ].createElement( 'P' ).tagName;
337 X_Node_none = X_Node_CHASHE[ 0 ] = Node(),
338 X_Node_html, // = <html>
339 X_Node_head, // = <head>
340 X_Node_body, // = <body>
341 X_Node_systemNode, // = X_Node_CHASHE[ ? ]
345 * X_Node_reserveRemoval = [] に追加。commitUpdate で remove
347 * X_Node_reserveRemoval にいたら消す, new_parent[ '_xnodes' ] に挿入
349 X_Node_reserveRemoval = [];
351 function X_Node_getType( v ){
352 if( v === '' ) return X_NodeType_STRING;
354 if( v === window ) return X_NodeType_WINDOW;
355 if( v === document ) return X_NodeType_DOCUMENT;
356 if( v.constructor === Node ) return X_NodeType_XNODE;
357 if( v.constructor === X_NodeList ) return X_NodeType_XNODE_LIST;
358 if( X_Type_isHTMLElement( v ) ) return X_NodeType_RAW_HTML;
359 if( v.nodeType === 3 ) return X_NodeType_RAW_TEXT;
360 if( X_Type_isString( v ) ){
361 return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? X_NodeType_HTML_STRING : X_NodeType_STRING;
363 if( v[ 'instanceOf' ] && v[ 'instanceOf' ]( Node ) ) return X_NodeType_XNODE;
366 function X_Node_getXNode( v ){
367 var uid, i, chashe, xnode;
368 switch( X_Node_getType( v ) ){
369 case X_NodeType_XNODE :
370 case X_NodeType_XNODE_LIST :
372 case X_NodeType_RAW_HTML :
373 // fake TextNode too.
375 uid = v.getAttribute( 'UID' );
376 return uid && X_Node_CHASHE[ uid ];
378 return v[ 'UID' ] && X_Node_CHASHE[ v[ 'UID' ] ];
379 case X_NodeType_WINDOW :
381 case X_NodeType_DOCUMENT :
382 return X_ViewPort_document;
383 case X_NodeType_RAW_TEXT :
384 if( v[ 'UID' ] ) return X_Node_CHASHE[ v[ 'UID' ] ];
385 for( chashe = X_Node_CHASHE, i = chashe.length; i; ){
386 if( ( xnode = chashe[ --i ] ) && ( xnode[ '_rawObject' ] === v ) ) return xnode;
391 function X_Node_getRoot( xnode ){
392 return X_ViewPort_document;
393 //return X_Node_body[ '_rawObject' ].documentElement ? node : node.ownerDocument || node.document;
397 // TODO document.all[ uid ] -> document[ uid ]
398 var X_Node__ie4getRawNode = X_UA_DOM.IE4 && function ( that ){
399 return that[ '_rawObject' ] ||
400 ( that[ '_rawObject' ] = document.all[ 'ie4uid' + that[ '_uid' ] ] || that[ '_id' ] && document.all[ that[ '_id' ] ] );
404 function X_Node_toggleInTreeFlag( xnodes, flag ){
405 var i = xnodes.length, xnode;
407 xnode = xnodes[ --i ];
408 flag ? ( xnode[ '_flags' ] |= X_NodeFlags_IN_TREE | X_NodeFlags_DIRTY_POSITION ) : ( xnode[ '_flags' ] &= ~X_NodeFlags_IN_TREE & ~X_NodeFlags_IE5_DISPLAY_NONE_FIX );
409 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( xnode[ '_xnodes' ], flag );
413 function X_Node_toggleInGPUFlag( gpuRoot, xnodes, flag ){
414 var i = xnodes.length, xnode;
418 xnode = xnodes[ --i ];
419 if( !xnode[ '_gpuParent' ] ){
420 xnode[ '_flags' ] |= X_NodeFlags_GPU_CHILD;
421 xnode[ '_gpuParent' ] = gpuRoot;
422 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
427 xnode = xnodes[ --i ];
428 if( xnode[ '_gpuParent' ] === gpuRoot ){
429 xnode[ '_flags' ] &= ~X_NodeFlags_GPU_CHILD;
430 delete xnode[ '_gpuParent' ];
431 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
438 * タグ名等を指定して新規に子ノードを作成し、現在のノードに追加する。
439 * @alias Node.prototype.create
440 * @param {string} [tag] タグ名
441 * @param {object} [opt_attrs=] 属性
442 * @param {object|string} [opt_css=] css
443 * @return {Node} 新規作成されたノード
444 * @example var child = parent.create( 'div' );
446 function X_Node_create( tag, opt_attrs, opt_css ){
449 if( !this[ '_tag' ] ) return;
450 this[ 'append' ]( xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
454 * 挿入位置とタグ名等を指定して新規に子ノードを作成し、現在のノードに挿入する。
455 * @alias Node.prototype.createAt
456 * @param {number} [index] 挿入位置
457 * @param {string} [tag] タグ名
458 * @param {object} [opt_attrs=] 属性
459 * @param {object|string} [opt_css=] css
460 * @return {Node} 新規作成されたノード
461 * @example var child = parent.create( 2, 'div' );
463 function X_Node_createAt( index, tag, opt_attrs, opt_css ){
465 if( !this[ '_tag' ] ) return;
466 this[ 'appendAt' ]( index, xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
471 * テキストを指定して新規にテキストノードを作成し、現在のノードに挿入する。
472 * @alias Node.prototype.createText
473 * @param {string} [tag] テキスト
474 * @return {Node} 新規作成されたノード
476 function X_Node_createText( text ){
478 if( !this[ '_tag' ] ) return;
479 this[ 'append' ]( xnode = X_Doc_createText( text ) );
483 * 挿入位置とテキストを指定して新規に子ノードを作成し、現在のノードに挿入する。
484 * @alias Node.prototype.createTextAt
485 * @param {number} [index] 挿入位置
486 * @param {string} [tag] テキスト
487 * @return {Node} 新規作成されたノード
489 function X_Node_createTextAt( index, text ){
491 if( !this[ '_tag' ] ) return;
492 this[ 'appendAt' ]( index, xnode = X_Doc_createText( text ) );
497 * Node のクローンを作成し返す。id もクローンされる点に注意。イベントリスナはクローンされない。
498 * http://d.hatena.ne.jp/think49/20110724/1311472811
499 * http://d.hatena.ne.jp/uupaa/20100508/1273299874
500 * @alias Node.prototype.clone
501 * @param {boolean} [opt_clone_children] 子要素のクローンを行うか?
504 function X_Node_clone( opt_clone_children ){
505 var xnode, xnodes, i, l;
507 if( this[ '_tag' ] ){
508 X_Node_newByTag = true;
509 xnode = Node( this[ '_tag' ], X_Object_copy( this[ '_attrs' ] ), X_Object_copy( this[ '_css' ] ) )
510 [ 'attr' ]( { 'id' : this[ '_id' ] } )
511 [ 'className' ]( this[ '_className' ] );
513 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
514 xnode[ '_flags' ] |= X_NodeFlags_IS_SVG;
516 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
517 xnode[ '_flags' ] |= X_NodeFlags_IS_VML;
520 if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
521 for( i = 0; i < l; ++i ){
522 xnode[ 'append' ]( xnodes[ i ][ 'clone' ]( true ) );
527 X_Node_newByText = true;
528 return Node( this[ '_text' ] );
532 * ノードを子配列の最後に追加する。文字列が渡された場合、HTMLパーサーによって Node ツリーを作成して追加する。HtmlElement, TextNode の場合は内部使用専用。
533 * @alias Node.prototype.append
534 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
535 * @return {Node} 自身。チェインメソッド
537 * myNode.append( node );
538 * myNode.append( node, '<span>Hello,</span>', 'world.' );
540 function X_Node_append( v ){
541 var i, l, xnodes, frg;
542 if( !this[ '_tag' ] ) return;
544 if( 1 < ( l = arguments.length ) ){
545 for( i = 0; i < l; ++i ){
546 this[ 'append' ]( arguments[ i ] );
551 if( !( xnodes = this[ '_xnodes' ] ) ) this[ '_xnodes' ] = xnodes = [];
553 switch( X_Node_getType( v ) ){
554 case X_NodeType_RAW_HTML :
555 case X_NodeType_RAW_TEXT :
558 case X_NodeType_HTML_STRING :
559 case X_NodeType_STRING :
560 return X_Node_append.apply( this, X_HtmlParser_parse( v, true ) );
561 case X_NodeType_XNODE :
562 // 親の xnodes から v を消す
563 if( v.parent === this && xnodes[ xnodes.length - 1 ] === v ) return this;
565 // IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
566 if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
573 xnodes[ xnodes.length ] = v;
574 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
575 v[ '_flags' ] |= X_NodeFlags_IN_TREE;
576 v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
577 X_Node_reserveUpdate();
579 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
580 v[ '_flags' ] |= X_NodeFlags_IS_SVG;
582 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
583 v[ '_flags' ] |= X_NodeFlags_IS_VML;
590 * @alias Node.prototype.appendAt
591 * @param {number} index 挿入位置 0以上
592 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
593 * @return {Node} 自身。チェインメソッド
594 * @example myNode.appendAt( 1, node );
596 function X_Node_appendAt( start, v ){
599 if( !this[ '_tag' ] ) return this;
601 l = arguments.length;
602 if( !( xnodes = this[ '_xnodes' ] ) ) xnodes = this[ '_xnodes' ] = [];
604 if( xnodes.length <= start ){
605 if( l === 2 ) return this[ 'append' ]( v );
606 for( i = 1; i < l; ++i ){
607 this[ 'append' ]( arguments[ i ] );
611 if( start < 0 ) start = 0;
614 this[ 'appendAt' ]( start, arguments[ --l ] );
619 switch( X_Node_getType( v ) ){
620 case X_NodeType_RAW_HTML :
621 case X_NodeType_RAW_TEXT :
624 case X_NodeType_HTML_STRING :
625 case X_NodeType_STRING :
626 v = X_HtmlParser_parse( v, true );
627 for( i = v.length; i; ){
628 this[ 'appendAt' ]( start, v[ --i ] );
631 case X_NodeType_XNODE :
632 // 親の xnodes から v を消す
634 if( v.parent === this ){
635 i = v[ 'getOrder' ]();
636 if( i === start ) return this;
637 if( i < start ) --start;
641 // IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
642 if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
649 this[ '_xnodes' ].splice( start, 0, v );
650 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
651 v[ '_flags' ] |= X_NodeFlags_IN_TREE;
652 v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
653 X_Node_reserveUpdate();
655 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
656 v[ '_flags' ] |= X_NodeFlags_IS_SVG;
658 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
659 v[ '_flags' ] |= X_NodeFlags_IS_VML;
665 * ノードを親に追加する。戻り値は子ノードなので、続けて操作が出来る。
666 * @alias Node.prototype.appendTo
667 * @param {Node|string|HTMLElement} [parent] HTMLElement は内部のみ。
668 * @param {number} [opt_index=-1] 挿入位置。省略した場合は最後に追加する。
669 * @return {Node} 自身。チェインメソッド
670 * @example childNode.appendTo( parentNode, 1 );
672 function X_Node_appendTo( parent, opt_index ){
673 switch( X_Node_getType( parent ) ){
674 case X_NodeType_RAW_HTML :
675 parent = Node( parent );
677 case X_NodeType_HTML_STRING :
678 parent = X_HtmlParser_parse( parent, true );
679 parent = parent[ 0 ] || parent;
680 case X_NodeType_XNODE :
685 X_Type_isFinite( opt_index ) ? parent[ 'appendAt' ]( opt_index, this ) : parent[ 'append' ]( this );
691 * ノードの直前の要素を取得。または直前に挿入。挿入する要素が先にいる兄弟でも正しく動作する。
692 * @alias Node.prototype.prev
693 * @param {Node|string|HTMLElement|TextNode} [...v] HTMLElement と TextNode は内部のみ。
694 * @return {Node} 自身。チェインメソッド
695 * @example childNode.prev( prevNode );
697 function X_Node_prev( v ){
698 var parent = this.parent, xnodes, i, l;
701 if( v === undefined ){
702 if( !parent ) return;
703 xnodes = parent[ '_xnodes' ];
704 i = xnodes.indexOf( this );
705 return 0 < i ? xnodes[ i - 1 ] : v;
708 if( !parent ) return this;
710 l = arguments.length;
712 for( i = 0; l; ++i ){
713 parent[ 'appendAt' ]( this[ 'getOrder' ]() - i, arguments[ --l ] );
717 parent[ 'appendAt' ]( this[ 'getOrder' ](), v );
722 * ノードの直後の要素を取得。または直後に挿入。挿入する要素が先にいる兄弟でも正しく動作する。
723 * @alias Node.prototype.next
724 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
725 * @return {Node} 自身。チェインメソッド
726 * @example childNode.next( prevNode );
728 function X_Node_next( v ){
729 var parent = this.parent, xnodes, i, l, start;
732 if( v === undefined ){
733 if( !parent ) return;
734 xnodes = parent[ '_xnodes' ];
735 i = xnodes.indexOf( this );
736 return ++i < xnodes.length ? xnodes[ i ] : v;
739 if( !parent ) return this;
741 l = arguments.length;
742 start = this[ 'getOrder' ]() + 1;
744 if( parent[ '_xnodes' ].length <= start ){
745 for( i = 0; i < l; ++i ){
746 parent[ 'append' ]( arguments[ i ] );
751 parent[ 'appendAt' ]( this[ 'getOrder' ]() + 1, arguments[ --l ] );
754 parent[ 'appendAt' ]( start, v );
760 * 要素の入れ替え。自身は remove() される。
761 * @alias Node.prototype.swap
762 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
763 * @return {Node} 自身。チェインメソッド
764 * @example node.swap( newNode );
766 function X_Node_swap( v ){
767 if( !this.parent ) return this;
768 return arguments.length === 1 ? this[ 'prev' ]( v )[ 'remove' ]() : X_Node_prev.apply( this, arguments )[ 'remove' ]();
772 * 要素を親要素から抜く。jQuery の remove と異なり、インスタンスは破壊(kill)されず、再び別の親に挿入等できる
773 * @alias Node.prototype.remove
774 * @return {Node} 自身。チェインメソッド
775 * @example node.remove();
776 * parent.append( node ); 新しい親に追加できる
778 function X_Node_remove(){
779 var parent = this.parent,
782 if( !parent ) return this;
785 if( this[ '_anime' ] && this[ '_anime' ].phase ){
786 console.log( 'Animation 中の REMOVE' );
787 X_NodeAnime_stopNow( this );
793 parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( this ), 1 );
795 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
796 this[ '_flags' ] &= ~X_NodeFlags_IN_TREE & ~X_NodeFlags_IE5_DISPLAY_NONE_FIX;
797 this[ '_xnodes' ] && X_Node_toggleInTreeFlag( this[ '_xnodes' ], false );
800 if( elm = this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ){
801 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
802 X_Node_reserveUpdate();
804 if( !this[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
805 parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
808 elm = this[ '_rawObject' ];
809 if( elm && elm.parentNode && elm.parentNode.tagName ){
810 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
811 X_Node_reserveUpdate();
816 elm = this[ '_rawObject' ];
817 if( elm && elm.parentNode && elm.parentNode.tagName ){
818 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
819 X_Node_reserveUpdate();
827 * 子要素を破棄する。子要素は kill() されます。
828 * @alias Node.prototype.empty
829 * @return {Node} 自身。チェインメソッド
830 * @example node.empty();
832 function X_Node_empty(){
833 var xnodes = this[ '_xnodes' ], i;
835 if( xnodes && ( i = xnodes.length ) ){
836 delete this[ '_xnodes' ];
838 xnodes[ --i ][ 'kill' ]();
845 function X_Node_onKill( that ){
846 var parent = that.parent,
847 xnodes = that[ '_xnodes' ], i, elm;
849 if( ( that[ '_flags' ] & X_NodeFlags_EXIST ) === 0 ) return;
851 parent && parent[ '_xnodes' ] && parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( that ), 1 );
853 if( xnodes && ( i = xnodes.length ) ){
854 delete that[ '_xnodes' ];
856 xnodes[ --i ][ 'kill' ]();
861 X_Node_CHASHE[ that[ '_uid' ] ] = null; // array に対して delete X_Node_CHASHE[ uid ] はまずい!
863 if( that[ '_anime' ] && that[ '_anime' ].phase ){
864 console.log( 'Animation 中の KILL' );
865 X_NodeAnime_stopNow( that );
868 elm = that[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( that );
873 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
874 X_Node_reserveUpdate();
876 if( !that[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
877 parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
880 if( elm && elm.parentNode && elm.parentNode.tagName ){
881 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
882 X_Node_reserveUpdate();
892 * @alias Node.prototype.contains
893 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
895 * @example node.contains( testNode );
897 function X_Node_contains( v ){
900 if( !v || !this[ '_tag' ] || this === v ) return false;
902 xnodes = this[ '_xnodes' ];
903 if( !xnodes || !xnodes.length ) return false;
905 while( v = v[ 'parent' ] ){
906 if( this === v ) return true;
913 * @alias Node.prototype.getChildAt
914 * @param {number} index 取得する子ノードの位置。0~
916 * @example child1 = parent.getChildAt(1);
918 function X_Node_getChildAt( i ){
919 var xnodes = this[ '_xnodes' ];
920 return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ];
925 * @alias Node.prototype.numChildren
926 * @return {number} 子要素の数。
927 * @example n = parent.numChildren();
929 function X_Node_numChildren(){
930 var xnodes = this[ '_xnodes' ];
931 return xnodes ? xnodes.length : 0;
936 * @alias Node.prototype.firstChild
937 * @return {Node} 最初の子要素
938 * @example child0 = parent.firstChild();
940 function X_Node_firstChild(){
941 return this[ '_xnodes' ] && this[ '_xnodes' ][ 0 ];
946 * @alias Node.prototype.lastChild
947 * @return {Node} 最後の子要素
948 * @example lastChild = parent.lastChild();
950 function X_Node_lastChild(){
951 var xnodes = this[ '_xnodes' ];
952 return xnodes && xnodes[ xnodes.length - 1 ];
957 * @alias Node.prototype.getOrder
958 * @return {number} index -1 の場合、親を持たない。
959 * @example index = node.getOrder();
961 function X_Node_getOrder(){
962 var parent = this.parent;
963 return this === X_Node_html ?
966 parent[ '_xnodes' ].indexOf( this ) :
972 * @alias Node.prototype.className
973 * @return {string|Node} getter の場合 class 文字列、setter の場合自身。
975 * className = node.className();
977 * node.className( 'myClass myClass_new' );
979 function X_Node_className( v ){
982 if( v === undefined ) return this[ '_className' ];
985 if( this[ '_className' ] === v ) return this;
986 if( !v || !X_Type_isString( v ) ){
987 delete this[ '_className' ];
992 while( v.indexOf( __ ) !== -1 ){ v = v.split( __ ).join( _ ); };
993 v.charAt( 0 ) === _ && ( v = v.substr( 1 ) );
994 v.lastIndexOf( _ ) === 0 && ( v = v.substr( 0, v.length - 1 ) );
996 if( this[ '_className' ] === v ) return this;
997 v ? ( this[ '_className' ] = v ) : delete this[ '_className' ];
999 this[ '_flags' ] |= X_NodeFlags_DIRTY_CLASSNAME;
1000 this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
1006 * @alias Node.prototype.addClass
1007 * @param {string} className スペース区切りで複数のクラスを追加できる。
1008 * @return {Node} 自身。
1009 * @example node.addClass( 'myClass myClass_new' );
1011 function X_Node_addClass( v ){
1012 var names = v.split( ' ' ),
1014 _class = this[ '_className' ],
1018 name = names[ --i ];
1019 if( !name ) continue;
1020 !this[ 'hasClass' ]( name ) && ( v += ( v ? ' ' : '' ) + name );
1022 return v ? this[ 'className' ]( ( _class ? _class + ' ' : '' ) + v ) : this;
1027 * @alias Node.prototype.removeClass
1028 * @param {string} className スペース区切りで複数のクラスを削除できる。
1029 * @return {Node} 自身。
1030 * @example node.removeClass( 'myClass myClass_new' );
1032 function X_Node_removeClass( v ){
1034 _class = this[ '_className' ],
1035 names = v.split( _ ),
1036 classNames, i, f, j;
1038 if( !_class ) return this;
1039 for( classNames = _class.split( _ ), i = classNames.length; i; ){
1040 _class = classNames[ --i ];
1041 for( j = names.length; j; ){
1042 if( _class === names[ --j ] ){
1043 classNames.splice( i, 1 );
1044 names.splice( j, 1 );
1050 return f ? this[ 'className' ]( classNames.join( _ ) ) : this;
1055 * @alias Node.prototype.toggleClass
1056 * @param {string} className スペース区切りで複数のクラスを削除できる。
1057 * @param {boolean} [opt_toggle=] true はクラスの追加。false はクラスの削除。undefined はクラスのトグル。
1058 * @return {Node} 自身。
1059 * @example node.toggleClass( 'myClass myClass_new', !!n );
1061 function X_Node_toggleClass( v, opt_toggle ){
1063 if( opt_toggle !== undefined ){
1064 return !opt_toggle ? this[ 'removeClass' ]( v ) : this[ 'addClass' ]( v );
1066 names = v.split( ' ' );
1067 for( i = names.length; i; ){
1068 name = names[ --i ];
1069 this[ 'hasClass' ]( name ) ? this[ 'removeClass' ]( name ) : this[ 'addClass' ]( name );
1076 * @alias Node.prototype.hasClass
1077 * @param {string} className スペース区切りで複数のクラスを削除できる。
1079 * @example node.hasClass( 'myClass myClass_new' );
1081 function X_Node_hasClass( v ){
1083 _class = this[ '_className' ],
1085 if( _class === v ) return true;
1086 if( !_class ) return false;
1088 _class = _ + _class + _;
1089 if( _class.indexOf( _ + v + _ ) !== -1 ) return true; // lucky hit
1091 for( v = v.split( _ ), i = v.length; i; ){
1093 if( name === '' ) continue;
1094 if( _class.indexOf( _ + name + _ ) === -1 ) return false;
1100 * innerHTML 取得・設定。outerHTML が欲しい場合は、xnode.call('outerHTML') とできる。
1101 * @alias Node.prototype.html
1102 * @param {string} [html=] html文字列
1103 * @return {string|Node}
1104 * @example node.html( '<img>' );
1106 function X_Node_html( html ){
1107 var _ = '', q = '"', xnodes, n, i, l;
1109 if( html !== undefined ){ // String 以外に Number や false null なども許可
1110 if( !this[ '_tag' ] ) return this[ 'text' ]( html );
1114 X_Node_append.apply( this, X_HtmlParser_parse( html, true ) );
1120 if( !this[ '_tag' ] ){
1121 return this[ '_text' ];
1124 this[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( this );
1126 html = !X_Node_outerXNode ? [] : [
1127 '<', this[ '_tag' ],
1128 this[ '_id' ] ? ' id="' + this[ '_id' ] + q : _,
1129 this[ '_className' ] ? ' class="' + this[ '_className' ] + q : _,
1130 this[ '_flags' ] & X_NodeFlags_OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( this ) : this[ '_attrText' ],
1131 this[ '_cssText' ] ? ' style="' + this[ '_cssText' ] + q : _,
1135 if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
1136 if( !X_Node_outerXNode ) X_Node_outerXNode = this;
1137 for( i = 0; i < l; ++i ){
1138 html[ n ] = xnodes[ i ][ 'html' ]();
1141 if( X_Node_outerXNode === this ) X_Node_outerXNode = null;
1143 !X_Node_outerXNode || X_Dom_DTD_EMPTY[ this[ '_tag' ] ] || ( html[ n ] = '<\/' + this[ '_tag' ] + '>' );
1144 return html.join( _ );
1148 * null が来たら '', 数値等が来たら文字列化
1151 * textContent 取得・設定。null が来たら '', 数値等が来たら文字列化
1152 * @alias Node.prototype.text
1153 * @param {string} [text=]
1154 * @return {string|Node}
1155 * @example node.text( 'Hello, world!' );
1157 function X_Node_text( text ){
1158 var xnodes, texts, i, l;
1160 if( text !== undefined ){
1161 if( text === null ) text = '';
1164 if( !this[ '_tag' ] ){
1165 if( this[ '_text' ] !== text ){
1166 text ? ( this[ '_text' ] = text ) : delete this[ '_text' ];
1167 this[ '_flags' ] |= X_NodeFlags_DIRTY_CONTENT;
1168 this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
1172 if( ( xnodes = this[ '_xnodes' ] ) && xnodes.length === 1 && !xnodes[ 0 ][ '_tag' ] ){
1173 xnodes[ 0 ][ 'text' ]( text );
1176 // TODO 一つのtextnode を残すケース 完全に削除したい場合は empty()を使う
1177 if( !text ) return this[ 'empty' ]();
1178 this[ 'empty' ]()[ 'createText' ]( text );
1182 if( this[ '_tag' ] ){
1183 if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
1184 for( texts = [], i = 0; i < l; ++i ){
1185 texts[ i ] = xnodes[ i ][ 'text' ]();
1187 return texts.join( '' );
1191 return this[ '_text' ];
1195 * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。
1196 * @alias Node.prototype.call
1197 * @param {string} [name] 要素の関数名
1199 * @example node.call( 'focus' );
1201 function X_Node_call( name /*, opt_args... */ ){
1202 var args = arguments,
1203 l = args.length - 1,
1204 v, raw, parent, body,
1205 childX, childY, childW, childH,
1207 parentSX, parentSY, parentSW, parentSH,
1208 visibleX, visibleY, visibleW, visibleH,
1209 visiblePartX, visiblePartY, func, args, params, i;
1213 return !!( this[ '_flags' ] & X_NodeFlags_IS_SVG );
1215 return !!( this[ '_flags' ] & X_NodeFlags_IS_VML );
1217 return this[ '_tag' ] ? 1 : 3;
1219 X_Node_outerXNode = X_Node_body; // == true ならなんでもよい。型を合わすために xbody にしている
1220 v = this[ 'html' ]();
1221 X_Node_outerXNode = null;
1223 case 'treeIsDirty' :
1224 return !!X_Node_updateTimerID;
1226 return ( this[ '_flags' ] & X_NodeFlags_IN_TREE ) ? X_Node_CSS_getCharSize( this ) : 0;
1228 return !!( this[ '_flags' ] & ( X_NodeFlags_GPU_NOW | X_NodeFlags_GPU_RELEASE_RESERVED ) );
1230 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
1232 while( parent = parent.parent ){
1233 if( parent[ '_flags' ] & ( X_NodeFlags_GPU_NOW | X_NodeFlags_GPU_RELEASE_RESERVED ) ) return true;
1240 case 'canAnimateNow' :
1241 return ( this[ '_flags' ] & X_NodeFlags_IN_TREE ) && X_NodeAnime_detectWaitAnimation( this, true, true ) === 6;
1243 return this[ '_anime' ] ? this[ '_anime' ].phase : 0;
1244 case 'animeProgress' :
1245 return this[ '_anime' ] && this[ '_anime' ].phase === 7 ? this[ '_anime' ].progress : 0;
1248 X_Node_updateTimerID && X_Node_startUpdate();
1250 raw = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this );
1254 if( name === 'scrollTo' ){
1255 raw.scrollLeft = args[ 1 ] || 0;
1256 raw.scrollTop = args[ 2 ] || 0;
1260 if( name === 'inView' ){
1263 visibleX = visibleY = visibleW = visibleH = 0;
1264 while( child !== body ){
1265 parent = child.parentNode || child.parentElement;
1266 parentH = parent.clientHeight;
1267 parentW = parent.clientWidth;
1268 parentSW = parent.scrollHeight;
1269 parentSH = parent.scrollWidth;
1271 if( parentH < parentSH || parentW < parentSW ){
1272 childX = child.offsetLeft + visibleX;
1273 childY = child.offsetTop + visibleY;
1274 childW = visibleW || child.offsetWidth;
1275 childH = visibleH || child.offsetHeight;
1276 parentSX = parent.scrollLeft;
1277 parentSY = parent.scrollTop;
1279 if( parentSY < childY + childH &&
1280 childY < parentSY + parentH &&
1281 parentSX < childX + childW &&
1282 childX < parentSX + parentW ){
1284 // right:子の左側が見えている left:子の左側が見えている both:完全に見えている
1286 childX < parentSX ? 'right' :
1287 ( parentSX + parentW ) < ( childX + childW ) ? 'left' : 'both';
1289 childY < parentSY ? 'bottom' :
1290 ( parentSY + parentH ) < ( childY + childH ) ? 'top' : 'both';
1293 visibleX = visiblePartX === 'right' ? 0 : childX - parentSX;
1294 visibleY = visiblePartX === 'bottom' ? 0 : childY - parentSY;
1296 visiblePartX === 'both' ? childW :
1297 visiblePartX === 'right' ? ( parentSX + parentW - childX ) : ( childX + childW - parentSX );
1299 visiblePartY === 'both' ? childH :
1300 visiblePartY === 'bottom' ? ( parentSY + parentH - childY ) : ( childY + childH - parentSY );
1302 return { 'isInView' : false };
1307 return { 'isInView' : true };
1311 if( X_Type_isFunction( func ) ){
1313 args = X_Array_copy( args );
1315 return func.apply( raw, args );
1317 return raw[ name ]();
1319 if( X_UA[ 'IE' ] < 9 && ( X_Type_isUnknown( func ) || X_Type_isObject( func ) ) ){
1320 // typeof func === unknown に対策
1321 // http://la.ma.la/blog/diary_200509031529.htm
1323 args = X_Array_copy( args );
1327 for( i = 0; i < l; ++i ){
1328 params[ i ] = '_' + i;
1330 params = params.join( ',' );
1333 [ 'return this.', name, '(', params, ')' ].join( '' )
1334 ).apply( raw, args );
1336 return raw[ name ]();
1341 * xnode を this として関数を実行する。 NodeList.each と動作を合わせてあるため関数の戻り値は破棄される。
1344 function X_Node_each( func /*, opt_args */ ){
1346 if( 1 < arguments.length ){
1347 args = X_Array_copy( arguments );
1349 func.apply( this, args );
1351 func.call( this, 0 );
1357 /* --------------------------------------
1358 * Async commit update
1360 * TODO Timer や DOM イベントの呼び出しの最後に、まだ一度も commitUpdate していないなら commitUpdate してしまう。
1363 function X_Node_reserveUpdate(){
1364 if( !X_Node_updateTimerID ) X_Node_updateTimerID = X_Timer_requestFrame( X_Node_startUpdate );
1367 var X_Node_updateReservedByReleaseGPU = false;
1369 function X_Node_startUpdate( time ){
1370 var removal, i, xnodeOrElm, xnodesIEFilterFixAfter, xnode;
1372 if( !X_Node_updateTimerID || X_ViewPort_readyState < X_EVENT_INIT ){
1376 X_Timer_cancelFrame( X_Node_updateTimerID );
1377 X_Node_updateTimerID = 0;
1380 // X.Timer 経由でないと発火しない このイベントでサイズを取ると無限ループに
1381 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE );
1384 removal = X_Node_reserveRemoval;
1386 if( i = removal.length ){
1388 xnodeOrElm = removal[ --i ];
1389 // TODO GPU レイヤーの子の場合、remove をスキップする。 非GPU レイヤーへ apppend される場合、clone する?
1390 // GPU レイヤーを削除する場合、cssText = '' して GPU レイヤーを解除する
1391 if( !xnodeOrElm[ 'instanceOf' ] ){
1393 xnodeOrElm.removeAttribute( 'id' ); // ?
1394 xnodeOrElm.outerHTML = ''; // xnodeOrElm.remove() ?
1396 if( !X_UA[ 'MacIE' ] ){
1397 // elm.parentNode.tagName for ie7
1398 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && xnodeOrElm.parentNode.removeChild( xnodeOrElm );
1400 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && X_TEMP._fixed_remove( xnodeOrElm, that );
1404 X_Node__actualRemove( xnodeOrElm );
1411 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = 'hidden' );
1413 if( X_Node_html[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1414 X_Node__commitUpdate( X_Node_html, X_Node_html[ '_rawObject' ].parentNode, null, X_Node_html[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1416 X_Node__commitUpdate( X_Node_head, X_Node_head[ '_rawObject' ].parentNode, null, X_Node_head[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1417 X_Node__commitUpdate( X_Node_body, X_Node_body[ '_rawObject' ].parentNode, null, X_Node_body[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1420 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = '' );
1422 if( X_Node_updateReservedByReleaseGPU ){
1423 X_Node_reserveUpdate();
1424 X_Node_updateReservedByReleaseGPU = false;
1427 if( X_NodeFlags_IE_FILTER_FIX_AFTER && xnodesIEFilterFixAfter.length ){
1428 for( i = 0; xnode = xnodesIEFilterFixAfter[ i ]; ++i ){
1429 xnode[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_FIX_AFTER;
1430 X_Node_CSS_onAfterUpdateIEFilterFix( xnode );
1434 // time を視て X.Timer 経由の場合、即座に発火する。
1435 // width() 等で強制的にツリーを構築している場合、UPDATE イベントのコールバックで要素を変更しサイズを取ると無限ループになる,これを防ぐため asyncDispatch とする
1436 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_UPDATED ] && X_System[ time ? 'dispatch' : 'asyncDispatch' ]( X_EVENT_UPDATED );
1438 X_ViewPort[ '_listeners' ] && X_ViewPort[ '_listeners' ][ X_EVENT_AFTER_UPDATE ] && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_AFTER_UPDATE );
1442 * 1. GPU_NOW の場合、子の変更は行わない
1443 * 2. GPU解放予約 の場合//、この要素のみ変更を行う。rAF 後にさらに更新するためフラグを立てる。
1445 * 4. style="display:none" の場合、これ以下の変更を行わない。
1446 * 5. ie5 非表示フラグが立っていて、親と自身の class・id によって非表示になっていて、親と自身に変更がない。accumulatedFlags を使用。
1447 * -> TODO これ TREE の変更を検出できない。 remove したときに 子まで X_NodeFlags_IE5_DISPLAY_NONE_FIXを落とす。
1451 * 9. ie5 親及び自身へのクラス・id指定で display:none になるケースがありそれを検出。
1452 * このままでは、生成と破棄が繰り返されてしまうので親と自身のクラス・idが変わった場合、ツリー位置の変化があった場合に再生する。
1454 var X_Node__commitUpdate =
1456 ( function( that, parentElement, nextElement, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter ){
1457 var elm = that[ '_rawObject' ],
1458 created, xnodes, l, next, anime, v, currentOpcity;
1460 // 1. GPU 一切の更新をスキップ
1461 if( that[ '_flags' ] & X_NodeFlags_GPU_NOW ){
1462 console.log( '更新のskip ' + that[ '_className' ] + !!( that[ '_flags' ] & X_Node_BitMask_IS_DIRTY ) );
1463 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1468 if( that[ '_flags' ] & X_NodeFlags_GPU_RELEASE_RESERVED ){
1469 console.log( 'GPU 解放 ' );
1470 //X_Node_updateReservedByReleaseGPU = true;
1471 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1472 //return elm;// このタイミングで更新できるっぽい。
1476 if( that[ '_flags' ] & X_NodeFlags_GPU_RESERVED ){
1477 // TODO size 取得のための update の場合、GPU化をスキップ
1478 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1479 that[ '_flags' ] |= X_NodeFlags_GPU_NOW;
1482 // 4. style="display:none" の場合
1483 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1484 if( X_Node_displayNoneFixForIE5 ){
1485 // filter の効いている要素を含む要素は display:none が無視される。
1486 // filter = '' で削除はできるが、再表示時に filter が消える。 -> filter な要素を削除してしまう。
1487 // TODO filters[0].enabled = false なんてどう?
1488 if( elm && elm.parentNode ){
1489 X_Node__actualRemove( that );
1493 elm && ( elm.style.display = 'none' );
1494 return ( elm && elm.nextSibling === nextElement ) ? elm : nextElement;
1498 accumulatedFlags |= that[ '_flags' ];
1500 if( that[ '_flags' ] & X_NodeFlags_IE5_DISPLAY_NONE_FIX ){
1501 if( ( accumulatedFlags & ( X_NodeFlags_DIRTY_POSITION | X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME ) ) === 0 ){
1508 if( !that[ '_tag' ] ){
1509 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1510 elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
1511 if( !X_UA[ 'IE' ] ){
1512 elm[ 'UID' ] = that[ '_uid' ];
1515 if( X_Node_strictElmCreation ){
1516 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true ); // OLD_CSSTEXT ??
1519 document.createElement( [
1520 '<', that[ '_tag' ],
1521 ' UID="', that[ '_uid' ], '"',
1522 that[ '_id' ] ? ' id="' + that[ '_id' ] + '"' : '',
1523 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
1524 X_Node_Attr_objToAttrText( that, true ),
1525 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
1528 if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
1529 elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ].toLowerCase() );
1531 // TODO math http://www.w3.org/1998/Math/MathML
1533 elm = document.createElement( that[ '_tag' ] );
1536 that[ '_rawObject' ] = elm;
1538 // IE には要素追加のタイミングで起こるメモリリークがありここで追加
1539 if( !X_Node_addTreeAfterChildren ){
1541 parentElement.insertBefore( elm, nextElement ) :
1542 parentElement.appendChild( elm );
1545 if( that[ '_tag' ] ){
1546 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
1547 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1549 //if( X_Node_documentFragment ){
1550 //( frg = X_Node_documentFragment ).appendChild( elm );
1551 // 連続する要素の差し替えの場合に有効
1554 if( X_Node_strictElmCreation ){
1555 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1556 // ie の string から要素を作る場合、ネットワーク系属性は onload イベントなどを拾うために、要素生成->イベント復帰後に適用する
1557 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR ); // _newAttrs には ネットワーク系属性が入っている。Network 系の属性は遅らせて設定
1558 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;// doc 追加後に filter を指定しないと有効にならない。
1560 elm[ 'UID' ] = that[ '_uid' ];
1561 that[ '_newAttrs' ] = that[ '_attrs' ];
1562 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1563 that[ '_flags' ] |= X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME | X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_CSS | X_NodeFlags_DIRTY_IE_FILTER;
1565 // http://outcloud.blogspot.jp/2010/09/iframe.html
1566 // この問題は firefox3.6 で確認
1567 if( X_UA[ 'Gecko' ] ){
1568 if( that[ '_tag' ] === 'IFRAME' && ( !that[ '_attrs' ] || !that[ '_attrs' ][ 'src' ] ) ){
1569 //elm.contentWindow.location.replace = elm.src = 'about:blank';
1570 that[ 'attr' ]( 'src', 'about:blank' );
1579 if( elm.parentNode !== parentElement || ( nextElement && elm.nextSibling !== nextElement ) ){
1581 parentElement.insertBefore( elm, nextElement ) :
1582 parentElement.appendChild( elm );
1585 if( that[ '_listeners' ] && ( ( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ) === 0 ) ){
1586 X_EventDispatcher_toggleAllEvents( that, true );// イベントの退避
1587 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1590 // ie8 では子要素に opacity が反映されないため、親要素の opacity を積算する
1591 currentOpcity = that[ '_css' ] && 0 <= that[ '_css' ].opacity && that[ '_css' ].opacity;
1592 ie8AccumulatedOpcity = ie8AccumulatedOpcity * ( currentOpcity || 1 );
1595 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ){
1596 delete that[ '_fontSize' ];
1597 X_Node__updateRawNode( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags );
1601 // 親及び自身へのクラス・id指定で display : none になるケースがありそれを検出
1602 // 生成と破棄が繰り返されてしまう、親と自身の id, class が変わった場合だけ再生成。 accumulatedFlags & ( ID | CLASSNAME )
1603 // currentStyle を観ていたときはエラーで停止する、alert と挟むと正常に動いて支離滅裂
1604 if( X_Node_displayNoneFixForIE5 && that[ '_tag' ] ){
1605 if( elm.runtimeStyle.display === 'none' ){
1606 X_Node__actualRemove( that );
1607 that[ '_flags' ] |= X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1610 that[ '_flags' ] &= ~X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1614 if( that[ '_flags' ] & X_NodeFlags_IE_FILTER_FIX_AFTER ){
1615 xnodesIEFilterFixAfter[ xnodesIEFilterFixAfter.length ] = that;
1619 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ) {
1621 next = X_Node__commitUpdate( xnodes[ --l ], elm, next, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter );
1625 if( created && X_Node_addTreeAfterChildren ){
1627 parentElement.insertBefore( elm, nextElement ) :
1628 parentElement.appendChild( elm );
1630 if( X_UA[ 'Gecko' ] && that[ '_tag' ] === 'IFRAME' && elm.contentWindow ){
1631 // tree に追加されるまで contentWindow は存在しない。
1632 elm.contentWindow.location.replace = elm.src;
1639 ( function( that, parentElement, prevElement, accumulatedFlags ){
1640 var elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
1641 xnodes, l, i, dirty, mix, html, text, prev;
1643 if( !that[ '_tag' ] ){
1644 that[ '_flags' ] & X_NodeFlags_DIRTY_CONTENT && X_Node__updateRawNode( that, elm );
1648 // 4. style="display:none" の場合
1649 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1651 elm.style.display = 'none';
1652 if( elm.style.display !== 'none' ){ // ie4 の style は currentStyle 相当らしい、、、? div 以外への display:none が効かないので remove する。
1653 X_Node__actualRemove( that );
1657 return elm || prevElement;
1662 prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that, false ) ) :
1663 parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that, false ) );
1664 X_Node__afterActualCreate( that );
1666 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that );
1668 accumulatedFlags |= that[ '_flags' ];
1670 xnodes = that[ '_xnodes' ];
1671 l = xnodes ? xnodes.length : 0;
1672 dirty = !!( that[ '_flags' ] & X_NodeFlags_IE4_DIRTY_CHILDREN );
1675 * HTML の下に TextNode だけ 。MIX_FIXED でない場合、削除、追加 を親に通知
1677 * HTML の下は MIX -> TextNode, html の削除、変更、追加
1678 * HTML の下は MIX_FIXED -> TextNode を <font> に置き換えてあるのでW3C DON 的に触ることができる
1681 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
1682 for( i = 0; i < l; ++i ){
1683 if( xnodes[ i ][ '_tag' ] ){
1684 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
1686 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
1688 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
1695 if( that[ '_flags' ] & X_NodeFlags_IE4_FIXED || that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_ELEMENT ){
1696 for( i = 0; i < l; ++i ){
1697 prev = X_Node__commitUpdate( xnodes[ i ], elm, prev, accumulatedFlags );
1702 for( i = 0; i < l; ++i ){
1703 html[ i ] = X_Node__actualCreate( xnodes[ i ], false );
1705 elm.innerHTML = html.join( '' );
1706 for( i = 0; i < l; ++i ){
1707 X_Node__afterActualCreate( xnodes[ i ] );
1709 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
1711 if( that[ '_flags' ] & X_NodeFlags_IE4_HAS_TEXTNODE ){
1712 dirty = dirty || false;
1713 for( i = 0; i < l; ++i ){
1715 if( text[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1716 text[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1720 if( dirty ) elm.innerHTML = that[ 'text' ]();
1723 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ) delete that[ '_fontSize' ];
1725 that[ '_flags' ] &= ~X_NodeFlags_DIRTY_POSITION;
1726 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1729 if( ( anime = that[ '_anime' ] ) && 6 <= anime.phase && anime.doScroll ){
1730 if( anime.phase === 6 ){
1731 v = anime.fromScrollX;
1735 anime.fromScrollX = elm.scrollLeft;
1737 v = anime.fromScrollY;
1741 anime.fromScrollY = elm.scrollTop;
1744 elm.scrollLeft = anime.scrollX;
1745 elm.scrollTop = anime.scrollY;
1754 * GPU レイヤーするブラウザは、子要素から変更を当てていく? <- とりあえず、親要素から。
1756 var X_Node__updateRawNode =
1758 ( function( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags ){
1759 var // flags = that[ '_flags' ],
1760 attrs, rename, k, v, f;
1763 if( !that[ '_tag' ] ){
1764 elm.data = X_String_chrReferanceTo( that[ '_text' ] );
1765 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1770 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ){
1772 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1773 elm.setAttribute( 'id', that[ '_id' ] ) :
1774 ( elm.id = that[ '_id' ] )
1776 ( elm.id && elm.removeAttribute( 'id' ) );
1779 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1780 that[ '_className' ] ?
1781 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1782 elm.setAttribute( 'class', that[ '_className' ] ) :
1783 ( elm.className = that[ '_className' ] )
1785 ( elm.className && elm.removeAttribute( X_UA[ 'IE' ] < 8 ? 'className' : 'class' ) ); // className は ie7-
1789 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1790 rename = X_Node_Attr_renameForDOM;
1795 switch( that[ '_tag' ] + k ){
1796 case 'TEXTAREAvalue' :
1797 // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので
1798 // MultipleIE6 でもここを通す。X_UA[ 'ieExeComError' ] の場合 MultipleIE6
1799 if( ( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ) || ( X_UA[ 'ieExeComError' ] && X_UA[ 'IE6' ] ) ){
1801 ( elm.firstChild.data = v || '' ) :
1802 elm.appendChild( document.createTextNode( v || '' ) );
1808 // http://outcloud.blogspot.jp/2010/09/iframe.html
1809 // この問題は firefox3.6 で確認
1810 if( X_UA[ 'Gecko' ] && elm.contentWindow ){
1811 elm.contentWindow.location.replace = elm.src = v || '';
1817 // http://d.hatena.ne.jp/NeoCat/20080921/1221940658
1818 // こちらに名前をsetしないとtargetが動作しない
1819 // これってあとから name を変更できないバグでは? itozyun
1820 // if( X_UA[ 'IE' ] ) elm.name = elm.contentWindow.name = v || '';
1823 //if( X_EMPTY_OBJECT[ k ] ) continue;
1824 // TODO IE では input, なぜか button, object も type, name の変更が出来ない、同値で置き換えようとしても不可
1826 elm.removeAttribute( rename[ k ] || k ) :
1827 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1828 elm.setAttribute( k, v ) :
1829 ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v )
1832 delete that[ '_newAttrs' ];
1835 if( accumulatedFlags & X_NodeFlags_IE8_OPACITY_FIX ){
1836 if( 0 <= currentOpcity ){
1838 that[ '_css' ].opacity = ie8AccumulatedOpcity;
1839 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1840 that[ '_flags' ] |= X_NodeFlags_OLD_CSSTEXT;
1842 if( !( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ) ){
1843 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;
1849 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1850 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1851 X_UA[ 'Opera78' ] || X_UA[ 'NN6' ] ?
1852 elm.setAttribute( 'style', that[ '_cssText' ] ) : // opera8用
1853 ( elm.style.cssText = that[ '_cssText' ] );
1855 elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要
1856 elm.removeAttribute( 'style' );
1859 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1860 v = X_Node_CSS_objToIEFilterText( that );
1862 elm.style.filter = v;
1863 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1865 elm.style.removeAttribute( 'filter' );
1866 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1871 * http://jsdo.it/esukei/imOL
1872 * IE8でのfilter:alpha継承
1873 * IE8でfilter:alphaの指定がposition:relative,position:absoluteの子要素に継承されない問題
1876 that[ '_css' ].opacity = currentOpcity;
1879 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1882 ( function( that, elm ){
1883 var attrs, rename, k, v;
1886 if( !that[ '_tag' ] ){
1887 elm.innerText = that[ '_text' ];
1888 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1893 * http://www.tohoho-web.com/js/element.htm
1894 * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる
1897 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ) elm.setAttribute( 'id', that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) );
1900 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1901 that[ '_className' ] ? ( elm.className = that[ '_className' ] ) : elm.removeAttribute( 'class' );
1904 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1905 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1906 elm.style.cssText = that[ '_cssText' ];
1908 elm.style.cssText = '';
1909 elm.removeAttribute( 'style' );
1912 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1913 v = X_Node_CSS_objToIEFilterText( that );
1915 elm.style.filter = v;
1916 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1918 elm.style.removeAttribute( 'filter' );
1919 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1924 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1925 rename = X_Node_Attr_renameForDOM;
1927 //if( X_EMPTY_OBJECT[ k ] ) continue;
1928 ( v = attrs[ k ] ) === undefined ?
1929 elm.removeAttribute( rename[ k ] || k ) :
1930 elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v );
1932 delete that[ '_newAttrs' ];
1935 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1939 /* --------------------------------------
1942 * http://d.hatena.ne.jp/uupaa/20080718/1216362040
1943 * DOM Rangeが使える環境(Firefox2+,Opera9+,Safari3+)なら、innerHTMLいらずで、ガーって書けます。
1944 * return document.createRange().createContextualFragment("<div><select><option></option></select></div>");
1945 * insertAdjacentHTML
1947 * ie7 以下では iframe の frameborder や、input name は、createElement 後に setAttribute しても無視される
1949 * fragument がある場合 children も足して
1950 * Mozilla: 1.0+, IE: 5.5+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+
1951 * ie6 大丈夫?fragment の場合リークしないか?チェックが必要
1952 * http://msdn.microsoft.com/ja-jp/library/bb250448%28v=vs.85%29.aspx
1954 * document.createElement of ie4 is only for OPTION & IMAGE.
1956 var X_Node__actualCreate =
1957 X_UA_DOM.IE4 && (function( that, isChild ){
1958 var uid = that[ '_uid' ],
1959 html, xnodes, n, i, l;
1961 if( !that[ '_tag' ] ){
1962 html = [ '<FONT id=ie4uid', uid, ' UID="', uid, '">', that[ '_text' ], '</FONT>' ];// fake textNode
1963 delete that[ '_rawObject' ];
1965 if( !isChild ) X_Node__actualRemove( that, /* true */ false );
1967 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true );
1970 '<', that[ '_tag' ], ' id=', ( that[ '_id' ] || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',
1971 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
1972 X_Node_Attr_objToAttrText( that, true ),
1973 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
1977 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ){
1979 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
1980 for( i = 0; i < l; ++i ){
1981 if( xnodes[ i ][ '_tag' ] ){
1982 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
1984 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
1986 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
1991 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_TEXTNODE ){
1993 html[ n ] = that[ 'text' ]();
1996 for( i = 0; i < l; ++i ){
1997 html[ n ] = X_Node__actualCreate( xnodes[ i ], true );
2000 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
2003 X_Dom_DTD_EMPTY[ that[ '_tag' ] ] || ( html[ n ] = '<\/' + that[ '_tag' ] + '>' );
2005 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR );
2008 return html.join( '' );
2011 var X_Node__afterActualCreate =
2012 X_UA_DOM.IE4 && (function( that ){
2015 if( !that[ '_tag' ] ) return that;
2017 if( ( xnodes = that[ '_xnodes' ] ) && ( i = xnodes.length ) ){
2019 X_Node__afterActualCreate( xnodes[ --i ] );
2022 // ネットワーク系属性と filter は要素生成後に適用
2023 if( that[ '_flags' ] & ( X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_IE_FILTER ) ){
2024 X_Node__updateRawNode( that, that[ '_rawObject' ] || X_Node__ie4getRawNode( that ) );
2026 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
2028 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
2031 var X_Node__actualRemove =
2033 // GPUレイヤーにいるうちは remove しない。-> GPU解除してから remove する
2034 // Firefox34 では遭遇せず、Safari で何度かアニメーションしているうちに発生
2035 ( function( that, isChild ){
2036 var xnodes = that[ '_xnodes' ],
2037 elm = that[ '_rawObject' ],
2040 if( xnodes && ( l = xnodes.length ) ){
2041 for( i = 0; i < l; ++i ){
2042 child = xnodes[ i ];
2043 child[ '_tag' ] && X_Node__actualRemove( child, true );
2049 if( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ){
2050 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2051 that[ '_flags' ] &= ~X_NodeFlags_ACTUAL_LISTENING;
2054 // ie5では filter の効いている要素をremove時に破棄して、再度append 時に新規生成する
2055 // ちなみに elm.filters に触ると ie8 でなぜかカラム落ちが発生、、、
2056 if( X_Node_displayNoneFixForIE5 ){
2057 if( elm.filters && elm.filters.length ){
2059 delete that[ '_rawObject' ];
2060 // 破棄前にインタラクティブな属性値を控える
2061 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2062 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2063 that[ '_attrs' ].value = elm.value;
2065 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2066 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2067 that[ '_attrs' ].selected = elm.selected;
2069 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2070 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2071 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2073 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2074 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2075 that[ '_attrs' ].checked = elm.checked;
2082 if( !X_UA[ 'MacIE' ] ){
2083 // elm.parentNode.tagName for ie7
2084 !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );
2086 !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that );
2090 ( function( that, isChild ){
2091 var xnodes = that[ '_xnodes' ],
2092 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
2094 if( xnodes && ( l = xnodes.length ) ){
2095 for( i = 0; i < l; ++i ){
2096 X_Node__actualRemove( xnodes[ i ], true );
2101 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2103 // 破棄前にインタラクティブな属性値を控える
2104 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2105 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2106 that[ '_attrs' ].value = elm.value;
2108 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2109 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2110 that[ '_attrs' ].selected = elm.selected;
2112 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2113 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2114 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2116 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2117 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2118 that[ '_attrs' ].checked = elm.checked;
2121 elm.removeAttribute( 'id' ); // ?
2122 //document.all[ that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) ] = null; // MacIE5 でエラー
2123 if( !isChild ) elm.outerHTML = ''; // elm.remove() ?
2124 delete that[ '_rawObject' ];
2128 X_ViewPort[ 'listenOnce' ]( X_EVENT_UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );