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 child, 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' ){
1261 if( !( this[ '_flags' ] & X_NodeFlags_IN_TREE ) ) return { 'isInView' : false };
1264 visibleX = visibleY = visibleW = visibleH = 0;
1265 while( child !== body ){
1266 parent = child.parentNode || child.parentElement;
1267 parentH = parent.clientHeight;
1268 parentW = parent.clientWidth;
1269 parentSW = parent.scrollHeight;
1270 parentSH = parent.scrollWidth;
1272 if( parentH < parentSH || parentW < parentSW ){
1273 childX = child.offsetLeft + visibleX;
1274 childY = child.offsetTop + visibleY;
1275 childW = visibleW || child.offsetWidth;
1276 childH = visibleH || child.offsetHeight;
1277 parentSX = parent.scrollLeft;
1278 parentSY = parent.scrollTop;
1280 if( parentSY < childY + childH &&
1281 childY < parentSY + parentH &&
1282 parentSX < childX + childW &&
1283 childX < parentSX + parentW ){
1285 // right:子の左側が見えている left:子の左側が見えている both:完全に見えている
1287 childX < parentSX ? 'right' :
1288 ( parentSX + parentW ) < ( childX + childW ) ? 'left' : 'both';
1290 childY < parentSY ? 'bottom' :
1291 ( parentSY + parentH ) < ( childY + childH ) ? 'top' : 'both';
1294 visibleX = visiblePartX === 'right' ? 0 : childX - parentSX;
1295 visibleY = visiblePartX === 'bottom' ? 0 : childY - parentSY;
1297 visiblePartX === 'both' ? childW :
1298 visiblePartX === 'right' ? ( parentSX + parentW - childX ) : ( childX + childW - parentSX );
1300 visiblePartY === 'both' ? childH :
1301 visiblePartY === 'bottom' ? ( parentSY + parentH - childY ) : ( childY + childH - parentSY );
1303 return { 'isInView' : false };
1308 return { 'isInView' : true };
1312 if( X_Type_isFunction( func ) ){
1314 args = X_Array_copy( args );
1316 return func.apply( raw, args );
1318 return raw[ name ]();
1320 if( X_UA[ 'IE' ] < 9 && ( X_Type_isUnknown( func ) || X_Type_isObject( func ) ) ){
1321 // typeof func === unknown に対策
1322 // http://la.ma.la/blog/diary_200509031529.htm
1324 args = X_Array_copy( args );
1328 for( i = 0; i < l; ++i ){
1329 params[ i ] = '_' + i;
1331 params = params.join( ',' );
1334 [ 'return this.', name, '(', params, ')' ].join( '' )
1335 ).apply( raw, args );
1337 return raw[ name ]();
1342 * xnode を this として関数を実行する。 NodeList.each と動作を合わせてあるため関数の戻り値は破棄される。
1345 function X_Node_each( func /*, opt_args */ ){
1347 if( 1 < arguments.length ){
1348 args = X_Array_copy( arguments );
1350 func.apply( this, args );
1352 func.call( this, 0 );
1358 /* --------------------------------------
1359 * Async commit update
1361 * TODO Timer や DOM イベントの呼び出しの最後に、まだ一度も commitUpdate していないなら commitUpdate してしまう。
1364 function X_Node_reserveUpdate(){
1365 if( !X_Node_updateTimerID ) X_Node_updateTimerID = X_Timer_requestFrame( X_Node_startUpdate );
1368 var X_Node_updateReservedByReleaseGPU = false;
1370 function X_Node_startUpdate( time ){
1371 var removal, i, xnodeOrElm, xnodesIEFilterFixAfter, xnode;
1373 if( !X_Node_updateTimerID || X_ViewPort_readyState < X_EVENT_INIT ){
1377 X_Timer_cancelFrame( X_Node_updateTimerID );
1378 X_Node_updateTimerID = 0;
1381 // X.Timer 経由でないと発火しない このイベントでサイズを取ると無限ループに
1382 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE );
1385 removal = X_Node_reserveRemoval;
1387 if( i = removal.length ){
1389 xnodeOrElm = removal[ --i ];
1390 // TODO GPU レイヤーの子の場合、remove をスキップする。 非GPU レイヤーへ apppend される場合、clone する?
1391 // GPU レイヤーを削除する場合、cssText = '' して GPU レイヤーを解除する
1392 if( !xnodeOrElm[ 'instanceOf' ] ){
1394 xnodeOrElm.removeAttribute( 'id' ); // ?
1395 xnodeOrElm.outerHTML = ''; // xnodeOrElm.remove() ?
1397 if( !X_UA[ 'MacIE' ] ){
1398 // elm.parentNode.tagName for ie7
1399 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && xnodeOrElm.parentNode.removeChild( xnodeOrElm );
1401 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && X_TEMP._fixed_remove( xnodeOrElm, that );
1405 X_Node__actualRemove( xnodeOrElm );
1412 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = 'hidden' );
1414 if( X_Node_html[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1415 X_Node__commitUpdate( X_Node_html, X_Node_html[ '_rawObject' ].parentNode, null, X_Node_html[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1417 X_Node__commitUpdate( X_Node_head, X_Node_head[ '_rawObject' ].parentNode, null, X_Node_head[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1418 X_Node__commitUpdate( X_Node_body, X_Node_body[ '_rawObject' ].parentNode, null, X_Node_body[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1421 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = '' );
1423 if( X_Node_updateReservedByReleaseGPU ){
1424 X_Node_reserveUpdate();
1425 X_Node_updateReservedByReleaseGPU = false;
1428 if( X_NodeFlags_IE_FILTER_FIX_AFTER && xnodesIEFilterFixAfter.length ){
1429 for( i = 0; xnode = xnodesIEFilterFixAfter[ i ]; ++i ){
1430 xnode[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_FIX_AFTER;
1431 X_Node_CSS_onAfterUpdateIEFilterFix( xnode );
1435 // time を視て X.Timer 経由の場合、即座に発火する。
1436 // width() 等で強制的にツリーを構築している場合、UPDATE イベントのコールバックで要素を変更しサイズを取ると無限ループになる,これを防ぐため asyncDispatch とする
1437 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_UPDATED ] && X_System[ time ? 'dispatch' : 'asyncDispatch' ]( X_EVENT_UPDATED );
1439 X_ViewPort[ '_listeners' ] && X_ViewPort[ '_listeners' ][ X_EVENT_AFTER_UPDATE ] && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_AFTER_UPDATE );
1443 * 1. GPU_NOW の場合、子の変更は行わない
1444 * 2. GPU解放予約 の場合//、この要素のみ変更を行う。rAF 後にさらに更新するためフラグを立てる。
1446 * 4. style="display:none" の場合、これ以下の変更を行わない。
1447 * 5. ie5 非表示フラグが立っていて、親と自身の class・id によって非表示になっていて、親と自身に変更がない。accumulatedFlags を使用。
1448 * -> TODO これ TREE の変更を検出できない。 remove したときに 子まで X_NodeFlags_IE5_DISPLAY_NONE_FIXを落とす。
1452 * 9. ie5 親及び自身へのクラス・id指定で display:none になるケースがありそれを検出。
1453 * このままでは、生成と破棄が繰り返されてしまうので親と自身のクラス・idが変わった場合、ツリー位置の変化があった場合に再生する。
1455 var X_Node__commitUpdate =
1457 ( function( that, parentElement, nextElement, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter ){
1458 var elm = that[ '_rawObject' ],
1459 created, xnodes, l, next, anime, v, currentOpcity;
1461 // 1. GPU 一切の更新をスキップ
1462 if( that[ '_flags' ] & X_NodeFlags_GPU_NOW ){
1463 console.log( '更新のskip ' + that[ '_className' ] + !!( that[ '_flags' ] & X_Node_BitMask_IS_DIRTY ) );
1464 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1469 if( that[ '_flags' ] & X_NodeFlags_GPU_RELEASE_RESERVED ){
1470 console.log( 'GPU 解放 ' );
1471 //X_Node_updateReservedByReleaseGPU = true;
1472 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1473 //return elm;// このタイミングで更新できるっぽい。
1477 if( that[ '_flags' ] & X_NodeFlags_GPU_RESERVED ){
1478 // TODO size 取得のための update の場合、GPU化をスキップ
1479 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1480 that[ '_flags' ] |= X_NodeFlags_GPU_NOW;
1483 // 4. style="display:none" の場合
1484 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1485 if( X_Node_displayNoneFixForIE5 ){
1486 // filter の効いている要素を含む要素は display:none が無視される。
1487 // filter = '' で削除はできるが、再表示時に filter が消える。 -> filter な要素を削除してしまう。
1488 // TODO filters[0].enabled = false なんてどう?
1489 if( elm && elm.parentNode ){
1490 X_Node__actualRemove( that );
1494 elm && ( elm.style.display = 'none' );
1495 return ( elm && elm.nextSibling === nextElement ) ? elm : nextElement;
1499 accumulatedFlags |= that[ '_flags' ];
1501 if( that[ '_flags' ] & X_NodeFlags_IE5_DISPLAY_NONE_FIX ){
1502 if( ( accumulatedFlags & ( X_NodeFlags_DIRTY_POSITION | X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME ) ) === 0 ){
1509 if( !that[ '_tag' ] ){
1510 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1511 elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
1512 if( !X_UA[ 'IE' ] ){
1513 elm[ 'UID' ] = that[ '_uid' ];
1516 if( X_Node_strictElmCreation ){
1517 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true ); // OLD_CSSTEXT ??
1520 document.createElement( [
1521 '<', that[ '_tag' ],
1522 ' UID="', that[ '_uid' ], '"',
1523 that[ '_id' ] ? ' id="' + that[ '_id' ] + '"' : '',
1524 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
1525 X_Node_Attr_objToAttrText( that, true ),
1526 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
1529 if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
1530 elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ].toLowerCase() );
1532 // TODO math http://www.w3.org/1998/Math/MathML
1534 elm = document.createElement( that[ '_tag' ] );
1537 that[ '_rawObject' ] = elm;
1539 // IE には要素追加のタイミングで起こるメモリリークがありここで追加
1540 if( !X_Node_addTreeAfterChildren ){
1542 parentElement.insertBefore( elm, nextElement ) :
1543 parentElement.appendChild( elm );
1546 if( that[ '_tag' ] ){
1547 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
1548 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1550 //if( X_Node_documentFragment ){
1551 //( frg = X_Node_documentFragment ).appendChild( elm );
1552 // 連続する要素の差し替えの場合に有効
1555 if( X_Node_strictElmCreation ){
1556 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1557 // ie の string から要素を作る場合、ネットワーク系属性は onload イベントなどを拾うために、要素生成->イベント復帰後に適用する
1558 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR ); // _newAttrs には ネットワーク系属性が入っている。Network 系の属性は遅らせて設定
1559 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;// doc 追加後に filter を指定しないと有効にならない。
1561 elm[ 'UID' ] = that[ '_uid' ];
1562 that[ '_newAttrs' ] = that[ '_attrs' ];
1563 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1564 that[ '_flags' ] |= X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME | X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_CSS | X_NodeFlags_DIRTY_IE_FILTER;
1566 // http://outcloud.blogspot.jp/2010/09/iframe.html
1567 // この問題は firefox3.6 で確認
1568 if( X_UA[ 'Gecko' ] ){
1569 if( that[ '_tag' ] === 'IFRAME' && ( !that[ '_attrs' ] || !that[ '_attrs' ][ 'src' ] ) ){
1570 //elm.contentWindow.location.replace = elm.src = 'about:blank';
1571 that[ 'attr' ]( 'src', 'about:blank' );
1580 if( elm.parentNode !== parentElement || ( nextElement && elm.nextSibling !== nextElement ) ){
1582 parentElement.insertBefore( elm, nextElement ) :
1583 parentElement.appendChild( elm );
1586 if( that[ '_listeners' ] && ( ( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ) === 0 ) ){
1587 X_EventDispatcher_toggleAllEvents( that, true );// イベントの退避
1588 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1591 // ie8 では子要素に opacity が反映されないため、親要素の opacity を積算する
1592 currentOpcity = that[ '_css' ] && 0 <= that[ '_css' ].opacity && that[ '_css' ].opacity;
1593 ie8AccumulatedOpcity = ie8AccumulatedOpcity * ( currentOpcity || 1 );
1596 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ){
1597 delete that[ '_fontSize' ];
1598 X_Node__updateRawNode( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags );
1602 // 親及び自身へのクラス・id指定で display : none になるケースがありそれを検出
1603 // 生成と破棄が繰り返されてしまう、親と自身の id, class が変わった場合だけ再生成。 accumulatedFlags & ( ID | CLASSNAME )
1604 // currentStyle を観ていたときはエラーで停止する、alert と挟むと正常に動いて支離滅裂
1605 if( X_Node_displayNoneFixForIE5 && that[ '_tag' ] ){
1606 if( elm.runtimeStyle.display === 'none' ){
1607 X_Node__actualRemove( that );
1608 that[ '_flags' ] |= X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1611 that[ '_flags' ] &= ~X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1615 if( that[ '_flags' ] & X_NodeFlags_IE_FILTER_FIX_AFTER ){
1616 xnodesIEFilterFixAfter[ xnodesIEFilterFixAfter.length ] = that;
1620 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ) {
1622 next = X_Node__commitUpdate( xnodes[ --l ], elm, next, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter );
1626 if( created && X_Node_addTreeAfterChildren ){
1628 parentElement.insertBefore( elm, nextElement ) :
1629 parentElement.appendChild( elm );
1631 if( X_UA[ 'Gecko' ] && that[ '_tag' ] === 'IFRAME' && elm.contentWindow ){
1632 // tree に追加されるまで contentWindow は存在しない。
1633 elm.contentWindow.location.replace = elm.src;
1638 * if( ( anime = that[ '_anime' ] ) && 6 <= anime.phase && anime.doScroll ){
1639 if( anime.phase === 6 ){
1640 v = anime.fromScrollX;
1644 anime.fromScrollX = elm.scrollLeft;
1646 v = anime.fromScrollY;
1650 anime.fromScrollY = elm.scrollTop;
1653 elm.scrollLeft = anime.scrollX;
1654 elm.scrollTop = anime.scrollY;
1662 ( function( that, parentElement, prevElement, accumulatedFlags ){
1663 var elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
1664 xnodes, l, i, dirty, mix, html, text, prev, anime, v;
1666 if( !that[ '_tag' ] ){
1667 that[ '_flags' ] & X_NodeFlags_DIRTY_CONTENT && X_Node__updateRawNode( that, elm );
1671 // 4. style="display:none" の場合
1672 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1674 elm.style.display = 'none';
1675 if( elm.style.display !== 'none' ){ // ie4 の style は currentStyle 相当らしい、、、? div 以外への display:none が効かないので remove する。
1676 X_Node__actualRemove( that );
1680 return elm || prevElement;
1685 prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that, false ) ) :
1686 parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that, false ) );
1687 X_Node__afterActualCreate( that );
1689 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that );
1691 accumulatedFlags |= that[ '_flags' ];
1693 xnodes = that[ '_xnodes' ];
1694 l = xnodes ? xnodes.length : 0;
1695 dirty = !!( that[ '_flags' ] & X_NodeFlags_IE4_DIRTY_CHILDREN );
1698 * HTML の下に TextNode だけ 。MIX_FIXED でない場合、削除、追加 を親に通知
1700 * HTML の下は MIX -> TextNode, html の削除、変更、追加
1701 * HTML の下は MIX_FIXED -> TextNode を <font> に置き換えてあるのでW3C DON 的に触ることができる
1704 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
1705 for( i = 0; i < l; ++i ){
1706 if( xnodes[ i ][ '_tag' ] ){
1707 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
1709 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
1711 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
1718 if( that[ '_flags' ] & X_NodeFlags_IE4_FIXED || that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_ELEMENT ){
1719 for( i = 0; i < l; ++i ){
1720 prev = X_Node__commitUpdate( xnodes[ i ], elm, prev, accumulatedFlags );
1725 for( i = 0; i < l; ++i ){
1726 html[ i ] = X_Node__actualCreate( xnodes[ i ], false );
1728 elm.innerHTML = html.join( '' );
1729 for( i = 0; i < l; ++i ){
1730 X_Node__afterActualCreate( xnodes[ i ] );
1732 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
1734 if( that[ '_flags' ] & X_NodeFlags_IE4_HAS_TEXTNODE ){
1735 dirty = dirty || false;
1736 for( i = 0; i < l; ++i ){
1738 if( text[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1739 text[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1743 if( dirty ) elm.innerHTML = that[ 'text' ]();
1746 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ) delete that[ '_fontSize' ];
1748 that[ '_flags' ] &= ~X_NodeFlags_DIRTY_POSITION;
1749 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1752 if( ( anime = that[ '_anime' ] ) && 6 <= anime.phase && anime.doScroll ){
1753 if( anime.phase === 6 ){
1754 v = anime.fromScrollX;
1758 anime.fromScrollX = elm.scrollLeft;
1760 v = anime.fromScrollY;
1764 anime.fromScrollY = elm.scrollTop;
1767 elm.scrollLeft = anime.scrollX;
1768 elm.scrollTop = anime.scrollY;
1777 * GPU レイヤーするブラウザは、子要素から変更を当てていく? <- とりあえず、親要素から。
1779 var X_Node__updateRawNode =
1781 ( function( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags ){
1782 var // flags = that[ '_flags' ],
1783 attrs, rename, k, v, f;
1786 if( !that[ '_tag' ] ){
1787 elm.data = X_String_chrReferanceTo( that[ '_text' ] );
1788 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1793 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ){
1795 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1796 elm.setAttribute( 'id', that[ '_id' ] ) :
1797 ( elm.id = that[ '_id' ] )
1799 ( elm.id && elm.removeAttribute( 'id' ) );
1802 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1803 that[ '_className' ] ?
1804 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1805 elm.setAttribute( 'class', that[ '_className' ] ) :
1806 ( elm.className = that[ '_className' ] )
1808 ( elm.className && elm.removeAttribute( X_UA[ 'IE' ] < 8 ? 'className' : 'class' ) ); // className は ie7-
1812 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1813 rename = X_Node_Attr_renameForDOM;
1818 switch( that[ '_tag' ] + k ){
1819 case 'TEXTAREAvalue' :
1820 // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので
1821 // MultipleIE6 でもここを通す。X_UA[ 'ieExeComError' ] の場合 MultipleIE6
1822 if( ( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ) || ( X_UA[ 'ieExeComError' ] && X_UA[ 'IE6' ] ) ){
1824 ( elm.firstChild.data = v || '' ) :
1825 elm.appendChild( document.createTextNode( v || '' ) );
1831 // http://outcloud.blogspot.jp/2010/09/iframe.html
1832 // この問題は firefox3.6 で確認
1833 if( X_UA[ 'Gecko' ] && elm.contentWindow ){
1834 elm.contentWindow.location.replace = elm.src = v || '';
1840 // http://d.hatena.ne.jp/NeoCat/20080921/1221940658
1841 // こちらに名前をsetしないとtargetが動作しない
1842 // これってあとから name を変更できないバグでは? itozyun
1843 // if( X_UA[ 'IE' ] ) elm.name = elm.contentWindow.name = v || '';
1846 //if( X_EMPTY_OBJECT[ k ] ) continue;
1847 // TODO IE では input, なぜか button, object も type, name の変更が出来ない、同値で置き換えようとしても不可
1849 elm.removeAttribute( rename[ k ] || k ) :
1850 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1851 elm.setAttribute( k, v ) :
1852 ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v )
1855 delete that[ '_newAttrs' ];
1858 if( accumulatedFlags & X_NodeFlags_IE8_OPACITY_FIX ){
1859 if( 0 <= currentOpcity ){
1861 that[ '_css' ].opacity = ie8AccumulatedOpcity;
1862 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1863 that[ '_flags' ] |= X_NodeFlags_OLD_CSSTEXT;
1865 if( !( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ) ){
1866 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;
1872 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1873 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1874 X_UA[ 'Opera78' ] || X_UA[ 'NN6' ] ?
1875 elm.setAttribute( 'style', that[ '_cssText' ] ) : // opera8用
1876 ( elm.style.cssText = that[ '_cssText' ] );
1878 elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要
1879 elm.removeAttribute( 'style' );
1882 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1883 v = X_Node_CSS_objToIEFilterText( that );
1885 elm.style.filter = v;
1886 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1888 elm.style.removeAttribute( 'filter' );
1889 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1894 * http://jsdo.it/esukei/imOL
1895 * IE8でのfilter:alpha継承
1896 * IE8でfilter:alphaの指定がposition:relative,position:absoluteの子要素に継承されない問題
1899 that[ '_css' ].opacity = currentOpcity;
1902 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1905 ( function( that, elm ){
1906 var attrs, rename, k, v;
1909 if( !that[ '_tag' ] ){
1910 elm.innerText = that[ '_text' ];
1911 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1916 * http://www.tohoho-web.com/js/element.htm
1917 * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる
1920 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ) elm.setAttribute( 'id', that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) );
1923 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1924 that[ '_className' ] ? ( elm.className = that[ '_className' ] ) : elm.removeAttribute( 'class' );
1927 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1928 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1929 elm.style.cssText = that[ '_cssText' ];
1931 elm.style.cssText = '';
1932 elm.removeAttribute( 'style' );
1935 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1936 v = X_Node_CSS_objToIEFilterText( that );
1938 elm.style.filter = v;
1939 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1941 elm.style.removeAttribute( 'filter' );
1942 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1947 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1948 rename = X_Node_Attr_renameForDOM;
1950 //if( X_EMPTY_OBJECT[ k ] ) continue;
1951 ( v = attrs[ k ] ) === undefined ?
1952 elm.removeAttribute( rename[ k ] || k ) :
1953 elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v );
1955 delete that[ '_newAttrs' ];
1958 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1962 /* --------------------------------------
1965 * http://d.hatena.ne.jp/uupaa/20080718/1216362040
1966 * DOM Rangeが使える環境(Firefox2+,Opera9+,Safari3+)なら、innerHTMLいらずで、ガーって書けます。
1967 * return document.createRange().createContextualFragment("<div><select><option></option></select></div>");
1968 * insertAdjacentHTML
1970 * ie7 以下では iframe の frameborder や、input name は、createElement 後に setAttribute しても無視される
1972 * fragument がある場合 children も足して
1973 * Mozilla: 1.0+, IE: 5.5+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+
1974 * ie6 大丈夫?fragment の場合リークしないか?チェックが必要
1975 * http://msdn.microsoft.com/ja-jp/library/bb250448%28v=vs.85%29.aspx
1977 * document.createElement of ie4 is only for OPTION & IMAGE.
1979 var X_Node__actualCreate =
1980 X_UA_DOM.IE4 && (function( that, isChild ){
1981 var uid = that[ '_uid' ],
1982 html, xnodes, n, i, l;
1984 if( !that[ '_tag' ] ){
1985 html = [ '<FONT id=ie4uid', uid, ' UID="', uid, '">', that[ '_text' ], '</FONT>' ];// fake textNode
1986 delete that[ '_rawObject' ];
1988 if( !isChild ) X_Node__actualRemove( that, /* true */ false );
1990 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true );
1993 '<', that[ '_tag' ], ' id=', ( that[ '_id' ] || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',
1994 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
1995 X_Node_Attr_objToAttrText( that, true ),
1996 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
2000 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ){
2002 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
2003 for( i = 0; i < l; ++i ){
2004 if( xnodes[ i ][ '_tag' ] ){
2005 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
2007 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
2009 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
2014 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_TEXTNODE ){
2016 html[ n ] = that[ 'text' ]();
2019 for( i = 0; i < l; ++i ){
2020 html[ n ] = X_Node__actualCreate( xnodes[ i ], true );
2023 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
2026 X_Dom_DTD_EMPTY[ that[ '_tag' ] ] || ( html[ n ] = '<\/' + that[ '_tag' ] + '>' );
2028 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR );
2031 return html.join( '' );
2034 var X_Node__afterActualCreate =
2035 X_UA_DOM.IE4 && (function( that ){
2038 if( !that[ '_tag' ] ) return that;
2040 if( ( xnodes = that[ '_xnodes' ] ) && ( i = xnodes.length ) ){
2042 X_Node__afterActualCreate( xnodes[ --i ] );
2045 // ネットワーク系属性と filter は要素生成後に適用
2046 if( that[ '_flags' ] & ( X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_IE_FILTER ) ){
2047 X_Node__updateRawNode( that, that[ '_rawObject' ] || X_Node__ie4getRawNode( that ) );
2049 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
2051 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
2054 var X_Node__actualRemove =
2056 // GPUレイヤーにいるうちは remove しない。-> GPU解除してから remove する
2057 // Firefox34 では遭遇せず、Safari で何度かアニメーションしているうちに発生
2058 ( function( that, isChild ){
2059 var xnodes = that[ '_xnodes' ],
2060 elm = that[ '_rawObject' ],
2063 if( xnodes && ( l = xnodes.length ) ){
2064 for( i = 0; i < l; ++i ){
2065 child = xnodes[ i ];
2066 child[ '_tag' ] && X_Node__actualRemove( child, true );
2072 if( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ){
2073 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2074 that[ '_flags' ] &= ~X_NodeFlags_ACTUAL_LISTENING;
2077 // ie5では filter の効いている要素をremove時に破棄して、再度append 時に新規生成する
2078 // ちなみに elm.filters に触ると ie8 でなぜかカラム落ちが発生、、、
2079 if( X_Node_displayNoneFixForIE5 ){
2080 if( elm.filters && elm.filters.length ){
2082 delete that[ '_rawObject' ];
2083 // 破棄前にインタラクティブな属性値を控える
2084 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2085 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2086 that[ '_attrs' ].value = elm.value;
2088 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2089 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2090 that[ '_attrs' ].selected = elm.selected;
2092 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2093 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2094 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2096 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2097 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2098 that[ '_attrs' ].checked = elm.checked;
2105 if( !X_UA[ 'MacIE' ] ){
2106 // elm.parentNode.tagName for ie7
2107 !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );
2109 !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that );
2113 ( function( that, isChild ){
2114 var xnodes = that[ '_xnodes' ],
2115 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
2117 if( xnodes && ( l = xnodes.length ) ){
2118 for( i = 0; i < l; ++i ){
2119 X_Node__actualRemove( xnodes[ i ], true );
2124 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2126 // 破棄前にインタラクティブな属性値を控える
2127 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2128 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2129 that[ '_attrs' ].value = elm.value;
2131 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2132 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2133 that[ '_attrs' ].selected = elm.selected;
2135 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2136 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2137 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2139 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2140 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2141 that[ '_attrs' ].checked = elm.checked;
2144 elm.removeAttribute( 'id' ); // ?
2145 //document.all[ that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) ] = null; // MacIE5 でエラー
2146 if( !isChild ) elm.outerHTML = ''; // elm.remove() ?
2147 delete that[ '_rawObject' ];
2151 X_ViewPort[ 'listenOnce' ]( X_EVENT_UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );