OSDN Git Service

Version 0.6.168, fix X.UI.Repeater.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 20_XNode.js
index e0aa707..de76d17 100644 (file)
@@ -221,8 +221,6 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ](
                        };
                        this[ '_flags' ] |= X_NodeFlags_EXIST;
                        X_Node_CHASHE[ this[ '_uid' ] = uid ] = this;
-                       
-                       X_EventDispatcher_systemListen( this, X_EVENT_BEFORE_KILL_INSTANCE, X_Node_onBeforeKill );
                },
                
                'width'          : X_Node_width,
@@ -507,7 +505,7 @@ function X_Node_clone( opt_clone_children ){
        var xnode, xnodes, i, l;
        if( this[ '_tag' ] ){
                X_Node_newByTag = true;
-               xnode = Node( this[ '_tag' ], X_Object_clone( this[ '_attrs' ] ), X_Object_clone( this[ '_css' ] ) )
+               xnode = Node( this[ '_tag' ], X_Object_copy( this[ '_attrs' ] ), X_Object_copy( this[ '_css' ] ) )
                        [ 'attr' ]( { 'id' : this[ '_id' ] } )
                        [ 'className' ]( this[ '_className' ] );
                if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
@@ -804,33 +802,44 @@ function X_Node_empty(){
        return this;
 };
 
-function X_Node_onBeforeKill( e ){
-       var xnodes = this[ '_xnodes' ], i, elm;
+function X_Node_onKill( that ){
+       var parent = that.parent,
+               xnodes = that[ '_xnodes' ], i, elm;
        
-       if( ( this[ '_flags' ] & X_NodeFlags_EXIST ) === 0 ) return X_Callback_NONE;
+       if( ( that[ '_flags' ] & X_NodeFlags_EXIST ) === 0 ) return;
        
-       elm = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this );
-       elm && this[ '_listeners' ] && X_EventDispatcher_unlistenAll( this ); // イベントの退避
+       parent && 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 ) ){
                for( ; i; ){
-                       X_Node_onBeforeKill.call( xnodes[ --i ] );
+                       xnodes[ --i ][ 'kill' ]();
                };
        };
 
-       delete X_Node_CHASHE[ this[ '_uid' ] ];
-
-       if( e ){
-               this[ 'remove' ]();
-               if( X_Node_reserveRemoval[ X_Node_reserveRemoval.length - 1 ] === this ){
-                       this[ '_flags' ] &= ~X_NodeFlags_EXIST;
-                       return X_Callback_PREVENT_DEFAULT;              
-               };              
+       delete X_Node_CHASHE[ that[ '_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 ){
+                       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();         
+               };
        };
-       return X_Callback_NONE;
 };
 
 
+
+
 /**
  * 要素を子以下に持つか?調べる。
  * @alias Node.prototype.contains
@@ -1141,7 +1150,7 @@ function X_Node_text( text ){
  */
 function X_Node_call( name /*, opt_args... */ ){
        var l = arguments.length - 1,
-               raw, func, args, params, i;
+               v, raw, func, args, params, i;
 
        switch( name ){
                case 'nodeType' :
@@ -1173,7 +1182,7 @@ function X_Node_call( name /*, opt_args... */ ){
        func = raw[ name ];
        if( X_Type_isFunction( func ) ){
                if( l ){
-                       args = X_Object_cloneArray( arguments );
+                       args = X_Array_copy( arguments );
                        args.shift();
                        return func.apply( raw, args );
                };
@@ -1183,7 +1192,7 @@ function X_Node_call( name /*, opt_args... */ ){
                // typeof func === unknown に対策
                // http://la.ma.la/blog/diary_200509031529.htm          
                if( l ){
-                       args = X_Object_cloneArray( arguments );
+                       args = X_Array_copy( arguments );
                        args.shift();
                        
                params = [];
@@ -1207,7 +1216,7 @@ function X_Node_call( name /*, opt_args... */ ){
 function X_Node_each( func /*, opt_args */ ){
        var args;
        if( 1 < arguments.length ){
-               args = X_Object_cloneArray( arguments );
+               args = X_Array_copy( arguments );
                args[ 0 ] = 0;          
                func.apply( this, args );
        } else {
@@ -1230,7 +1239,7 @@ function X_Node_reserveUpdate(){
 var X_Node_updateReservedByReleaseGPU = false;
 
 function X_Node_startUpdate( time ){
-       var removal, i, xnode;
+       var removal, i, xnodeOrElm;
        
        if( !X_Node_updateTimerID || X_ViewPort_readyState < X_EVENT_INIT ){
                return;
@@ -1248,10 +1257,23 @@ function X_Node_startUpdate( time ){
 
        if( i = removal.length ){
                for( ; i; ){
-                       xnode = removal[ --i ];
+                       xnodeOrElm = removal[ --i ];
                        // TODO GPU レイヤーの子の場合、remove をスキップする。 非GPU レイヤーへ apppend される場合、clone する?
-                       X_Node__actualRemove( xnode );
-                       ( xnode[ '_flags' ] & X_NodeFlags_EXIST ) === 0 && xnode[ 'kill' ]();
+                       if( !xnodeOrElm[ 'instanceOf' ] ){
+                               if( X_UA_DOM.IE4 ){
+                                       xnodeOrElm.removeAttribute( 'id' ); // ?
+                                       xnodeOrElm.outerHTML = ''; // xnodeOrElm.remove() ?
+                               } else {
+                                       if( !X_UA[ 'MacIE' ] ){
+                                               // elm.parentNode.tagName for ie7
+                                               xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && xnodeOrElm.parentNode.removeChild( xnodeOrElm );
+                                       } else {
+                                               xnodeOrElm.parentNode && xnodeOrElm.parentNode.tagName && X_TEMP._fixed_remove( xnodeOrElm, that );
+                                       };
+                               };
+                       } else {
+                               X_Node__actualRemove( xnodeOrElm );
+                       };
                };
                removal.length = 0;
        };
@@ -1585,7 +1607,8 @@ var X_Node__updateRawNode =
                                        switch( that[ '_tag' ] + k ){
                                                case 'TEXTAREAvalue' :
                                                        // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので
-                                                       if( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ){
+                                                       // MultipleIE6 でもここを通す。X_UA[ 'ieExeComError' ] の場合 MultipleIE6
+                                                       if( ( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ) || ( X_UA[ 'ieExeComError' ] && X_UA[ 'IE6' ] ) ){
                                                                elm.firstChild ?
                                                                        ( elm.firstChild.data = v || '' ) :
                                                                        elm.appendChild( document.createTextNode( v || '' ) );
@@ -1884,7 +1907,7 @@ var X_Node__actualRemove =
 
                        elm.removeAttribute( 'id' ); // ?
                        //document.all[ that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) ] = null; // MacIE5 でエラー
-                       if( !isChild ) elm.outerHTML = '';
+                       if( !isChild ) elm.outerHTML = ''; // elm.remove() ?
                        delete that[ '_rawObject' ];
                }) :
                (function(){});