OSDN Git Service

Version 0.6.32, async X.Dom.Builder.
authoritozyun <itozyun@user.sourceforge.jp>
Sat, 29 Mar 2014 03:56:50 +0000 (12:56 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Sat, 29 Mar 2014 03:56:50 +0000 (12:56 +0900)
0.6.x/js/dom/10_XDom.js
0.6.x/js/dom/11_XDomNode.js
0.6.x/js/dom/22_XDomBuilder.js

index bd22892..55804c0 100644 (file)
@@ -50,8 +50,7 @@
                        X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : w, h : h } );\r
                        lock = false;\r
                };\r
-       };      \r
-       \r
+       };\r
        \r
        X.Dom = X.Class._override(\r
                new X.EventDispatcher(),\r
                                } );\r
                                \r
                                X.Dom.listenOnce( X.Dom.Event.DOM_BUILDER_COMPLETE, function(){\r
+                                       X.Dom.readyState = X.Dom.Event.DOM_INIT;\r
+                                       \r
                                        Node.root.appendAt( 0,\r
                                                Node._systemNode = Node.create( 'div', { 'class' : 'hidden-system-node' } ),\r
                                                Node._fontSizeNode = Node.create( 'div', { 'class' : 'hidden-system-node' } ).cssText( 'line-height:1;height:1em;' ).text( 'X' )\r
                                        )._startUpdate();\r
                                        \r
-                                       X.Dom.readyState = X.Dom.Event.DOM_INIT;\r
-                                       \r
                                        X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_INIT } );\r
                                } );\r
 \r
 \r
                                X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_PRE_INIT } );  \r
 \r
+                               Node._window\r
+                                       .listen( 'beforeunload', X.Dom )\r
+                                       .listenOnce( 'unload', X.Dom );\r
+\r
+                               if (document[ 'hidden' ] !== undefined ) {// iOS 7+\r
+                                       Node._document.listen( 'visibilitychange', X.Dom );\r
+                               } else\r
+                               if (document[ 'webkitHidden' ] !== undefined ) {\r
+                                       Node._document.listen( 'webkitvisibilitychange', X.Dom );\r
+                               } else\r
+                               if ( X.UA.iOS && window[ 'onpageshow' ] !== undefined ) {\r
+                                       Node._window.listen('pageshow', X.Dom );\r
+                                       Node._window.listen('pagehide', X.Dom );\r
+                               } else {\r
+                                       Node._window.listen('focus', X.Dom );\r
+                                       Node._window.listen('blur', X.Dom );\r
+                               };\r
+\r
                                return X.Callback.UN_LISTEN;\r
                        },\r
 \r
+                       handleEvent : function( e ){\r
+                               switch( e.type ){\r
+                                       case 'beforeunload' :\r
+                                               return X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UNLOAD } );\r
+                                       case 'unload' :\r
+                                               X.Dom.dispatch( { type : X.Dom.Event.UNLOAD } );\r
+                                               \r
+                                               Node._window.unlisten();\r
+                                               Node._document.unlisten();\r
+                                               Node._html._actualRemove( true );\r
+                                               break;\r
+                                       case 'visibilitychange' :\r
+                                               break;\r
+                                       case 'webkitvisibilitychange' :\r
+                                               break;\r
+                                       case 'pageshow' :\r
+                                       \r
+                                       \r
+                                       case 'focus' :\r
+                                               X.Dom.dispatch( { type : X.Dom.Event.VIEW_ACTIVATE } );\r
+                                               break;\r
+                                       case 'pagehide' :\r
+                                       case 'blur' :\r
+                                               X.Dom.dispatch( { type : X.Dom.Event.VIEW_DEACTIVATE } );\r
+                                               break;\r
+                               };\r
+                       },\r
+\r
                        getSize :\r
                                X.UA.IE ?\r
                                        new Function( 'return[X.Dom._root.clientWidth,X.Dom._root.clientHeight]' ) :\r
@@ -205,7 +250,7 @@ X.Dom.whiteSpaceToTag = function( text ){
        .split( '\n\r' ).join( '<br>' )\r
        .split( '\r' ).join( '<br>' )\r
        .split( '\n' ).join( '<br>' )\r
-       .split( '\t' ).join( '' )\r
+       .split( '\t' ).join( '&nbsp;&nbsp;&nbsp;&nbsp;' )\r
        .split( '\f' ).join( '' )\r
        .split( '\b' ).join( '' );\r
 };\r
