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 'createRange' : X_Node_createRange,
258 'clone' : X_Node_clone,
260 'append' : X_Node_append,
262 'appendAt' : X_Node_appendAt,
264 'appendTo' : X_Node_appendTo,
266 'prev' : X_Node_prev,
268 'next' : X_Node_next,
270 'swap' : X_Node_swap,
272 'remove' : X_Node_remove,
274 'empty' : X_Node_empty,
276 'contains' : X_Node_contains,
278 'getChildAt' : X_Node_getChildAt,
280 'numChildren' : X_Node_numChildren,
282 'firstChild' : X_Node_firstChild,
284 'lastChild' : X_Node_lastChild,
286 'getOrder' : X_Node_getOrder,
288 'className' : X_Node_className,
289 'addClass' : X_Node_addClass,
290 'removeClass' : X_Node_removeClass,
291 'toggleClass' : X_Node_toggleClass,
292 'hasClass' : X_Node_hasClass,
294 'html' : X_Node_html,
295 'text' : X_Node_text,
296 'call' : X_Node_call,
302 var X_NodeType_XNODE = 1,
303 X_NodeType_RAW_HTML = 2,
304 X_NodeType_RAW_TEXT = 3,
305 X_NodeType_HTML_STRING = 4,
306 X_NodeType_STRING = 5,
308 X_NodeType_XNODE_LIST = 7,
309 X_NodeType_WINDOW = 8,
310 X_NodeType_DOCUMENT = 9,
311 X_NodeType_IMAGE = 10,
313 X_Node_strictElmCreation = !X_UA[ 'MacIE' ] && X_UA[ 'IE' ] <= 8,
315 X_Node_documentFragment = document.createDocumentFragment && ( !X_UA[ 'IE' ] || 5.5 <= X_UA[ 'IE' ] ) && document.createDocumentFragment(),
317 // 子の生成後に リアル文書 tree に追加する
318 X_Node_addTreeAfterChildren = !( X_UA[ 'IE' ] < 9 ),
320 X_Node_displayNoneFixForIE5 = !!X_NodeFlags_IE5_DISPLAY_NONE_FIX,
322 X_Node_newByTag = false,
324 X_Node_newByText = false,
326 X_Node_outerXNode = null,
328 X_Node_updateTimerID = 0,
331 X_Node_isXmlDocument =
335 if( X_Type_isBoolean( root.isXML ) ) return root.isXML;
336 return root.isXML = root[ '_rawObject' ].createElement( 'p' ).tagName !== root[ '_rawObject' ].createElement( 'P' ).tagName;
339 X_Node_none = X_Node_CHASHE[ 0 ] = Node(),
340 X_Node_html, // = <html>
341 X_Node_head, // = <head>
342 X_Node_body, // = <body>
343 X_Node_systemNode, // = X_Node_CHASHE[ ? ]
347 * X_Node_reserveRemoval = [] に追加。commitUpdate で remove
349 * X_Node_reserveRemoval にいたら消す, new_parent[ '_xnodes' ] に挿入
351 X_Node_reserveRemoval = [];
353 function X_Node_getType( v ){
354 if( v === '' ) return X_NodeType_STRING;
356 if( v === window ) return X_NodeType_WINDOW;
357 if( v === document ) return X_NodeType_DOCUMENT;
358 if( v.constructor === Node ) return X_NodeType_XNODE;
359 if( v.constructor === X_NodeList ) return X_NodeType_XNODE_LIST;
360 if( X_Type_isHTMLElement( v ) ) return X_NodeType_RAW_HTML;
361 if( v.nodeType === 3 ) return X_NodeType_RAW_TEXT;
362 if( X_Type_isString( v ) ){
363 return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? X_NodeType_HTML_STRING : X_NodeType_STRING;
365 if( v[ 'instanceOf' ] && v[ 'instanceOf' ]( Node ) ) return X_NodeType_XNODE;
368 function X_Node_getXNode( v ){
369 var uid, i, chashe, xnode;
370 switch( X_Node_getType( v ) ){
371 case X_NodeType_XNODE :
372 case X_NodeType_XNODE_LIST :
374 case X_NodeType_RAW_HTML :
375 // fake TextNode too.
377 uid = v.getAttribute( 'UID' );
378 return uid && X_Node_CHASHE[ uid ];
380 return v[ 'UID' ] && X_Node_CHASHE[ v[ 'UID' ] ];
381 case X_NodeType_WINDOW :
383 case X_NodeType_DOCUMENT :
384 return X_ViewPort_document;
385 case X_NodeType_RAW_TEXT :
386 if( v[ 'UID' ] ) return X_Node_CHASHE[ v[ 'UID' ] ];
387 for( chashe = X_Node_CHASHE, i = chashe.length; i; ){
388 if( ( xnode = chashe[ --i ] ) && ( xnode[ '_rawObject' ] === v ) ) return xnode;
393 function X_Node_getRoot( xnode ){
394 return X_ViewPort_document;
395 //return X_Node_body[ '_rawObject' ].documentElement ? node : node.ownerDocument || node.document;
399 // TODO document.all[ uid ] -> document[ uid ]
400 var X_Node__ie4getRawNode = X_UA_DOM.IE4 && function ( that ){
401 return that[ '_rawObject' ] ||
402 ( that[ '_rawObject' ] = document.all[ 'ie4uid' + that[ '_uid' ] ] || that[ '_id' ] && document.all[ that[ '_id' ] ] );
406 function X_Node_toggleInTreeFlag( xnodes, flag ){
407 var i = xnodes.length, xnode;
409 xnode = xnodes[ --i ];
410 flag ? ( xnode[ '_flags' ] |= X_NodeFlags_IN_TREE | X_NodeFlags_DIRTY_POSITION ) : ( xnode[ '_flags' ] &= ~X_NodeFlags_IN_TREE & ~X_NodeFlags_IE5_DISPLAY_NONE_FIX );
411 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( xnode[ '_xnodes' ], flag );
415 function X_Node_toggleInGPUFlag( gpuRoot, xnodes, flag ){
416 var i = xnodes.length, xnode;
420 xnode = xnodes[ --i ];
421 if( !xnode[ '_gpuParent' ] ){
422 xnode[ '_flags' ] |= X_NodeFlags_GPU_CHILD;
423 xnode[ '_gpuParent' ] = gpuRoot;
424 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
429 xnode = xnodes[ --i ];
430 if( xnode[ '_gpuParent' ] === gpuRoot ){
431 xnode[ '_flags' ] &= ~X_NodeFlags_GPU_CHILD;
432 delete xnode[ '_gpuParent' ];
433 xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
440 * タグ名等を指定して新規に子ノードを作成し、現在のノードに追加する。
441 * @alias Node.prototype.create
442 * @param {string} [tag] タグ名
443 * @param {object} [opt_attrs=] 属性
444 * @param {object|string} [opt_css=] css
445 * @return {Node} 新規作成されたノード
446 * @example var child = parent.create( 'div' );
448 function X_Node_create( tag, opt_attrs, opt_css ){
451 if( !this[ '_tag' ] ) return;
452 this[ 'append' ]( xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
456 * 挿入位置とタグ名等を指定して新規に子ノードを作成し、現在のノードに挿入する。
457 * @alias Node.prototype.createAt
458 * @param {number} [index] 挿入位置
459 * @param {string} [tag] タグ名
460 * @param {object} [opt_attrs=] 属性
461 * @param {object|string} [opt_css=] css
462 * @return {Node} 新規作成されたノード
463 * @example var child = parent.create( 2, 'div' );
465 function X_Node_createAt( index, tag, opt_attrs, opt_css ){
467 if( !this[ '_tag' ] ) return;
468 this[ 'appendAt' ]( index, xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
473 * テキストを指定して新規にテキストノードを作成し、現在のノードに挿入する。
474 * @alias Node.prototype.createText
475 * @param {string} [tag] テキスト
476 * @return {Node} 新規作成されたノード
478 function X_Node_createText( text ){
480 if( !this[ '_tag' ] ) return;
481 this[ 'append' ]( xnode = X_Doc_createText( text ) );
485 * 挿入位置とテキストを指定して新規に子ノードを作成し、現在のノードに挿入する。
486 * @alias Node.prototype.createTextAt
487 * @param {number} [index] 挿入位置
488 * @param {string} [tag] テキスト
489 * @return {Node} 新規作成されたノード
491 function X_Node_createTextAt( index, text ){
493 if( !this[ '_tag' ] ) return;
494 this[ 'appendAt' ]( index, xnode = X_Doc_createText( text ) );
499 * 選択されたテキストへの参照やテキスト座標情報
500 * @alias Node.prototype.createRange
501 * @return {TextRange} 新規作成されたテキストレンジ
503 function X_Node_createRange( a, b, c ){
504 return X_TextRange( this, a, b, c );
508 * Node のクローンを作成し返す。id もクローンされる点に注意。イベントリスナはクローンされない。
509 * http://d.hatena.ne.jp/think49/20110724/1311472811
510 * http://d.hatena.ne.jp/uupaa/20100508/1273299874
511 * @alias Node.prototype.clone
512 * @param {boolean} [opt_clone_children] 子要素のクローンを行うか?
515 function X_Node_clone( opt_clone_children ){
516 var xnode, xnodes, i, l;
518 if( this[ '_tag' ] ){
519 X_Node_newByTag = true;
520 xnode = Node( this[ '_tag' ], X_Object_copy( this[ '_attrs' ] ), X_Object_copy( this[ '_css' ] ) )
521 [ 'attr' ]( { 'id' : this[ '_id' ] } )
522 [ 'className' ]( this[ '_className' ] );
524 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
525 xnode[ '_flags' ] |= X_NodeFlags_IS_SVG;
527 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
528 xnode[ '_flags' ] |= X_NodeFlags_IS_VML;
531 if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
532 for( i = 0; i < l; ++i ){
533 xnode[ 'append' ]( xnodes[ i ][ 'clone' ]( true ) );
538 X_Node_newByText = true;
539 return Node( this[ '_text' ] );
543 * ノードを子配列の最後に追加する。文字列が渡された場合、HTMLパーサーによって Node ツリーを作成して追加する。HtmlElement, TextNode の場合は内部使用専用。
544 * @alias Node.prototype.append
545 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
546 * @return {Node} 自身。チェインメソッド
548 * myNode.append( node );
549 * myNode.append( node, '<span>Hello,</span>', 'world.' );
551 function X_Node_append( v ){
552 var i, l, xnodes, frg;
553 if( !this[ '_tag' ] ) return;
555 if( 1 < ( l = arguments.length ) ){
556 for( i = 0; i < l; ++i ){
557 this[ 'append' ]( arguments[ i ] );
562 if( !( xnodes = this[ '_xnodes' ] ) ) this[ '_xnodes' ] = xnodes = [];
564 switch( X_Node_getType( v ) ){
565 case X_NodeType_RAW_HTML :
566 case X_NodeType_RAW_TEXT :
569 case X_NodeType_HTML_STRING :
570 case X_NodeType_STRING :
571 return X_Node_append.apply( this, X_HtmlParser_parse( v, true ) );
572 case X_NodeType_XNODE :
573 // 親の xnodes から v を消す
574 if( v.parent === this && xnodes[ xnodes.length - 1 ] === v ) return this;
576 // IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
577 if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
584 xnodes[ xnodes.length ] = v;
585 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
586 v[ '_flags' ] |= X_NodeFlags_IN_TREE;
587 v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
588 X_Node_reserveUpdate();
590 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
591 v[ '_flags' ] |= X_NodeFlags_IS_SVG;
593 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
594 v[ '_flags' ] |= X_NodeFlags_IS_VML;
601 * @alias Node.prototype.appendAt
602 * @param {number} index 挿入位置 0以上
603 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
604 * @return {Node} 自身。チェインメソッド
605 * @example myNode.appendAt( 1, node );
607 function X_Node_appendAt( start, v ){
610 if( !this[ '_tag' ] ) return this;
612 l = arguments.length;
613 if( !( xnodes = this[ '_xnodes' ] ) ) xnodes = this[ '_xnodes' ] = [];
615 if( xnodes.length <= start ){
616 if( l === 2 ) return this[ 'append' ]( v );
617 for( i = 1; i < l; ++i ){
618 this[ 'append' ]( arguments[ i ] );
622 if( start < 0 ) start = 0;
625 this[ 'appendAt' ]( start, arguments[ --l ] );
630 switch( X_Node_getType( v ) ){
631 case X_NodeType_RAW_HTML :
632 case X_NodeType_RAW_TEXT :
635 case X_NodeType_HTML_STRING :
636 case X_NodeType_STRING :
637 v = X_HtmlParser_parse( v, true );
638 for( i = v.length; i; ){
639 this[ 'appendAt' ]( start, v[ --i ] );
642 case X_NodeType_XNODE :
643 // 親の xnodes から v を消す
645 if( v.parent === this ){
646 i = v[ 'getOrder' ]();
647 if( i === start ) return this;
648 if( i < start ) --start;
652 // IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
653 if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
660 this[ '_xnodes' ].splice( start, 0, v );
661 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
662 v[ '_flags' ] |= X_NodeFlags_IN_TREE;
663 v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
664 X_Node_reserveUpdate();
666 if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
667 v[ '_flags' ] |= X_NodeFlags_IS_SVG;
669 if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
670 v[ '_flags' ] |= X_NodeFlags_IS_VML;
676 * ノードを親に追加する。戻り値は子ノードなので、続けて操作が出来る。
677 * @alias Node.prototype.appendTo
678 * @param {Node|string|HTMLElement} [parent] HTMLElement は内部のみ。
679 * @param {number} [opt_index=-1] 挿入位置。省略した場合は最後に追加する。
680 * @return {Node} 自身。チェインメソッド
681 * @example childNode.appendTo( parentNode, 1 );
683 function X_Node_appendTo( parent, opt_index ){
684 switch( X_Node_getType( parent ) ){
685 case X_NodeType_RAW_HTML :
686 parent = Node( parent );
688 case X_NodeType_HTML_STRING :
689 parent = X_HtmlParser_parse( parent, true );
690 parent = parent[ 0 ] || parent;
691 case X_NodeType_XNODE :
696 X_Type_isFinite( opt_index ) ? parent[ 'appendAt' ]( opt_index, this ) : parent[ 'append' ]( this );
702 * ノードの直前の要素を取得。または直前に挿入。挿入する要素が先にいる兄弟でも正しく動作する。
703 * @alias Node.prototype.prev
704 * @param {Node|string|HTMLElement|TextNode} [...v] HTMLElement と TextNode は内部のみ。
705 * @return {Node} 自身。チェインメソッド
706 * @example childNode.prev( prevNode );
708 function X_Node_prev( v ){
709 var parent = this.parent, xnodes, i, l;
712 if( v === undefined ){
713 if( !parent ) return;
714 xnodes = parent[ '_xnodes' ];
715 i = xnodes.indexOf( this );
716 return 0 < i ? xnodes[ i - 1 ] : v;
719 if( !parent ) return this;
721 l = arguments.length;
723 for( i = 0; l; ++i ){
724 parent[ 'appendAt' ]( this[ 'getOrder' ]() - i, arguments[ --l ] );
728 parent[ 'appendAt' ]( this[ 'getOrder' ](), v );
733 * ノードの直後の要素を取得。または直後に挿入。挿入する要素が先にいる兄弟でも正しく動作する。
734 * @alias Node.prototype.next
735 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
736 * @return {Node} 自身。チェインメソッド
737 * @example childNode.next( prevNode );
739 function X_Node_next( v ){
740 var parent = this.parent, xnodes, i, l, start;
743 if( v === undefined ){
744 if( !parent ) return;
745 xnodes = parent[ '_xnodes' ];
746 i = xnodes.indexOf( this );
747 return ++i < xnodes.length ? xnodes[ i ] : v;
750 if( !parent ) return this;
752 l = arguments.length;
753 start = this[ 'getOrder' ]() + 1;
755 if( parent[ '_xnodes' ].length <= start ){
756 for( i = 0; i < l; ++i ){
757 parent[ 'append' ]( arguments[ i ] );
762 parent[ 'appendAt' ]( this[ 'getOrder' ]() + 1, arguments[ --l ] );
765 parent[ 'appendAt' ]( start, v );
771 * 要素の入れ替え。自身は remove() される。
772 * @alias Node.prototype.swap
773 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
774 * @return {Node} 自身。チェインメソッド
775 * @example node.swap( newNode );
777 function X_Node_swap( v ){
778 if( !this.parent ) return this;
779 return arguments.length === 1 ? this[ 'prev' ]( v )[ 'remove' ]() : X_Node_prev.apply( this, arguments )[ 'remove' ]();
783 * 要素を親要素から抜く。jQuery の remove と異なり、インスタンスは破壊(kill)されず、再び別の親に挿入等できる
784 * @alias Node.prototype.remove
785 * @return {Node} 自身。チェインメソッド
786 * @example node.remove();
787 * parent.append( node ); 新しい親に追加できる
789 function X_Node_remove(){
790 var parent = this.parent,
793 if( !parent ) return this;
796 if( this[ '_anime' ] && this[ '_anime' ].phase ){
797 console.log( 'Animation 中の REMOVE' );
798 X_NodeAnime_stopNow( this );
804 parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( this ), 1 );
806 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
807 this[ '_flags' ] &= ~X_NodeFlags_IN_TREE & ~X_NodeFlags_IE5_DISPLAY_NONE_FIX;
808 this[ '_xnodes' ] && X_Node_toggleInTreeFlag( this[ '_xnodes' ], false );
811 if( elm = this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ){
812 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
813 X_Node_reserveUpdate();
815 if( !this[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
816 parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
819 elm = this[ '_rawObject' ];
820 if( elm && elm.parentNode && elm.parentNode.tagName ){
821 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
822 X_Node_reserveUpdate();
827 elm = this[ '_rawObject' ];
828 if( elm && elm.parentNode && elm.parentNode.tagName ){
829 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
830 X_Node_reserveUpdate();
838 * 子要素を破棄する。子要素は kill() されます。
839 * @alias Node.prototype.empty
840 * @return {Node} 自身。チェインメソッド
841 * @example node.empty();
843 function X_Node_empty(){
844 var xnodes = this[ '_xnodes' ], i;
846 if( xnodes && ( i = xnodes.length ) ){
847 delete this[ '_xnodes' ];
849 xnodes[ --i ][ 'kill' ]();
856 function X_Node_onKill( that ){
857 var parent = that.parent,
858 xnodes = that[ '_xnodes' ], i, elm;
860 if( ( that[ '_flags' ] & X_NodeFlags_EXIST ) === 0 ) return;
862 parent && parent[ '_xnodes' ] && parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( that ), 1 );
864 if( xnodes && ( i = xnodes.length ) ){
865 delete that[ '_xnodes' ];
867 xnodes[ --i ][ 'kill' ]();
872 X_Node_CHASHE[ that[ '_uid' ] ] = null; // array に対して delete X_Node_CHASHE[ uid ] はまずい!
874 if( that[ '_anime' ] && that[ '_anime' ].phase ){
875 console.log( 'Animation 中の KILL' );
876 X_NodeAnime_stopNow( that );
879 elm = that[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( that );
884 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
885 X_Node_reserveUpdate();
887 if( !that[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
888 parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
891 if( elm && elm.parentNode && elm.parentNode.tagName ){
892 X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
893 X_Node_reserveUpdate();
903 * @alias Node.prototype.contains
904 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。
906 * @example node.contains( testNode );
908 function X_Node_contains( v ){
911 if( !v || !this[ '_tag' ] || this === v ) return false;
913 xnodes = this[ '_xnodes' ];
914 if( !xnodes || !xnodes.length ) return false;
916 while( v = v[ 'parent' ] ){
917 if( this === v ) return true;
924 * @alias Node.prototype.getChildAt
925 * @param {number} index 取得する子ノードの位置。0~
927 * @example child1 = parent.getChildAt(1);
929 function X_Node_getChildAt( i ){
930 var xnodes = this[ '_xnodes' ];
931 return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ];
936 * @alias Node.prototype.numChildren
937 * @return {number} 子要素の数。
938 * @example n = parent.numChildren();
940 function X_Node_numChildren(){
941 var xnodes = this[ '_xnodes' ];
942 return xnodes ? xnodes.length : 0;
947 * @alias Node.prototype.firstChild
948 * @return {Node} 最初の子要素
949 * @example child0 = parent.firstChild();
951 function X_Node_firstChild(){
952 return this[ '_xnodes' ] && this[ '_xnodes' ][ 0 ];
957 * @alias Node.prototype.lastChild
958 * @return {Node} 最後の子要素
959 * @example lastChild = parent.lastChild();
961 function X_Node_lastChild(){
962 var xnodes = this[ '_xnodes' ];
963 return xnodes && xnodes[ xnodes.length - 1 ];
968 * @alias Node.prototype.getOrder
969 * @return {number} index -1 の場合、親を持たない。
970 * @example index = node.getOrder();
972 function X_Node_getOrder(){
973 var parent = this.parent;
974 return this === X_Node_html ?
977 parent[ '_xnodes' ].indexOf( this ) :
983 * @alias Node.prototype.className
984 * @return {string|Node} getter の場合 class 文字列、setter の場合自身。
986 * className = node.className();
988 * node.className( 'myClass myClass_new' );
990 function X_Node_className( v ){
993 if( v === undefined ) return this[ '_className' ];
996 if( this[ '_className' ] === v ) return this;
997 if( !v || !X_Type_isString( v ) ){
998 delete this[ '_className' ];
1003 while( v.indexOf( __ ) !== -1 ){ v = v.split( __ ).join( _ ); };
1004 v.charAt( 0 ) === _ && ( v = v.substr( 1 ) );
1005 v.lastIndexOf( _ ) === 0 && ( v = v.substr( 0, v.length - 1 ) );
1007 if( this[ '_className' ] === v ) return this;
1008 v ? ( this[ '_className' ] = v ) : delete this[ '_className' ];
1010 this[ '_flags' ] |= X_NodeFlags_DIRTY_CLASSNAME;
1011 this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
1017 * @alias Node.prototype.addClass
1018 * @param {string} className スペース区切りで複数のクラスを追加できる。
1019 * @return {Node} 自身。
1020 * @example node.addClass( 'myClass myClass_new' );
1022 function X_Node_addClass( v ){
1023 var names = v.split( ' ' ),
1025 _class = this[ '_className' ],
1029 name = names[ --i ];
1030 if( !name ) continue;
1031 !this[ 'hasClass' ]( name ) && ( v += ( v ? ' ' : '' ) + name );
1033 return v ? this[ 'className' ]( ( _class ? _class + ' ' : '' ) + v ) : this;
1038 * @alias Node.prototype.removeClass
1039 * @param {string} className スペース区切りで複数のクラスを削除できる。
1040 * @return {Node} 自身。
1041 * @example node.removeClass( 'myClass myClass_new' );
1043 function X_Node_removeClass( v ){
1045 _class = this[ '_className' ],
1046 names = v.split( _ ),
1047 classNames, i, f, j;
1049 if( !_class ) return this;
1050 for( classNames = _class.split( _ ), i = classNames.length; i; ){
1051 _class = classNames[ --i ];
1052 for( j = names.length; j; ){
1053 if( _class === names[ --j ] ){
1054 classNames.splice( i, 1 );
1055 names.splice( j, 1 );
1061 return f ? this[ 'className' ]( classNames.join( _ ) ) : this;
1066 * @alias Node.prototype.toggleClass
1067 * @param {string} className スペース区切りで複数のクラスを削除できる。
1068 * @param {boolean} [opt_toggle=] true はクラスの追加。false はクラスの削除。undefined はクラスのトグル。
1069 * @return {Node} 自身。
1070 * @example node.toggleClass( 'myClass myClass_new', !!n );
1072 function X_Node_toggleClass( v, opt_toggle ){
1074 if( opt_toggle !== undefined ){
1075 return !opt_toggle ? this[ 'removeClass' ]( v ) : this[ 'addClass' ]( v );
1077 names = v.split( ' ' );
1078 for( i = names.length; i; ){
1079 name = names[ --i ];
1080 this[ 'hasClass' ]( name ) ? this[ 'removeClass' ]( name ) : this[ 'addClass' ]( name );
1087 * @alias Node.prototype.hasClass
1088 * @param {string} className スペース区切りで複数のクラスを削除できる。
1090 * @example node.hasClass( 'myClass myClass_new' );
1092 function X_Node_hasClass( v ){
1094 _class = this[ '_className' ],
1096 if( _class === v ) return true;
1097 if( !_class ) return false;
1099 _class = _ + _class + _;
1100 if( _class.indexOf( _ + v + _ ) !== -1 ) return true; // lucky hit
1102 for( v = v.split( _ ), i = v.length; i; ){
1104 if( name === '' ) continue;
1105 if( _class.indexOf( _ + name + _ ) === -1 ) return false;
1111 * innerHTML 取得・設定。outerHTML が欲しい場合は、xnode.call('outerHTML') とできる。
1112 * @alias Node.prototype.html
1113 * @param {string} [html=] html文字列
1114 * @return {string|Node}
1115 * @example node.html( '<img>' );
1117 function X_Node_html( html ){
1118 var _ = '', q = '"', xnodes, n, i, l;
1120 if( html !== undefined ){ // String 以外に Number や false null なども許可
1121 if( !this[ '_tag' ] ) return this[ 'text' ]( html );
1125 X_Node_append.apply( this, X_HtmlParser_parse( html, true ) );
1131 if( !this[ '_tag' ] ){
1132 return this[ '_text' ];
1135 this[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( this );
1137 html = !X_Node_outerXNode ? [] : [
1138 '<', this[ '_tag' ],
1139 this[ '_id' ] ? ' id="' + this[ '_id' ] + q : _,
1140 this[ '_className' ] ? ' class="' + this[ '_className' ] + q : _,
1141 this[ '_flags' ] & X_NodeFlags_OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( this ) : this[ '_attrText' ],
1142 this[ '_cssText' ] ? ' style="' + this[ '_cssText' ] + q : _,
1146 if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
1147 if( !X_Node_outerXNode ) X_Node_outerXNode = this;
1148 for( i = 0; i < l; ++i ){
1149 html[ n ] = xnodes[ i ][ 'html' ]();
1152 if( X_Node_outerXNode === this ) X_Node_outerXNode = null;
1154 !X_Node_outerXNode || X_Dom_DTD_EMPTY[ this[ '_tag' ] ] || ( html[ n ] = '<\/' + this[ '_tag' ] + '>' );
1155 return html.join( _ );
1159 * null が来たら '', 数値等が来たら文字列化
1162 * textContent 取得・設定。null が来たら '', 数値等が来たら文字列化
1163 * @alias Node.prototype.text
1164 * @param {string} [text=]
1165 * @return {string|Node}
1166 * @example node.text( 'Hello, world!' );
1168 function X_Node_text( text ){
1169 var xnodes, texts, i, l;
1171 if( text !== undefined ){
1172 if( text === null ) text = '';
1175 if( !this[ '_tag' ] ){
1176 if( this[ '_text' ] !== text ){
1177 text ? ( this[ '_text' ] = text ) : delete this[ '_text' ];
1178 this[ '_flags' ] |= X_NodeFlags_DIRTY_CONTENT;
1179 this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
1183 if( ( xnodes = this[ '_xnodes' ] ) && xnodes.length === 1 && !xnodes[ 0 ][ '_tag' ] ){
1184 xnodes[ 0 ][ 'text' ]( text );
1187 // TODO 一つのtextnode を残すケース 完全に削除したい場合は empty()を使う
1188 if( !text ) return this[ 'empty' ]();
1189 this[ 'empty' ]()[ 'createText' ]( text );
1193 if( this[ '_tag' ] ){
1194 if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
1195 for( texts = [], i = 0; i < l; ++i ){
1196 texts[ i ] = xnodes[ i ][ 'text' ]();
1198 return texts.join( '' );
1202 return this[ '_text' ];
1206 * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。
1207 * @alias Node.prototype.call
1208 * @param {string} [name] 要素の関数名
1210 * @example node.call( 'focus' );
1212 function X_Node_call( name /*, opt_args... */ ){
1213 var args = arguments,
1214 l = args.length - 1,
1215 v, raw, parent, body,
1216 child, childX, childY, childW, childH,
1218 parentSX, parentSY, parentSW, parentSH,
1219 visibleX, visibleY, visibleW, visibleH,
1220 visiblePartX, visiblePartY, func, args, params, i;
1224 return !!( this[ '_flags' ] & X_NodeFlags_IS_SVG );
1226 return !!( this[ '_flags' ] & X_NodeFlags_IS_VML );
1228 return this[ '_tag' ] ? 1 : 3;
1230 X_Node_outerXNode = X_Node_body; // == true ならなんでもよい。型を合わすために xbody にしている
1231 v = this[ 'html' ]();
1232 X_Node_outerXNode = null;
1234 case 'treeIsDirty' :
1235 return !!X_Node_updateTimerID;
1237 return ( this[ '_flags' ] & X_NodeFlags_IN_TREE ) ? X_Node_CSS_getCharSize( this ) : 0;
1239 return !!( this[ '_flags' ] & ( X_NodeFlags_GPU_NOW | X_NodeFlags_GPU_RELEASE_RESERVED ) );
1241 if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){
1243 while( parent = parent.parent ){
1244 if( parent[ '_flags' ] & ( X_NodeFlags_GPU_NOW | X_NodeFlags_GPU_RELEASE_RESERVED ) ) return true;
1251 case 'canAnimateNow' :
1252 return ( this[ '_flags' ] & X_NodeFlags_IN_TREE ) && X_NodeAnime_detectWaitAnimation( this, true, true ) === 6;
1254 return this[ '_anime' ] ? this[ '_anime' ].phase : 0;
1255 case 'animeProgress' :
1256 return this[ '_anime' ] && this[ '_anime' ].phase === 7 ? this[ '_anime' ].progress : 0;
1259 X_Node_updateTimerID && X_Node_startUpdate();
1261 raw = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this );
1265 if( name === 'scrollTo' ){
1266 raw.scrollLeft = args[ 1 ] || 0;
1267 raw.scrollTop = args[ 2 ] || 0;
1271 if( name === 'inView' ){
1272 if( !( this[ '_flags' ] & X_NodeFlags_IN_TREE ) ) return { 'isInView' : false };
1275 visibleX = visibleY = visibleW = visibleH = 0;
1276 while( child !== body ){
1277 parent = child.parentNode || child.parentElement;
1278 parentH = parent.clientHeight;
1279 parentW = parent.clientWidth;
1280 parentSW = parent.scrollHeight;
1281 parentSH = parent.scrollWidth;
1283 if( parentH < parentSH || parentW < parentSW ){
1284 childX = child.offsetLeft + visibleX;
1285 childY = child.offsetTop + visibleY;
1286 childW = visibleW || child.offsetWidth;
1287 childH = visibleH || child.offsetHeight;
1288 parentSX = parent.scrollLeft;
1289 parentSY = parent.scrollTop;
1291 if( parentSY < childY + childH &&
1292 childY < parentSY + parentH &&
1293 parentSX < childX + childW &&
1294 childX < parentSX + parentW ){
1296 // right:子の左側が見えている left:子の左側が見えている both:完全に見えている
1298 childX < parentSX ? 'right' :
1299 ( parentSX + parentW ) < ( childX + childW ) ? 'left' : 'both';
1301 childY < parentSY ? 'bottom' :
1302 ( parentSY + parentH ) < ( childY + childH ) ? 'top' : 'both';
1305 visibleX = visiblePartX === 'right' ? 0 : childX - parentSX;
1306 visibleY = visiblePartX === 'bottom' ? 0 : childY - parentSY;
1308 visiblePartX === 'both' ? childW :
1309 visiblePartX === 'right' ? ( parentSX + parentW - childX ) : ( childX + childW - parentSX );
1311 visiblePartY === 'both' ? childH :
1312 visiblePartY === 'bottom' ? ( parentSY + parentH - childY ) : ( childY + childH - parentSY );
1314 return { 'isInView' : false };
1319 return { 'isInView' : true };
1323 if( X_Type_isFunction( func ) ){
1325 args = X_Array_copy( args );
1327 return func.apply( raw, args );
1329 return raw[ name ]();
1331 if( X_UA[ 'IE' ] < 9 && ( X_Type_isUnknown( func ) || X_Type_isObject( func ) ) ){
1332 // typeof func === unknown に対策
1333 // http://la.ma.la/blog/diary_200509031529.htm
1335 args = X_Array_copy( args );
1339 for( i = 0; i < l; ++i ){
1340 params[ i ] = '_' + i;
1342 params = params.join( ',' );
1345 [ 'return this.', name, '(', params, ')' ].join( '' )
1346 ).apply( raw, args );
1348 return raw[ name ]();
1353 * xnode を this として関数を実行する。 NodeList.each と動作を合わせてあるため関数の戻り値は破棄される。
1356 function X_Node_each( func /*, opt_args */ ){
1358 if( 1 < arguments.length ){
1359 args = X_Array_copy( arguments );
1361 func.apply( this, args );
1363 func.call( this, 0 );
1369 /* --------------------------------------
1370 * Async commit update
1372 * TODO Timer や DOM イベントの呼び出しの最後に、まだ一度も commitUpdate していないなら commitUpdate してしまう。
1375 function X_Node_reserveUpdate(){
1376 if( !X_Node_updateTimerID ) X_Node_updateTimerID = X_Timer_requestFrame( X_Node_startUpdate );
1379 var X_Node_updateReservedByReleaseGPU = false;
1381 function X_Node_startUpdate( time ){
1382 var removal, i, xnodeOrElm, xnodesIEFilterFixAfter, xnode;
1384 if( !X_Node_updateTimerID || X_ViewPort_readyState < X_EVENT_INIT ){
1388 X_Timer_cancelFrame( X_Node_updateTimerID );
1389 X_Node_updateTimerID = 0;
1392 // X.Timer 経由でないと発火しない このイベントでサイズを取ると無限ループに
1393 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE );
1396 removal = X_Node_reserveRemoval;
1398 if( i = removal.length ){
1400 xnodeOrElm = removal[ --i ];
1401 // TODO GPU レイヤーの子の場合、remove をスキップする。 非GPU レイヤーへ apppend される場合、clone する?
1402 // GPU レイヤーを削除する場合、cssText = '' して GPU レイヤーを解除する
1403 if( !xnodeOrElm[ 'instanceOf' ] ){
1405 xnodeOrElm.removeAttribute( 'id' ); // ?
1406 xnodeOrElm.outerHTML = ''; // xnodeOrElm.remove() ?
1408 if( !X_UA[ 'MacIE' ] ){
1409 // elm.parentNode.tagName for ie7
1410 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && xnodeOrElm.parentNode.removeChild( xnodeOrElm );
1412 xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && X_TEMP._fixed_remove( xnodeOrElm, that );
1416 X_Node__actualRemove( xnodeOrElm );
1423 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = 'hidden' );
1425 if( X_Node_html[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1426 X_Node__commitUpdate( X_Node_html, X_Node_html[ '_rawObject' ].parentNode, null, X_Node_html[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1428 X_Node__commitUpdate( X_Node_head, X_Node_head[ '_rawObject' ].parentNode, null, X_Node_head[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1429 X_Node__commitUpdate( X_Node_body, X_Node_body[ '_rawObject' ].parentNode, null, X_Node_body[ '_flags' ], 1, xnodesIEFilterFixAfter = [] );
1432 X_UA[ 'IE5' ] && ( X_elmBody.style.visibility = '' );
1434 if( X_Node_updateReservedByReleaseGPU ){
1435 X_Node_reserveUpdate();
1436 X_Node_updateReservedByReleaseGPU = false;
1439 if( X_NodeFlags_IE_FILTER_FIX_AFTER && xnodesIEFilterFixAfter.length ){
1440 for( i = 0; xnode = xnodesIEFilterFixAfter[ i ]; ++i ){
1441 xnode[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_FIX_AFTER;
1442 X_Node_CSS_onAfterUpdateIEFilterFix( xnode );
1446 // time を視て X.Timer 経由の場合、即座に発火する。
1447 // width() 等で強制的にツリーを構築している場合、UPDATE イベントのコールバックで要素を変更しサイズを取ると無限ループになる,これを防ぐため asyncDispatch とする
1448 X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_UPDATED ] && X_System[ time ? 'dispatch' : 'asyncDispatch' ]( X_EVENT_UPDATED );
1450 X_ViewPort[ '_listeners' ] && X_ViewPort[ '_listeners' ][ X_EVENT_AFTER_UPDATE ] && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_AFTER_UPDATE );
1454 * 1. GPU_NOW の場合、子の変更は行わない
1455 * 2. GPU解放予約 の場合//、この要素のみ変更を行う。rAF 後にさらに更新するためフラグを立てる。
1457 * 4. style="display:none" の場合、これ以下の変更を行わない。
1458 * 5. ie5 非表示フラグが立っていて、親と自身の class・id によって非表示になっていて、親と自身に変更がない。accumulatedFlags を使用。
1459 * -> TODO これ TREE の変更を検出できない。 remove したときに 子まで X_NodeFlags_IE5_DISPLAY_NONE_FIXを落とす。
1463 * 9. ie5 親及び自身へのクラス・id指定で display:none になるケースがありそれを検出。
1464 * このままでは、生成と破棄が繰り返されてしまうので親と自身のクラス・idが変わった場合、ツリー位置の変化があった場合に再生する。
1466 var X_Node__commitUpdate =
1468 ( function( that, parentElement, nextElement, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter ){
1469 var elm = that[ '_rawObject' ],
1470 created, xnodes, l, next, anime, v, currentOpcity;
1472 // 1. GPU 一切の更新をスキップ
1473 if( that[ '_flags' ] & X_NodeFlags_GPU_NOW ){
1474 console.log( '更新のskip ' + that[ '_className' ] + !!( that[ '_flags' ] & X_Node_BitMask_IS_DIRTY ) );
1475 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1480 if( that[ '_flags' ] & X_NodeFlags_GPU_RELEASE_RESERVED ){
1481 console.log( 'GPU 解放 ' );
1482 //X_Node_updateReservedByReleaseGPU = true;
1483 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1484 //return elm;// このタイミングで更新できるっぽい。
1488 if( that[ '_flags' ] & X_NodeFlags_GPU_RESERVED ){
1489 // TODO size 取得のための update の場合、GPU化をスキップ
1490 that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
1491 that[ '_flags' ] |= X_NodeFlags_GPU_NOW;
1494 // 4. style="display:none" の場合
1495 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1496 if( X_Node_displayNoneFixForIE5 ){
1497 // filter の効いている要素を含む要素は display:none が無視される。
1498 // filter = '' で削除はできるが、再表示時に filter が消える。 -> filter な要素を削除してしまう。
1499 // TODO filters[0].enabled = false なんてどう?
1500 if( elm && elm.parentNode ){
1501 X_Node__actualRemove( that );
1505 elm && ( elm.style.display = 'none' );
1506 return ( elm && elm.nextSibling === nextElement ) ? elm : nextElement;
1510 accumulatedFlags |= that[ '_flags' ];
1512 if( that[ '_flags' ] & X_NodeFlags_IE5_DISPLAY_NONE_FIX ){
1513 if( ( accumulatedFlags & ( X_NodeFlags_DIRTY_POSITION | X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME ) ) === 0 ){
1520 if( !that[ '_tag' ] ){
1521 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1522 elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
1523 if( !X_UA[ 'IE' ] ){
1524 elm[ 'UID' ] = that[ '_uid' ];
1527 if( X_Node_strictElmCreation ){
1528 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true ); // OLD_CSSTEXT ??
1531 document.createElement( [
1532 '<', that[ '_tag' ],
1533 ' UID="', that[ '_uid' ], '"',
1534 that[ '_id' ] ? ' id="' + that[ '_id' ] + '"' : '',
1535 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
1536 X_Node_Attr_objToAttrText( that, true ),
1537 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
1540 if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
1541 elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ].toLowerCase() );
1543 // TODO math http://www.w3.org/1998/Math/MathML
1545 elm = document.createElement( that[ '_tag' ] );
1548 that[ '_rawObject' ] = elm;
1550 // IE には要素追加のタイミングで起こるメモリリークがありここで追加
1551 if( !X_Node_addTreeAfterChildren ){
1553 parentElement.insertBefore( elm, nextElement ) :
1554 parentElement.appendChild( elm );
1557 if( that[ '_tag' ] ){
1558 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
1559 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1561 //if( X_Node_documentFragment ){
1562 //( frg = X_Node_documentFragment ).appendChild( elm );
1563 // 連続する要素の差し替えの場合に有効
1566 if( X_Node_strictElmCreation ){
1567 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1568 // ie の string から要素を作る場合、ネットワーク系属性は onload イベントなどを拾うために、要素生成->イベント復帰後に適用する
1569 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR ); // _newAttrs には ネットワーク系属性が入っている。Network 系の属性は遅らせて設定
1570 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;// doc 追加後に filter を指定しないと有効にならない。
1572 elm[ 'UID' ] = that[ '_uid' ];
1573 that[ '_newAttrs' ] = that[ '_attrs' ];
1574 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1575 that[ '_flags' ] |= X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME | X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_CSS | X_NodeFlags_DIRTY_IE_FILTER;
1577 // http://outcloud.blogspot.jp/2010/09/iframe.html
1578 // この問題は firefox3.6 で確認
1579 if( X_UA[ 'Gecko' ] ){
1580 if( that[ '_tag' ] === 'IFRAME' && ( !that[ '_attrs' ] || !that[ '_attrs' ][ 'src' ] ) ){
1581 //elm.contentWindow.location.replace = elm.src = 'about:blank';
1582 that[ 'attr' ]( 'src', 'about:blank' );
1591 if( elm.parentNode !== parentElement || ( nextElement && elm.nextSibling !== nextElement ) ){
1593 parentElement.insertBefore( elm, nextElement ) :
1594 parentElement.appendChild( elm );
1597 if( that[ '_listeners' ] && ( ( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ) === 0 ) ){
1598 X_EventDispatcher_toggleAllEvents( that, true );// イベントの退避
1599 that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
1602 // ie8 では子要素に opacity が反映されないため、親要素の opacity を積算する
1603 currentOpcity = that[ '_css' ] && 0 <= that[ '_css' ].opacity && that[ '_css' ].opacity;
1604 ie8AccumulatedOpcity = ie8AccumulatedOpcity * ( currentOpcity || 1 );
1607 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ){
1608 delete that[ '_fontSize' ];
1609 X_Node__updateRawNode( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags );
1613 // 親及び自身へのクラス・id指定で display : none になるケースがありそれを検出
1614 // 生成と破棄が繰り返されてしまう、親と自身の id, class が変わった場合だけ再生成。 accumulatedFlags & ( ID | CLASSNAME )
1615 // currentStyle を観ていたときはエラーで停止する、alert と挟むと正常に動いて支離滅裂
1616 if( X_Node_displayNoneFixForIE5 && that[ '_tag' ] ){
1617 if( elm.runtimeStyle.display === 'none' ){
1618 X_Node__actualRemove( that );
1619 that[ '_flags' ] |= X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1622 that[ '_flags' ] &= ~X_NodeFlags_IE5_DISPLAY_NONE_FIX;
1626 if( that[ '_flags' ] & X_NodeFlags_IE_FILTER_FIX_AFTER ){
1627 xnodesIEFilterFixAfter[ xnodesIEFilterFixAfter.length ] = that;
1631 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ) {
1633 next = X_Node__commitUpdate( xnodes[ --l ], elm, next, accumulatedFlags, ie8AccumulatedOpcity, xnodesIEFilterFixAfter );
1637 if( created && X_Node_addTreeAfterChildren ){
1639 parentElement.insertBefore( elm, nextElement ) :
1640 parentElement.appendChild( elm );
1642 if( X_UA[ 'Gecko' ] && that[ '_tag' ] === 'IFRAME' && elm.contentWindow ){
1643 // tree に追加されるまで contentWindow は存在しない。
1644 elm.contentWindow.location.replace = elm.src;
1649 * if( ( anime = that[ '_anime' ] ) && 6 <= anime.phase && anime.doScroll ){
1650 if( anime.phase === 6 ){
1651 v = anime.fromScrollX;
1655 anime.fromScrollX = elm.scrollLeft;
1657 v = anime.fromScrollY;
1661 anime.fromScrollY = elm.scrollTop;
1664 elm.scrollLeft = anime.scrollX;
1665 elm.scrollTop = anime.scrollY;
1673 ( function( that, parentElement, prevElement, accumulatedFlags ){
1674 var elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
1675 xnodes, l, i, dirty, mix, html, text, prev, anime, v;
1677 if( !that[ '_tag' ] ){
1678 that[ '_flags' ] & X_NodeFlags_DIRTY_CONTENT && X_Node__updateRawNode( that, elm );
1682 // 4. style="display:none" の場合
1683 if( that[ '_flags' ] & X_NodeFlags_STYLE_IS_DISPLAY_NONE ){
1685 elm.style.display = 'none';
1686 if( elm.style.display !== 'none' ){ // ie4 の style は currentStyle 相当らしい、、、? div 以外への display:none が効かないので remove する。
1687 X_Node__actualRemove( that );
1691 return elm || prevElement;
1696 prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that, false ) ) :
1697 parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that, false ) );
1698 X_Node__afterActualCreate( that );
1700 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that );
1702 accumulatedFlags |= that[ '_flags' ];
1704 xnodes = that[ '_xnodes' ];
1705 l = xnodes ? xnodes.length : 0;
1706 dirty = !!( that[ '_flags' ] & X_NodeFlags_IE4_DIRTY_CHILDREN );
1709 * HTML の下に TextNode だけ 。MIX_FIXED でない場合、削除、追加 を親に通知
1711 * HTML の下は MIX -> TextNode, html の削除、変更、追加
1712 * HTML の下は MIX_FIXED -> TextNode を <font> に置き換えてあるのでW3C DON 的に触ることができる
1715 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
1716 for( i = 0; i < l; ++i ){
1717 if( xnodes[ i ][ '_tag' ] ){
1718 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
1720 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
1722 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
1729 if( that[ '_flags' ] & X_NodeFlags_IE4_FIXED || that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_ELEMENT ){
1730 for( i = 0; i < l; ++i ){
1731 prev = X_Node__commitUpdate( xnodes[ i ], elm, prev, accumulatedFlags );
1736 for( i = 0; i < l; ++i ){
1737 html[ i ] = X_Node__actualCreate( xnodes[ i ], false );
1739 elm.innerHTML = html.join( '' );
1740 for( i = 0; i < l; ++i ){
1741 X_Node__afterActualCreate( xnodes[ i ] );
1743 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
1745 if( that[ '_flags' ] & X_NodeFlags_IE4_HAS_TEXTNODE ){
1746 dirty = dirty || false;
1747 for( i = 0; i < l; ++i ){
1749 if( text[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
1750 text[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1754 if( dirty ) elm.innerHTML = that[ 'text' ]();
1757 if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ) delete that[ '_fontSize' ];
1759 that[ '_flags' ] &= ~X_NodeFlags_DIRTY_POSITION;
1760 that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
1763 if( ( anime = that[ '_anime' ] ) && 6 <= anime.phase && anime.doScroll ){
1764 if( anime.phase === 6 ){
1765 v = anime.fromScrollX;
1769 anime.fromScrollX = elm.scrollLeft;
1771 v = anime.fromScrollY;
1775 anime.fromScrollY = elm.scrollTop;
1778 elm.scrollLeft = anime.scrollX;
1779 elm.scrollTop = anime.scrollY;
1788 * GPU レイヤーするブラウザは、子要素から変更を当てていく? <- とりあえず、親要素から。
1790 var X_Node__updateRawNode =
1792 ( function( that, elm, currentOpcity, ie8AccumulatedOpcity, accumulatedFlags ){
1793 var // flags = that[ '_flags' ],
1794 attrs, rename, k, v, f;
1797 if( !that[ '_tag' ] ){
1798 elm.data = X_String_chrReferanceTo( that[ '_text' ] );
1799 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1804 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ){
1806 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1807 elm.setAttribute( 'id', that[ '_id' ] ) :
1808 ( elm.id = that[ '_id' ] )
1810 ( elm.id && elm.removeAttribute( 'id' ) );
1813 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1814 that[ '_className' ] ?
1815 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1816 elm.setAttribute( 'class', that[ '_className' ] ) :
1817 ( elm.className = that[ '_className' ] )
1819 ( elm.className && elm.removeAttribute( X_UA[ 'IE' ] < 8 ? 'className' : 'class' ) ); // className は ie7-
1823 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1824 rename = X_Node_Attr_renameForDOM;
1829 switch( that[ '_tag' ] + k ){
1830 case 'TEXTAREAvalue' :
1831 // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので
1832 // MultipleIE6 でもここを通す。X_UA[ 'ieExeComError' ] の場合 MultipleIE6
1833 if( ( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ) || ( X_UA[ 'ieExeComError' ] && X_UA[ 'IE6' ] ) ){
1835 ( elm.firstChild.data = v || '' ) :
1836 elm.appendChild( document.createTextNode( v || '' ) );
1842 // http://outcloud.blogspot.jp/2010/09/iframe.html
1843 // この問題は firefox3.6 で確認
1844 if( X_UA[ 'Gecko' ] && elm.contentWindow ){
1845 elm.contentWindow.location.replace = elm.src = v || '';
1851 // http://d.hatena.ne.jp/NeoCat/20080921/1221940658
1852 // こちらに名前をsetしないとtargetが動作しない
1853 // これってあとから name を変更できないバグでは? itozyun
1854 // if( X_UA[ 'IE' ] ) elm.name = elm.contentWindow.name = v || '';
1857 //if( X_EMPTY_OBJECT[ k ] ) continue;
1858 // TODO IE では input, なぜか button, object も type, name の変更が出来ない、同値で置き換えようとしても不可
1860 elm.removeAttribute( rename[ k ] || k ) :
1861 ( ( that[ '_flags' ] & X_NodeFlags_IS_SVG ) ?
1862 elm.setAttribute( k, v ) :
1863 ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v )
1866 delete that[ '_newAttrs' ];
1869 if( accumulatedFlags & X_NodeFlags_IE8_OPACITY_FIX ){
1870 if( 0 <= currentOpcity ){
1872 that[ '_css' ].opacity = ie8AccumulatedOpcity;
1873 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1874 that[ '_flags' ] |= X_NodeFlags_OLD_CSSTEXT;
1876 if( !( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ) ){
1877 that[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;
1883 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1884 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1885 X_UA[ 'Opera78' ] || X_UA[ 'NN6' ] ?
1886 elm.setAttribute( 'style', that[ '_cssText' ] ) : // opera8用
1887 ( elm.style.cssText = that[ '_cssText' ] );
1889 elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要
1890 elm.removeAttribute( 'style' );
1893 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1894 v = X_Node_CSS_objToIEFilterText( that );
1896 elm.style.filter = v;
1897 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1899 elm.style.removeAttribute( 'filter' );
1900 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1905 * http://jsdo.it/esukei/imOL
1906 * IE8でのfilter:alpha継承
1907 * IE8でfilter:alphaの指定がposition:relative,position:absoluteの子要素に継承されない問題
1910 that[ '_css' ].opacity = currentOpcity;
1913 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1916 ( function( that, elm ){
1917 var attrs, rename, k, v;
1920 if( !that[ '_tag' ] ){
1921 elm.innerText = that[ '_text' ];
1922 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1927 * http://www.tohoho-web.com/js/element.htm
1928 * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる
1931 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ID ) elm.setAttribute( 'id', that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) );
1934 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CLASSNAME ){
1935 that[ '_className' ] ? ( elm.className = that[ '_className' ] ) : elm.removeAttribute( 'class' );
1938 if( that[ '_flags' ] & X_NodeFlags_DIRTY_CSS ){
1939 if( that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
1940 elm.style.cssText = that[ '_cssText' ];
1942 elm.style.cssText = '';
1943 elm.removeAttribute( 'style' );
1946 if( that[ '_flags' ] & X_NodeFlags_DIRTY_IE_FILTER ){
1947 v = X_Node_CSS_objToIEFilterText( that );
1949 elm.style.filter = v;
1950 that[ '_flags' ] |= X_NodeFlags_IE_FILTER_NOW;
1952 elm.style.removeAttribute( 'filter' );
1953 that[ '_flags' ] &= ~X_NodeFlags_IE_FILTER_NOW;
1958 if( that[ '_flags' ] & X_NodeFlags_DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
1959 rename = X_Node_Attr_renameForDOM;
1961 //if( X_EMPTY_OBJECT[ k ] ) continue;
1962 ( v = attrs[ k ] ) === undefined ?
1963 elm.removeAttribute( rename[ k ] || k ) :
1964 elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v );
1966 delete that[ '_newAttrs' ];
1969 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
1973 /* --------------------------------------
1976 * http://d.hatena.ne.jp/uupaa/20080718/1216362040
1977 * DOM Rangeが使える環境(Firefox2+,Opera9+,Safari3+)なら、innerHTMLいらずで、ガーって書けます。
1978 * return document.createRange().createContextualFragment("<div><select><option></option></select></div>");
1979 * insertAdjacentHTML
1981 * ie7 以下では iframe の frameborder や、input name は、createElement 後に setAttribute しても無視される
1983 * fragument がある場合 children も足して
1984 * Mozilla: 1.0+, IE: 5.5+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+
1985 * ie6 大丈夫?fragment の場合リークしないか?チェックが必要
1986 * http://msdn.microsoft.com/ja-jp/library/bb250448%28v=vs.85%29.aspx
1988 * document.createElement of ie4 is only for OPTION & IMAGE.
1990 var X_Node__actualCreate =
1991 X_UA_DOM.IE4 && (function( that, isChild ){
1992 var uid = that[ '_uid' ],
1993 html, xnodes, n, i, l;
1995 if( !that[ '_tag' ] ){
1996 html = [ '<FONT id=ie4uid', uid, ' UID="', uid, '">', that[ '_text' ], '</FONT>' ];// fake textNode
1997 delete that[ '_rawObject' ];
1999 if( !isChild ) X_Node__actualRemove( that, /* true */ false );
2001 that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true );
2004 '<', that[ '_tag' ], ' id=', ( that[ '_id' ] || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',
2005 that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
2006 X_Node_Attr_objToAttrText( that, true ),
2007 that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
2011 if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ){
2013 that[ '_flags' ] &= ~X_NodeFlags_IE4_DIRTY_CHILDREN;
2014 for( i = 0; i < l; ++i ){
2015 if( xnodes[ i ][ '_tag' ] ){
2016 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_ELEMENT;
2018 that[ '_flags' ] |= X_NodeFlags_IE4_HAS_TEXTNODE;
2020 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
2025 if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_NodeFlags_IE4_HAS_TEXTNODE ){
2027 html[ n ] = that[ 'text' ]();
2030 for( i = 0; i < l; ++i ){
2031 html[ n ] = X_Node__actualCreate( xnodes[ i ], true );
2034 that[ '_flags' ] |= X_NodeFlags_IE4_FIXED;
2037 X_Dom_DTD_EMPTY[ that[ '_tag' ] ] || ( html[ n ] = '<\/' + that[ '_tag' ] + '>' );
2039 that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_NodeFlags_DIRTY_ATTR );
2042 return html.join( '' );
2045 var X_Node__afterActualCreate =
2046 X_UA_DOM.IE4 && (function( that ){
2049 if( !that[ '_tag' ] ) return that;
2051 if( ( xnodes = that[ '_xnodes' ] ) && ( i = xnodes.length ) ){
2053 X_Node__afterActualCreate( xnodes[ --i ] );
2056 // ネットワーク系属性と filter は要素生成後に適用
2057 if( that[ '_flags' ] & ( X_NodeFlags_DIRTY_ATTR | X_NodeFlags_DIRTY_IE_FILTER ) ){
2058 X_Node__updateRawNode( that, that[ '_rawObject' ] || X_Node__ie4getRawNode( that ) );
2060 that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
2062 X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
2065 var X_Node__actualRemove =
2067 // GPUレイヤーにいるうちは remove しない。-> GPU解除してから remove する
2068 // Firefox34 では遭遇せず、Safari で何度かアニメーションしているうちに発生
2069 ( function( that, isChild ){
2070 var xnodes = that[ '_xnodes' ],
2071 elm = that[ '_rawObject' ],
2074 if( xnodes && ( l = xnodes.length ) ){
2075 for( i = 0; i < l; ++i ){
2076 child = xnodes[ i ];
2077 child[ '_tag' ] && X_Node__actualRemove( child, true );
2083 if( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ){
2084 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2085 that[ '_flags' ] &= ~X_NodeFlags_ACTUAL_LISTENING;
2088 // ie5では filter の効いている要素をremove時に破棄して、再度append 時に新規生成する
2089 // ちなみに elm.filters に触ると ie8 でなぜかカラム落ちが発生、、、
2090 if( X_Node_displayNoneFixForIE5 ){
2091 if( elm.filters && elm.filters.length ){
2093 delete that[ '_rawObject' ];
2094 // 破棄前にインタラクティブな属性値を控える
2095 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2096 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2097 that[ '_attrs' ].value = elm.value;
2099 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2100 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2101 that[ '_attrs' ].selected = elm.selected;
2103 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2104 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2105 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2107 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2108 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2109 that[ '_attrs' ].checked = elm.checked;
2116 if( !X_UA[ 'MacIE' ] ){
2117 // elm.parentNode.tagName for ie7
2118 !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );
2120 !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that );
2124 ( function( that, isChild ){
2125 var xnodes = that[ '_xnodes' ],
2126 elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
2128 if( xnodes && ( l = xnodes.length ) ){
2129 for( i = 0; i < l; ++i ){
2130 X_Node__actualRemove( xnodes[ i ], true );
2135 that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避
2137 // 破棄前にインタラクティブな属性値を控える
2138 if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
2139 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2140 that[ '_attrs' ].value = elm.value;
2142 if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
2143 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2144 that[ '_attrs' ].selected = elm.selected;
2146 if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
2147 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2148 that[ '_attrs' ].selectedIndex = elm.selectedIndex;
2150 if( that[ '_tag' ] === 'INPUT' && that[ '_attrs' ] && ( that[ '_attrs' ].type === 'checkbox' || that[ '_attrs' ].type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
2151 if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
2152 that[ '_attrs' ].checked = elm.checked;
2155 elm.removeAttribute( 'id' ); // ?
2156 //document.all[ that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) ] = null; // MacIE5 でエラー
2157 if( !isChild ) elm.outerHTML = ''; // elm.remove() ?
2158 delete that[ '_rawObject' ];
2162 X_ViewPort[ 'listenOnce' ]( X_EVENT_UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );