var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ](
'X.Node',
X_Class.POOL_OBJECT,
-
{
/**
* 要素に振られるユニークID
// 親の xnodes から v を消す
v.parent && v[ 'remove' ]();
// IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
- if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
+ if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
break;
default :
return this;
v[ 'remove' ]();
};
// IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知
- if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
+ if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( ( this[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ) this[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
break;
default :
return this;
};
/**
- * 要素を抜く。
+ * 要素を親要素から抜く。jQuery の remove と異なり、インスタンスは破壊(kill)されず、再び別の親に挿入等できる
* @alias Node.prototype.remove
* @return {Node} 自身。チェインメソッド
* @example node.remove();
+ * parent.append( node ); 新しい親に追加できる
*/
function X_Node_remove(){
var parent = this.parent,
this[ '_xnodes' ] && X_Node_toggleInTreeFlag( this[ '_xnodes' ], false );
if( X_UA_DOM.IE4 ){
- elm = this[ '_rawObject' ] || X_Node__ie4getRawNode( this );
- if( elm ){
+ if( elm = this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ){
X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
X_Node_reserveUpdate();
} else
- if( !this[ '_tag' ] && ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ){
+ if( !this[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
};
} else {
X_Node_reserveUpdate();
};
};
+ } else {
+ if( !X_UA_DOM.IE4 ){
+ elm = this[ '_rawObject' ];
+ if( elm && elm.parentNode && elm.parentNode.tagName ){
+ X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
+ X_Node_reserveUpdate();
+ };
+ };
};
return this;
};
*/
function X_Node_empty(){
var xnodes = this[ '_xnodes' ], i;
+
if( xnodes && ( i = xnodes.length ) ){
+ delete this[ '_xnodes' ];
for( ; i; ){
xnodes[ --i ][ 'kill' ]();
};
if( ( that[ '_flags' ] & X_NodeFlags_EXIST ) === 0 ) return;
- parent && parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( that ), 1 );
+ parent && parent[ '_xnodes' ] && parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( that ), 1 );
elm = that[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( that );
- // elm && that[ '_listeners' ] && X_EventDispatcher_unlistenAll( that ); // イベントの退避
if( xnodes && ( i = xnodes.length ) ){
+ delete that[ '_xnodes' ];
for( ; i; ){
xnodes[ --i ][ 'kill' ]();
};
+ xnodes.length = 0;
};
- delete X_Node_CHASHE[ that[ '_uid' ] ];
+ X_Node_CHASHE[ that[ '_uid' ] ] = null; // array に対して delete X_Node_CHASHE[ uid ] はまずい!
+
// remove _xnodes
if( X_UA_DOM.IE4 ){
if( elm ){
X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
X_Node_reserveUpdate();
} else
- if( !that[ '_tag' ] && ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ){
+ if( !that[ '_tag' ] && ( ( parent[ '_flags' ] & X_NodeFlags_IE4_FIXED ) === 0 ) ){
parent[ '_flags' ] |= X_NodeFlags_IE4_DIRTY_CHILDREN;
};
} else {
if( elm && elm.parentNode && elm.parentNode.tagName ){
X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = elm;
- X_Node_reserveUpdate();
+ X_Node_reserveUpdate();
};
};
};
// setter
if( html !== undefined ){ // String 以外に Number や false null なども許可
if( !this[ '_tag' ] ) return this[ 'text' ]( html );
- return html ? this[ 'empty' ]()[ 'append' ].apply( this, X_HtmlParser_parse( html, true ) ) : this[ 'empty' ]();
+
+ this[ 'empty' ]();
+ if( html ){
+ X_Node_append.apply( this, X_HtmlParser_parse( html, true ) );
+ };
+ return this;
};
// getter
};
if( name === 'inView' ){
- body = document.body;
+ body = X_elmBody;
child = raw;
visibleX = visibleY = visibleW = visibleH = 0;
while( child !== body ){
accumulatedFlags |= that[ '_flags' ];
if( that[ '_flags' ] & X_NodeFlags_IE5_DISPLAY_NONE_FIX ){
- if( accumulatedFlags & ( X_NodeFlags_DIRTY_POSITION | X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME ) === 0 ){
+ if( ( accumulatedFlags & ( X_NodeFlags_DIRTY_POSITION | X_NodeFlags_DIRTY_ID | X_NodeFlags_DIRTY_CLASSNAME ) ) === 0 ){
return nextElement;
};
};
if( !elm ){
if( !that[ '_tag' ] ){
that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
- that[ '_rawObject' ] = elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
+ elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
if( !X_UA[ 'IE' ] ){
elm[ 'UID' ] = that[ '_uid' ];
};
if( X_Node_strictElmCreation ){
that[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true ); // OLD_CSSTEXT ??
- that[ '_rawObject' ] = elm =
+ elm =
document.createElement( [
'<', that[ '_tag' ],
' UID="', that[ '_uid' ], '"',
X_Node_Attr_objToAttrText( that, true ),
that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
'>' ].join( '' ) );
+ } else
+ if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
+ elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ].toLowerCase() );
+
+ // math http://www.w3.org/1998/Math/MathML
} else {
- if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
- that[ '_rawObject' ] = elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ].toLowerCase() );
- } else {
- that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] );
- };
+ elm = document.createElement( that[ '_tag' ] );
};
+ that[ '_rawObject' ] = elm;
+
// IE には要素追加のタイミングで起こるメモリリークがありここで追加
if( !X_Node_addTreeAfterChildren ){
nextElement ?
X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰
that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
- if( X_Node_documentFragment ){
+ //if( X_Node_documentFragment ){
//( frg = X_Node_documentFragment ).appendChild( elm );
// 連続する要素の差し替えの場合に有効
- };
+ //};
if( X_Node_strictElmCreation ){
that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
parentElement.appendChild( elm );
};
- if( that[ '_listeners' ] && ( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ) === 0 ){
+ if( that[ '_listeners' ] && ( ( that[ '_flags' ] & X_NodeFlags_ACTUAL_LISTENING ) === 0 ) ){
X_EventDispatcher_toggleAllEvents( that, true );// イベントの退避
that[ '_flags' ] |= X_NodeFlags_ACTUAL_LISTENING;
};