index 35a03d9..589db76 100644 (file)
@@ -813,7 +813,9 @@ Node.prototype._reserveUpdate = function(){
 \r
 Node.prototype._startUpdate = function(){\r
        var removal, i, xnode, tmp;\r
-       \r
+       if( X.Dom.readyState < X.Dom.Event.DOM_INIT ){\r
+               return;\r
+       };\r
        if( this._updateTimerID ){\r
                //X.Timer.cancelFrame( this._updateTimerID ); // fire 中の cancel が動かない、、、\r
                this._updateTimerID = 0;\r
index 5fc818a..506f182 100644 (file)
@@ -61,139 +61,153 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT,
                };\r
        })( body );\r
        \r
-                       function createTree( xnode, childNodes, skipCleanup, textarea ){\r
-                               var i = 0,\r
-                                       j = 0,\r
-                                       l = childNodes.length,\r
-                                       child, _xnode, f, tag, text, _xtext, doc;\r
-                               childNodes = X.copyArray( childNodes );\r
+       function createTree( xnode, childNodes, skipCleanup, textarea ){\r
+               var i = 0,\r
+                       j = 0,\r
+                       l = childNodes.length,\r
+                       child, _xnode, f, tag, text, _xtext, doc;\r
+               childNodes = X.copyArray( childNodes );\r
 \r
-                               if( textarea ){\r
-                                       xnode.attr( 'value', xnode.html() ).empty();\r
-                                       return;\r
-                               };\r
+               if( textarea ){\r
+                       xnode.attr( 'value', xnode.html() ).empty();\r
+                       return;\r
+               };\r
 \r
-                               for( ; i < l; ++i ){\r
-                                       child = childNodes[ i ];\r
-                                       tag   = child.tagName;\r
-                                       if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || tag === '!' || ( tag && tag.charAt( 0 ) === '/' ) ){\r
-                                               child.parentNode.removeChild( child );\r
+               for( ; i < l; ++i ){\r
+                       child = childNodes[ i ];\r
+                       tag   = child.tagName;\r
+                       if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || tag === '!' || ( tag && tag.charAt( 0 ) === '/' ) ){\r
+                               child.parentNode.removeChild( child );\r
+                               continue;\r
+                       };\r
+                       f = false;\r
+                       while( xnode._xnodes && j < xnode._xnodes.length ){\r
+                               _xnode = xnode._xnodes[ j ];\r
+                               _xnode.parent   = xnode;\r
+                               \r
+                               if( _xnode._xnodeType === 1 ){\r
+                                       if( child.nodeType !== 1 ){\r
+                                               if( !( text = child.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                                                       child.parentNode.removeChild( child );\r
+                                                       break;\r
+                                               };\r
+                                               alert( '[' +xnode._tag + '>' +_xnode._tag + '] !== ' + child.nodeType + '\n' + child.data );\r
+                                               ++j;\r
                                                continue;\r
                                        };\r
-                                       f = false;\r
-                                       while( xnode._xnodes && j < xnode._xnodes.length ){\r
-                                               _xnode = xnode._xnodes[ j ];\r
-                                               _xnode.parent   = xnode;\r
-                                               \r
-                                               if( _xnode._xnodeType === 1 ){\r
-                                                       if( child.nodeType !== 1 ){\r
-                                                               if( !( text = child.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
-                                                                       child.parentNode.removeChild( child );\r
-                                                                       break;\r
-                                                               };\r
-                                                               alert( '[' +xnode._tag + '>' +_xnode._tag + '] !== ' + child.nodeType + '\n' + child.data );\r
-                                                               ++j;\r
-                                                               continue;\r
-                                                       };\r
-                                                       if( _xnode._tag.toUpperCase() !== tag ){\r
-                                                               alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );\r
-                                                               ++j;\r
-                                                               continue;\r
-                                                       } else {\r
-                                                               _xnode._rawNode = child;\r
-                                                               //if( ( doc = child.ownerDocument || child.document ) && ( doc.createElement( 'p' ).tagName === doc.createElement( 'P' ).tagName ) ){\r
-                                                                       if( tag.charAt( 0 ) === '/' ) tag = tag.slice( 1 );\r
-                                                                       _xnode._tag     = tag; // .toUpperCase()\r
-                                                               //};\r
-                                                               _xnode._root    = xnode._root;\r
-                                                               child.UID = _xnode._uid;\r
-                                                               if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){ // ie で body 内の script が2度よばれるのに対処\r
-                                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + '] remove ... ' );\r
-                                                                       _xnode.destroy();\r
-                                                                       ++n;\r
-                                                                       continue;\r
-                                                               } else {\r
-                                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );\r
-                                                                       child.childNodes && child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ), tag === 'TEXTAREA' );\r
-                                                               };\r
-                                                               _xtext = null;\r
-                                                               f = true;\r
-                                                               ++j;\r
-                                                               break;\r
-                                                       };\r
-                                               } else\r
-                                               if( _xnode._xnodeType === 3 ){\r
-                                                       \r
-                                                       if( child.nodeType !== 3 ){\r
-                                                               if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
-                                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );\r
-                                                                       _xnode.destroy();\r
-                                                                       ++n;\r
-                                                                       continue;\r
-                                                               };\r
-                                                               alert(  xnode._tag + '>' + '"' + _xnode._text + '" !== ' + tag + '\n' + child.outerHTML );\r
-                                                               ++j;\r
-                                                               continue;\r
-                                                       };\r
-                                                       \r
-                                                       _xnode._rawNode = child;\r
-                                                       _xnode._root    = xnode._root;\r
-                                                       if( !skipCleanup ){\r
-                                                               if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
-                                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );\r
-                                                                       _xnode.destroy();\r
-                                                                       ++n;\r
-                                                                       continue;\r
-                                                               };\r
-                                                               if( _xtext ){\r
-                                                                       _xtext.text( _xtext._text + text );\r
-                                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );\r
-                                                                       _xnode.destroy();\r
-                                                                       ++n;\r
-                                                                       continue;\r
-                                                               } else {\r
-                                                                       //alert( xnode._tag + '>' + '"' + text + '"\n' + child.data );\r
-                                                                       _xnode.text( text );\r
-                                                               };\r
-                                                       } else\r
-                                                       if( _xtext ){\r
-                                                               _xtext.text( _xtext._text + _xnode.text );\r
-                                                               console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );\r
-                                                               _xnode.destroy();\r
-                                                               ++n;\r
-                                                               continue;\r
-                                                       };\r
-                                                       _xtext = _xtext || _xnode;\r
-                                                       ++j;\r
-                                                       break;\r
+                                       if( _xnode._tag.toUpperCase() !== tag ){\r
+                                               alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );\r
+                                               ++j;\r
+                                               continue;\r
+                                       } else {\r
+                                               _xnode._rawNode = child;\r
+                                               //if( ( doc = child.ownerDocument || child.document ) && ( doc.createElement( 'p' ).tagName === doc.createElement( 'P' ).tagName ) ){\r
+                                                       if( tag.charAt( 0 ) === '/' ) tag = tag.slice( 1 );\r
+                                                       _xnode._tag     = tag; // .toUpperCase()\r
+                                               //};\r
+                                               _xnode._root    = xnode._root;\r
+                                               child.UID = _xnode._uid;\r
+                                               if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){ // ie で body 内の script が2度よばれるのに対処\r
+                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + '] remove ... ' );\r
+                                                       _xnode.destroy();\r
+                                                       ++n;\r
+                                                       continue;\r
                                                } else {\r
-                                                       alert( 'no hit!' );\r
+                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );\r
+                                                       child.childNodes && child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ), tag === 'TEXTAREA' );\r
                                                };\r
+                                               _xtext = null;\r
+                                               f = true;\r
                                                ++j;\r
-\r
-                                       };                              \r
-                                       //if( !f ) alert( '**** ' + child.outerHTML );\r
-                               };\r
-                               while( xnode._xnodes && j < xnode._xnodes.length ){\r
-                                       _xnode = xnode._xnodes[ j ];\r
-                                       _xnode.parent = xnode;\r
-                                       _xnode.destroy();\r
-                                       ++n;\r
-                                       continue;\r
+                                               break;\r
+                                       };\r
+                               } else\r
+                               if( _xnode._xnodeType === 3 ){\r
+                                       \r
+                                       if( child.nodeType !== 3 ){\r
+                                               if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );\r
+                                                       _xnode.destroy();\r
+                                                       ++n;\r
+                                                       continue;\r
+                                               };\r
+                                               alert(  xnode._tag + '>' + '"' + _xnode._text + '" !== ' + tag + '\n' + child.outerHTML );\r
+                                               ++j;\r
+                                               continue;\r
+                                       };\r
+                                       \r
+                                       _xnode._rawNode = child;\r
+                                       _xnode._root    = xnode._root;\r
+                                       if( !skipCleanup ){\r
+                                               if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );\r
+                                                       _xnode.destroy();\r
+                                                       ++n;\r
+                                                       continue;\r
+                                               };\r
+                                               if( _xtext ){\r
+                                                       _xtext.text( _xtext._text + text );\r
+                                                       console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );\r
+                                                       _xnode.destroy();\r
+                                                       ++n;\r
+                                                       continue;\r
+                                               } else {\r
+                                                       //alert( xnode._tag + '>' + '"' + text + '"\n' + child.data );\r
+                                                       _xnode.text( text );\r
+                                               };\r
+                                       } else\r
+                                       if( _xtext ){\r
+                                               _xtext.text( _xtext._text + _xnode._text );\r
+                                               console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );\r
+                                               _xnode.destroy();\r
+                                               ++n;\r
+                                               continue;\r
+                                       };\r
+                                       _xtext = _xtext || _xnode;\r
+                                       ++j;\r
+                                       break;\r
+                               } else {\r
+                                       alert( 'no hit!' );\r
                                };\r
-                       };\r
+                               ++j;\r
+\r
+                       };                              \r
+                       //if( !f ) alert( '**** ' + child.outerHTML );\r
+               };\r
+               while( xnode._xnodes && j < xnode._xnodes.length ){\r
+                       _xnode = xnode._xnodes[ j ];\r
+                       _xnode.parent = xnode;\r
+                       _xnode.destroy();\r
+                       ++n;\r
+                       continue;\r
+               };\r
+       };\r
        \r
        // body の属性値の取得\r
 \r
+       body.appendChild( elmProgress = document.createElement( 'div' ) );\r
+       elmProgress.style.cssText = 'position:absolute;top:0;left:0;z-index:9999;width:0;height:0.5em;background:#00f;overflow:hidden;';\r
+       \r
        X.Dom.asyncParse( body.innerHTML, true )\r
-               .listenOnce( X.Event.SUCCESS, X.Dom._onAsyncParseComplete, [ createTree ] );\r
-               //.listen( X.Event.PROGRESS, function(e){alert(e.progress);} );\r
+               //.listenOnce( X.Event.SUCCESS, X.Dom._onAsyncParseComplete, [ createTree ] )\r
+               .listen( X.Event.PROGRESS,\r
+                       function(e){\r
+                               elmProgress.style.width = ( e.progress * 100 | 0 ) + '%';\r
+                       }\r
+               )\r
+               .listenOnce( X.Event.SUCCESS, function( e ){\r
+                       var xnodes = Node.root._xnodes = [], t;\r
+                       xnodes.push.apply( xnodes, e.xnodes );\r
+                       \r
+                       asyncCreateTree( Node.root, body.childNodes, elmProgress );\r
+               } );\r
+\r
 }) :\r
 document.all ?\r
 (function(){\r
        var r    = Node.root,\r
                body = r._rawNode,\r
-               i, n = 0, parser, elmProgress = '_xdom_builder_progress';\r
+               i, n = 0, elmProgress = '_xdom_builder_progress';\r
                \r
                        function createTree( xnode, children, skipCleanup, textarea ){\r
                                var parent = xnode,\r
@@ -298,13 +312,19 @@ document.all ?
        body.insertAdjacentHTML( 'BeforeEnd', '<div id="' + elmProgress + '" style="position:absolute;top:0;left:0;z-index:9999;width:0;height:0.5em;background:#00f;overflow:hidden;"></div>' );\r
        elmProgress = document.all[ elmProgress ];\r
        \r
-       parser = X.Dom.asyncParse( body.innerHTML, true )\r
-               .listenOnce( X.Event.SUCCESS, X.Dom._onAsyncParseComplete, [ createTree ] )\r
+       X.Dom.asyncParse( body.innerHTML, true )\r
+               //.listenOnce( X.Event.SUCCESS, X.Dom._onAsyncParseComplete, [ createTree ] )\r
                .listen( X.Event.PROGRESS,\r
                        function(e){\r
                                elmProgress.style.width = ( e.progress * 100 | 0 ) + '%';\r
                        }\r
-               );\r
+               )\r
+               .listenOnce( X.Event.SUCCESS, function( e ){\r
+                       var xnodes = Node.root._xnodes = [], t;\r
+                       xnodes.push.apply( xnodes, e.xnodes );\r
+                       \r
+                       asyncCreateTree( Node.root, body.childNodes || body.children, elmProgress );\r
+               } );\r
 }) :\r
 (function(){\r
        \r
@@ -324,46 +344,267 @@ X.Dom._onAsyncParseComplete = function( e, createTree ){
 };\r
 \r
 \r
-function asyncCreateTree( parent, elems, xnodeProgress, async ){\r
-       var xnodes    = async ? 0             : X.copyArray( parent._xnodes ),\r
-               l         = async ? 0             : xnodes.length,\r
-               current   = async ? async.current : { xnodes : xnodes, l : l, i : 0 },\r
-               stack     = async ? async.stack   : [],\r
-               count     = async ? async.count   : 0,\r
+function asyncCreateTree( parent, elems, elmProgress, async ){\r
+       var xnodes      = async ? 0             : X.copyArray( parent._xnodes ),\r
+               l           = async ? 0             : xnodes.length,\r
+               current     = async ? async.current : {\r
+                       me     : parent,\r
+                       xnodes : xnodes,\r
+                       l      : l,\r
+                       i      : 0,\r
+                       elems  : elems,\r
+                       j      : 0,\r
+                       xtext  : null,\r
+                       flag   : 0\r
+               },\r
+               stack       = async ? async.stack   : [],\r
+               done        = async ? async.done    : 0,\r
                startTime = X.getTime(),\r
-               xnodes, xnode, l, progress;\r
+               xnode, i, dive;\r
        while( current || ( current = stack.pop() ) ){\r
-               for( ; current.i < current.l; ++current.i ){\r
-                       xnode = current.xnoeds[ current.i ];\r
-                       \r
-                       //\r
-                       \r
-                       ++count;\r
-                       \r
-                       if(( xnodes = xnode._xnodes ) && ( l = xnodes.length ) ){\r
-                               ++current.i;\r
-                               stack[ stack.length ] = current;\r
-                               current = {\r
-                                       xnodes : X.copyArray( xnodes ),\r
-                                       i      : -1,\r
-                                       l      : l\r
+               i = current.i;\r
+               l = current.l;\r
+               if( i < l ){\r
+                       parent = current.me;\r
+                       xnodes = current.xnodes;\r
+                       while( xnode = xnodes[ i ] ){                   \r
+                               //\r
+                               dive = bindElementToXnode( parent, xnode, current );\r
+                               \r
+                               ++i;\r
+                               ++done;\r
+                               if( dive ){\r
+                                       current.i = i;\r
+                                       stack[ stack.length ] = current;\r
+                                       \r
+                                       current = dive;\r
+                                       i       = 0;\r
+                                       l       = dive.l;\r
+                                       parent  = xnode;\r
+                                       xnodes  = dive.xnodes;\r
+                                       continue;\r
                                };\r
-                               continue;\r
-                       };\r
-                       \r
-                       if( startTime + 16 <= X.getTime() ){\r
-                               if( async ){\r
-                                       async.current = ++current.i < current.l && current;\r
-                                       async.count   = count;\r
+                               \r
+                               if( startTime + 16 <= X.getTime() ){\r
+                                       current.i = i;\r
+                                       if( async ){\r
+                                               async.current = i < l && current;\r
+                                               async.done    = done;\r
+                                       };\r
+                                       X.Timer.once( 0, asyncCreateTree, [ null, null, elmProgress, async || { stack : stack, current : i < l && current, done : done } ] );\r
+                                       // progress\r
+                                       elmProgress.style.width = ( ( 1 - done / Node._chashe.length ) * 100 | 0 ) + '%';\r
+                                       return;\r
                                };\r
-                               X.Timer.once( 0, asyncCreateTree, [ null, xnodeProgress, async || { stack : stack, current : ++current.i < current.l && current, count : count } ] );\r
-                               // progress\r
-                               progress = 1 - count / Node._chashe.length;\r
-                               return;\r
-                       };\r
+                       };                      \r
                };\r
                current = null;\r
        };\r
        // complete\r
        X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_BUILDER_COMPLETE } );\r
 };\r
+\r
+bindElementToXnode =\r
+document.getElementById ?\r
+(function( parent, xnode, current ){\r
+       var elems = current.elems,\r
+               //j     = current.j,\r
+               m     = elems.length,\r
+               xtext = current.xtext,\r
+               skipCleanup = current.skipCleanup,\r
+               elm, tag, text;\r
+\r
+       xnode.parent = parent;\r
+\r
+       for( ; current.j < m; ++current.j ){\r
+               elm = elems[ current.j ];\r
+               tag = elm.tagName;\r
+               if( ( elm.nodeType !== 1 && elm.nodeType !== 3 ) || tag === '!' || ( tag && tag.charAt( 0 ) === '/' ) ){\r
+                       elm.parentNode.removeChild( elm );\r
+                       continue;\r
+               };\r
+\r
+               if( xnode._xnodeType === 1 ){\r
+                       if( elm.nodeType === 3 ){\r
+                               if( !( text = elm.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                                       elm.parentNode.removeChild( elm );\r
+                                       continue;\r
+                               };\r
+                               alert( '[' +parent._tag + '>' +xnode._tag + '] !== ' + elm.nodeType + '\n' + elm.data );\r
+                       } else\r
+                       if( xnode._tag.toUpperCase() !== tag ){\r
+                               alert( '[' +parent._tag + '>' +xnode._tag + ' ' + (xnode._xnodes ? xnode._xnodes.length : '' ) + '] !== ' + tag + ' ' + (elm.childNodes ? elm.childNodes.length : '' ) + '\n' + elm.outerHTML );\r
+                       } else {\r
+                               xnode._rawNode = elm;\r
+                               //if( ( doc = elm.ownerDocument || elm.document ) && ( doc.createElement( 'p' ).tagName === doc.createElement( 'P' ).tagName ) ){\r
+                                       if( tag.charAt( 0 ) === '/' ) tag = tag.slice( 1 );\r
+                                       xnode._tag = tag; // .toUpperCase()\r
+                               //};\r
+                               xnode._root = parent._root;\r
+                               elm.UID     = xnode._uid;\r
+                               \r
+                               if( tag === 'TEXTAREA' ){\r
+                                       xnode.attr( 'value', xnode.html() ).empty();\r
+                               } else\r
+                               if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){ // ie で body 内の script が2度よばれるのに対処\r
+                                       //alert( '[' +parent._tag + '>' + xnode._tag + '] remove ... ' );\r
+                                       xnode.destroy();\r
+                               } else\r
+                               if( elm.childNodes && elm.childNodes.length ){\r
+                                       //alert( '[' +parent._tag + '>' + xnode._tag + ' ' + (xnode._xnodes ? xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (elm.childNodes ? elm.childNodes.length : '' ) + ' Hit\n' + elm.outerHTML );\r
+                                       ++current.j;\r
+                                       return {\r
+                                               me     : xnode,\r
+                                               xnodes : X.copyArray( xnode._xnodes ),\r
+                                               xtext  : null,\r
+                                               flag   : 0,\r
+                                               i      : 0,\r
+                                               l      : xnode._xnodes.length,\r
+                                               elems  : elm.childNodes,\r
+                                               j      : 0,\r
+                                               skipCleanup : skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() )\r
+                                       };\r
+                               };\r
+                               current.xtext = null;\r
+                       };\r
+                       ++current.j;\r
+                       break;\r
+               };\r
+               \r
+               if( elm.nodeType !== 3 ){\r
+                       if( !( text = xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                               console.log( '[' +parent._tag + '>' + xnode._uid + '] destroy ... ' );\r
+                               xnode.destroy();\r
+                               break;\r
+                       };\r
+                       alert(  parent._tag + '>' + '"' + xnode._text + '" !== ' + tag + '\n' + elm.outerHTML );\r
+                       break;\r
+               };\r
+               \r
+               ++current.j;\r
+               xnode._rawNode = elm;\r
+               xnode._root    = parent._root;\r
+               if( !skipCleanup ){\r
+                       if( !( text = xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                               console.log( '[' +parent._tag + '>' + xnode._uid + '] destroy ... ' );\r
+                               xnode.destroy();\r
+                       };\r
+                       if( xtext ){\r
+                               xtext.text( xtext._text + text );\r
+                               console.log( '[' +parent._tag + '>' + xnode._uid + '] xtext,destroy ... ' );\r
+                               xnode.destroy();\r
+                       } else {\r
+                               //alert( parent._tag + '>' + '"' + text + '"\n' + elm.data );\r
+                               xnode.text( text );\r
+                       };\r
+               } else\r
+               if( xtext ){\r
+                       xtext.text( xtext._text + xnode._text );\r
+                       console.log( '[' +parent._tag + '>' + xnode._uid + '] xtext,destroy ... ' );\r
+                       xnode.destroy();\r
+               };\r
+               current.xtext = xtext || xnode;\r
+               break;\r
+       };\r
+}) :\r
+(function ( parent, xnode, current ){\r
+       var elems = current.elems,\r
+               j     = current.j,\r
+               m     = elems.length,\r
+               xtext = current.xtext,\r
+               skipCleanup = current.skipCleanup,\r
+               elm, tag, text;\r
+\r
+       xnode.parent = parent;\r
+       \r
+       if( xnode._xnodeType === 3 ){\r
+               //alert( X.Dom.cleanupWhiteSpace( xnode._text ) );\r
+               if( !skipCleanup ){\r
+                       if( !( text = xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){\r
+                               xnode.destroy();\r
+                       } else\r
+                       if( xtext ){\r
+                               //alert( 'xtext ' + text.charCodeAt( 0 ) + ' : ' + text.length );\r
+                               xtext.text( xtext._text + text );\r
+                               xnode.destroy();\r
+                       } else {\r
+                               //alert( 'xnode ' + text.charCodeAt( 0 ) + ' : ' + text.length );\r
+                               xnode.text( text );\r
+                       };\r
+               } else\r
+               if( xtext ){\r
+                       //alert( 'skip ' + text.charCodeAt( 0 ) + ' : ' + text.length );\r
+                       xtext.text( xtext._text + xnode._text );\r
+                       xnode.destroy();\r
+               };\r
+               current.flag |= 4;\r
+               current.xtext = xtext || xnode;\r
+               return;\r
+       };\r
+       \r
+       if( xnode._xnodeType !== 1 ){\r
+               //alert( xnode._xnodeType )\r
+               return;\r
+       };\r
+       \r
+       for( ; j < m; ++j, ++current.j ){\r
+               elm = elems[ j ];\r
+               tag = elm.tagName;\r
+               /*\r
+                * 未知のタグについては、閉じタグも含めてタグ名扱いになる\r
+                */\r
+               if( tag === '!' || tag.charAt( 0 ) === '/' ){\r
+                       //alert( '## ' + tag );\r
+                       continue;\r
+               } else\r
+               if( xnode._tag !== tag ){\r
+                       alert( xnode._tag + ' ' + ' !== ' + tag + '\nxnode.html():' + xnode.attr('cite') + '\nelm.outerHTML:' +  elm.outerHTML );\r
+               } else {\r
+                       ++current.j;\r
+                       \r
+                       xnode._rawNode = elm;\r
+                       xnode._root    = parent._root;\r
+                       //xnode._tag     = X.Dom.DTD.TAG_FIX[ tag ] || tag;\r
+                       if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){\r
+                               xnode.destroy();\r
+                               break;\r
+                       };\r
+                       \r
+                       !xnode._id && elm.setAttribute( 'id', 'ie4uid' + xnode._uid );\r
+                       elm.setAttribute( 'UID', xnode._uid );\r
+                       \r
+                       tag === 'INPUT' && (\r
+                               !xnode._attrs ?\r
+                                       ( xnode._attrs = { type : 'text' } ) :\r
+                                       !xnode._attrs.type || ( xnode._attrs.type = 'text' )\r
+                       );\r
+                       current.flag |= 3;\r
+                       current.xtext = null;\r
+                       \r
+                       if( tag === 'TEXTAREA' ){\r
+                               xnode.attr( 'value', xnode.html() ).empty();\r
+                       } else\r
+                       if( xnode._xnodes && xnode._xnodes.length ){\r
+                               return {\r
+                                       me     : xnode,\r
+                                       xnodes : X.copyArray( xnode._xnodes ),\r
+                                       xtext  : null,\r
+                                       flag   : 0,\r
+                                       i      : 0,\r
+                                       l      : xnode._xnodes.length,\r
+                                       elems  : elm.children,\r
+                                       j      : 0,\r
+                                       skipCleanup : skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() )\r
+                               };\r
+                       };\r
+                       break;\r
+               };\r
+       };\r
+       // for\r
+       if( !xnode._rawNode ){\r
+               alert( xnode._tag + ' ' + xnode._id + ' !== none...' );\r
+       };\r
+\r
+       // textNode がある\r
+       ( current.flag & 6 ) && ( parent._dirty |= X.Dom.Dirty.IE4_TEXTNODE_FIX );\r
+});\r