OSDN Git Service

Version 0.6.8
authoritozyun <itozyun@user.sourceforge.jp>
Mon, 26 Aug 2013 00:52:31 +0000 (09:52 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Mon, 26 Aug 2013 00:52:31 +0000 (09:52 +0900)
0.6.x/js/core/00_builtin.js
0.6.x/js/core/05_XTimer.js
0.6.x/js/dom/12_XDomParser.js
0.6.x/js/dom/14_XDomNode.js

index ebf6e79..c15f816 100644 (file)
@@ -9,15 +9,10 @@ Function.prototype.apply || (Function.prototype.apply = function (x, y) {
        y = y || [];\r
        \r
        // apply 内で apply を呼んだ場合に備える\r
-       if( x.__apply ){\r
-               if( x === window ){\r
-                       x.__apply = void 0;\r
-               } else {\r
-                       delete x.__apply;\r
-               };\r
-       };\r
-       if( x.constructor && x.constructor.prototype.__apply ){\r
-               delete x.constructor.prototype.__apply;\r
+       if( x === window ){\r
+               x.__apply = void 0;\r
+       } else {\r
+               delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
        };\r
        \r
        x.__apply = this;\r
@@ -43,15 +38,10 @@ Function.prototype.apply || (Function.prototype.apply = function (x, y) {
        };\r
        // delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
        // ie5\r
-       if( x.__apply ){\r
-               if( x === window ){\r
-                       x.__apply = void 0;\r
-               } else {\r
-                       delete x.__apply;\r
-               };\r
-       };\r
-       if( x.constructor && x.constructor.prototype.__apply ){\r
-               delete x.constructor.prototype.__apply;\r
+       if( x === window ){\r
+               x.__apply = void 0;\r
+       } else {\r
+               delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
        };\r
        return r;\r
 });\r
index 9bd177f..5f50b7f 100644 (file)
@@ -91,5 +91,13 @@ X.Timer = ( function(){
                        };\r
                    update();\r
                }\r
+               \r
+               // string only ie4-\r
+               ,_loop : X.UA.IE && X.UA.IE < 5 && (function(){\r
+                       var _loop = loop;\r
+                       loop = 'X.Timer._loop()';\r
+                       return _loop;\r
+               })()\r
+               \r
        };\r
 })();
\ No newline at end of file
index 1511c35..2920185 100644 (file)
@@ -8,8 +8,8 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
 
 (function(){
 
-       var alphabets  = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
-               whiteSpace = '\t\r\n\f\b\v ';
+       var alphabets  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
+               whiteSpace = '\t\r\n\f\b ';
 
        // Empty Elements - HTML 4.01
        var empty = {area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1};
@@ -22,7 +22,25 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
 
        // Elements that you can, intentionally, leave open
        // (and which close themselves)
-       var closeSelf = {colgroup:1,dd:1,dt:1,li:1,options:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1};
+       var closeSelf = {colgroup:1,dd:1,dt:1,li:1,options:1,p:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1}; // add tbody
+
+       var sisters = {
+               th : { td : 1 },
+               td : { th : 1 },
+               dt : { dd : 1 },
+               dd : { dt : 1 },
+               colgroup : { caption : 1 },
+               thead    : { caption : 1, colgroup : 1 },
+               tfoot    : { caption : 1, colgroup : 1, thead : 1, tbody : 1 },
+               tbody    : { caption : 1, colgroup : 1, thead : 1, tfoot : 1 }
+       };
+       /*
+        * http://www.tohoho-web.com/html/tbody.htm
+        * HTML4.01では、ヘッダとフッタを先読みして表示するために、<tbody> よりも <tfoot> の方を先に記述しなくてはならないと定義されています。
+        * IE5.0 などでは HEAD → BODY → FOOT の順に表示するのですが、
+        * <tfoot> に未対応の古いブラウザでは、HEAD → FOOT → BODY の順に表示されてしまいます。
+        * また、HTML5 では、<tfoot> と <tbody> の順番はどちらでもよいことになりました。
+        */
 
        // Attributes that have their values filled in disabled="disabled"
        var fillAttrs = {checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};
@@ -66,6 +84,9 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
                                        if( index = _parseStartTag( stack, last, handler, html ) ){
                                                html  = html.substring( index );
                                                chars = false;
+                                       } else
+                                       if( index === false ){
+                                               return;
                                        };
                                };
 
@@ -154,7 +175,7 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
                        ++i;
                };
                if( phase === 9 ){
-                       parseStartTag( stack, last, handler, tagName.toLowerCase(), attrs, empty );
+                       if( parseStartTag( stack, last, handler, tagName.toLowerCase(), attrs, empty, i ) === false ) return false;;
                        return i;
                };
                return 0; // error
@@ -197,25 +218,26 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
        function saveAttr( attrs, name, value ){
                name  = name.toLowerCase();
                value = fillAttrs[ name ] === 1 ? name : value;
+               var escape = value.indexOf( '"' ) !== -1 && value.split( '"' ).join( '\\"' ).split( '\\\\"' ).join( '\\"' );
                attrs[ attrs.length ] = {
                        name    : name,
                        value   : value,
-                       escaped : value && value.split( '"' ).join( '\\"' ).split( '\\\\"' ).join( '\\"' )
+                       escaped : escape || value
                };
        };
 
-       function parseStartTag( stack, last, handler, tagName, attrs, unary ) {
+       function parseStartTag( stack, last, handler, tagName, attrs, unary, index ) {
                if ( block[ tagName ] === 1 ) {
                        while ( last && inline[ last ] === 1 ) {
                                parseEndTag( stack, handler, last );
                                last = stack[ stack.length - 1 ];
                        };
                };
-               closeSelf[ tagName ] === 1 && last === tagName && parseEndTag( stack, handler, tagName );
+               closeSelf[ tagName ] === 1 && ( last === tagName || ( sisters[ tagName ] && sisters[ tagName ][ last ] === 1 ) ) && parseEndTag( stack, handler, last );
                unary = empty[ tagName ] === 1 || !!unary;
                !unary && ( stack[ stack.length ] = tagName );
                
-               handler.start( tagName, attrs, unary );
+               return handler.start( tagName, attrs, unary, index );
        };
 
        function parseEndTag( stack, handler, tagName ) {
@@ -240,25 +262,25 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
 
 })();
 
-X.Dom._htmlStringToXHtmlNode = {
+X.Dom._htmlStringToXNode = {
        flat : null,
        nest : [],
        err : function( html ){
                this.flat.length = 0;
                this.ignoreError !== true && X.Notification.warn( 'X.Dom.Parser() error ' + html );
        },
-       start : function( tagName, attrs, noChild ){
-               var $,
+       start : function( tagName, attrs, noChild, length ){
+               var xnode,
                        nest = this.nest,
                        flat = this.flat,
                        l    = nest.length;
                if( l ){
-                       $ = nest[ l - 1 ].create( tagName );
+                       xnode = nest[ l - 1 ].create( tagName );
                } else {
-                       $ = flat[ flat.length ] = X.Dom.Node.create( tagName );
+                       xnode = flat[ flat.length ] = X.Dom.Node.create( tagName );
                };
-               $.attr( attrs );
-               if( !noChild ) nest[ l ] = $;
+               xnode.attr( attrs );
+               if( !noChild ) nest[ l ] = xnode;
        },
        end : function(){
                0 < this.nest.length && ( --this.nest.length );
@@ -276,7 +298,7 @@ X.Dom._htmlStringToXHtmlNode = {
 };
 
 X.Dom.parse = function( html, ignoreError ){
-       var worker = X.Dom._htmlStringToXHtmlNode, ret;
+       var worker = X.Dom._htmlStringToXNode, ret;
        worker.flat = [];
        worker.nest.length = 0;
        worker.ignoreError = ignoreError;
index c36f2b7..2292a3a 100644 (file)
@@ -31,13 +31,13 @@ X.Dom.Node = function( v ){
                        case Node.IS_RAW_HTML :\r
                                if( xnode = Node._getXNode( v ) ) return xnode;\r
                                // dom2 || dom0\r
-                               this.parent    = v !== document.body && ( parent = v.parentNode || v.parent ) && Node._getXNode( parent, v );\r
+                               this.parent    = v !== document.body && ( parent = v.parentNode || v.parentElement ) && Node._getXNode( parent );\r
                                this._rawNode  = v;\r
                                this._nodeType = 1;\r
                                break;\r
                        case Node.IS_RAW_TEXT :\r
                                if( xnode = Node._getXNode( v ) ) return xnode;\r
-                               // v.parentNode && ( this.parent = Node._getXNode( v.parentNode ) );\r
+                               this.parent    = Node._getXNode( v.parentNode );\r
                                this._rawNode  = v;\r
                                this._nodeType = 3;\r
                                break;\r
@@ -55,14 +55,7 @@ X.Dom.Node = function( v ){
        this._uid = Node._chashe.length;\r
        Node._chashe[ this._uid ] = this;\r
        \r
-       if( this._rawNode ){\r
-               //alert( this._rawNode.tagName || this._rawNode.data );\r
-               // this._nodeType === 1 && 4 < X.UA.IE && X.UA.IE < 5 ) ?\r
-               //      this._rawNode.setAttribute( 'uid', '' + this._uid ) :\r
-                       this._nodeType === 1 && /*this._rawNode.setAttribute( 'uid', '' + this._uid ); //*/( this._rawNode.uid = this._uid );\r
-               if( 9 < this._uid ) return;\r
-               //alert( ( this._rawNode.tagName || this._rawNode.data ) + this._rawNode.uid );\r
-       };\r
+       this._rawNode && this._nodeType === 1 && v.setAttribute( 'UID', '' + this._uid );\r
 };\r
 \r
 var Node = X.Dom.Node;\r
@@ -76,9 +69,10 @@ Node._getType = function( v ){
        if( typeof v === 'string' ){\r
                return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING;\r
        };\r
+       if( v.nodeType === 11 ) return Node.IS_DOC_FRAG;\r
        return 0;\r
 };\r
-Node.create = function( tag ){\r
+Node.create = function( tag, attr ){\r
        Node._newByTag = true;\r
        return new Node( tag );\r
 };\r
@@ -89,14 +83,14 @@ Node.createText = function( text ){
 \r
 Node._chashe = [];\r
 Node._chashe[ 0 ] = new Node();\r
-Node._getXNode = function( node, v ){\r
+Node._getXNode = function( node ){\r
        if( !node ) return;\r
        var uid;\r
        if( X.UA.IE && X.UA.IE < 5 ){\r
-               uid = parseFloat( node.getAttribute( 'uid' ) );\r
+               uid = parseFloat( node.getAttribute( 'UID' ) );\r
                return uid && Node._chashe[ uid ];\r
        } else {\r
-               return node.uid && Node._chashe[ node.uid ];\r
+               return node.uid && Node._chashe[ node.UID ];\r
        };\r
 };\r
 \r
@@ -113,11 +107,26 @@ Node.hasClass = function( elm , className ){
        return true;\r
 };\r
 \r
+Node.cleanupWhiteSpace = function( text ){\r
+       text.indexOf( '\r\n' ) !== -1 && ( text = text.split( '\r\n' ).join( ' ' ) );\r
+       text.indexOf( '\n\r' ) !== -1 && ( text = text.split( '\n\r' ).join( ' ' ) );\r
+       text.indexOf( '\t' )   !== -1 && ( text = text.split( '\t' ).join( ' ' ) );\r
+       text.indexOf( '\r' )   !== -1 && ( text = text.split( '\r' ).join( ' ' ) );\r
+       text.indexOf( '\n' )   !== -1 && ( text = text.split( '\n' ).join( ' ' ) );\r
+       text.indexOf( '\f' )   !== -1 && ( text = text.split( '\f' ).join( ' ' ) );\r
+       text.indexOf( '\b' )   !== -1 && ( text = text.split( '\b' ).join( ' ' ) );\r
+       while( text.indexOf( '  ' ) !== -1 ){\r
+               text = text.split( '  ' ).join( ' ' );\r
+       };\r
+       return text;\r
+};\r
+\r
 Node.IS_XHNODE      = 1;\r
 Node.IS_RAW_HTML    = 2;\r
 Node.IS_RAW_TEXT    = 3;\r
 Node.IS_HTML_STRING = 4;\r
 Node.IS_STRING      = 5;\r
+Node.IS_DOC_FRAG    = 6;\r
 \r
 Node.prototype._uid       = 0;\r
 Node.prototype._nodeType  = 0;\r
@@ -126,7 +135,7 @@ Node.prototype._tag       = null;
 Node.prototype._text      = null;\r
 Node.prototype._id        = null;\r
 Node.prototype._className = null;\r
-Node.prototype._attr      = null;\r
+Node.prototype._attrs     = null;\r
 Node.prototype._children  = null;\r
 Node.prototype._events    = null;\r
 Node.prototype.parent     = null;\r
@@ -142,7 +151,7 @@ if( document.getElementById ){
                if( elm && children && ( childNodes = elm.childNodes ) ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
                                child = children[ i ];\r
-                               if( child.constractor === Node ) child = child._create( true );\r
+                               if( child.constructor === Node ) child = child._create( true );\r
                                if( typeof child === 'string'  ) child = document.createTextNode( child );\r
                                if( ( _child = childNodes[ i ] ) !== child ){\r
                                        _child ?\r
@@ -184,20 +193,38 @@ Node.prototype._create =
                };\r
                return node;\r
        }) :\r
-       document.all ? (function(){\r
-               var elm, id, html, children, i, l, child;\r
-               if( elm = this._ie4getRawNode() ){\r
-                       // 追加する前に要素を抜く\r
-                       this.remove();\r
-                       return elm.outerHTML;\r
+       document.all ? (function( skipRemove ){\r
+               var elm, id, html, attrs, attr, p, v, children, i, l, child;\r
+               if( this._nodeType !== 1 ) return this._text;\r
+               \r
+               if( elm = this._rawNode || this._ie4getRawNode() ){\r
+                       if( skipRemove ){\r
+                               this._ie4beforeRemove();\r
+                       } else {\r
+                               // 追加する前に要素を抜く\r
+                               this.remove();          \r
+                       };\r
+                       if( !this._ie4containsDirty() ){\r
+                               return this._htmlText;\r
+                       };\r
+               };\r
+               id   = this._id || this._ie4uid || ( 'ie4uid' + this._uid );\r
+               if( id !== this._id ) this._ie4uid = id;\r
+               html = [ '<', this._tag, id ? ( ' id="' + id + '"' ) : '' ];\r
+               if( attrs = this._attrs ){\r
+                       for ( i = 0, l = attrs.length; i < l; ++i ){\r
+                               attr = attrs[ i ];\r
+                               //if( attr.name === 'id' ) continue;\r
+                               html[ html.length ] = ' ' + ( attr.name || attr ) + '="' + ( attr.escaped || attr ) + '"';\r
+                               //if( attr.name === 'href' ) alert( attr.escaped );\r
+                       };\r
                };\r
-               // attr\r
-               id       = this._id || this._ie4uid || ( 'ie4uid_' + ( ++Node.ie4uid ) );\r
-               html     = [ '<', this._tag, id ? ( ' id="' + id + '"' ) : '', '>' ];\r
+               html[ html.length ] = '>';\r
+\r
                if( ( children = this._children ) && ( l = children.length ) ){\r
                        for( i = 0; i < l; ++i ){\r
                                child = children[ i ];\r
-                               html[ html.length ] = child.constractor === Node ? child._create() : ( child.outerHTML || child );\r
+                               html[ html.length ] = child.constructor === Node && child._create( skipRemove );\r
                        };\r
                };\r
                html[ html.length ] = '<\/' + this._tag + '>';\r
@@ -227,7 +254,7 @@ Node.prototype._afterCreate =
                if( _children ){\r
                        for( i = 0, l = _children.length; i < l; ++i ){\r
                                _child = _children[ i ];\r
-                               _child.constractor === Node ? _child._afterCreate( this ) : ( _children[ i ] = eChildren[ i ] );\r
+                               _child.constructor === Node ? _child._afterCreate( this ) : ( _children[ i ] = eChildren[ i ] );\r
                        };\r
                } else\r
                if( eChildren && eChildren.length ){\r
@@ -237,47 +264,33 @@ Node.prototype._afterCreate =
                return this;\r
        }) :\r
        document.all ? (function( parent ){\r
-               var elm       = this._nodeType === 1 && this._ie4getRawNode(),\r
-                       _children = this._children,\r
-                       eChildren = elm && elm.innerHTML && Node._ie4getChildNodes( elm ),\r
-                       _child, i, l;\r
+               var elm,\r
+                       children = this._children,\r
+                       child, i, l;\r
                this.parent = parent;\r
-               /*\r
-                * elm.children を this._children にリンクさせる\r
-                */\r
-               if( _children ){\r
-                       for( i = 0; i < l; ++i ){\r
-                               _child = _children[ i ];\r
-                               if( _child.constractor === Node ){\r
-                                       if( _child._ie4getRawNode() === eChildren[ i ] ){\r
-                                               _child._afterCreate( this );\r
-                                       } else {\r
-                                               alert( 'error XHTMLElement._afterCreate() _child._ie4getRawNode() === eChildren[ i ]' );\r
-                                       };\r
-                               } else\r
-                               if( _child !== eChildren[ i ] ){\r
-                                       alert( 'error XHTMLElement._afterCreate() _child !== eChildren[ i ]' );\r
-                               };\r
-                       };\r
-               } else\r
-               if( eChildren ){\r
-                       this._children = eChildren;\r
-               } else {\r
+               delete this._ie4dirty;\r
+               \r
+               if( this._nodeType !== 1 ) return;\r
 \r
+               delete this._rawNode;\r
+               delete this._ie4dirtyChildren;\r
+               \r
+               if( children ){\r
+                       for( i = children.length; i; ){\r
+                               children[ --i ]._afterCreate( this );\r
+                       };\r
                };\r
                /*\r
                 * イベントの復帰 if( this._events && ( elm = this._ie4getRawNode() ) )\r
                 */\r
-               \r
-               delete this._ie4dirty;\r
-               delete this._ie4dirtyChildren;\r
+               elm = this._ie4getRawNode();\r
        }) :\r
        (function(){});\r
 \r
 /* --------------------------------------\r
  *  Create\r
  */\r
-Node.prototype.create = function( tag ){\r
+Node.prototype.create = function( tag, attrs ){\r
        var elm, xnode;\r
        if( this._nodeType !== 1 ) return;\r
        if( !this._children ) this._children = [];\r
@@ -288,10 +301,13 @@ Node.prototype.create = function( tag ){
                if( document.appendChild ){\r
                        elm.appendChild( document.createElement( tag ) );\r
                        xnode = new Node( elm.lastChild );\r
+                       xnode.attr( attrs );\r
                } else\r
                if( document.all ){\r
-                       elm.insertAdjacentHTML( 'BeforeEnd', '<' + tag + '>' );\r
-                       xnode = new Node( elm.children[ elm.children.length - 1 ] );\r
+                       Node._newByTag = true;\r
+                       xnode = new Node( tag, attrs );\r
+                       elm.insertAdjacentHTML( 'BeforeEnd', xnode._create() );\r
+                       xnode._rawNode = elm.children[ elm.children.length - 1 ];\r
                } else {\r
                        \r
                };\r
@@ -346,6 +362,7 @@ Node.prototype.append = function( v ){
        \r
        if( 1 < arguments.length ){\r
                for( i = 0, l = arguments.length; i < l; ++i ){\r
+                       // Node.fragment.append( arguments[ i ] )\r
                        this.append( arguments[ i ] );\r
                };\r
                return this;\r
@@ -368,19 +385,11 @@ Node.prototype.append = function( v ){
                                        \r
                                };\r
                        };\r
-                       this._children[ this._children.length ] = v;\r
+                       this._children[ this._children.length ] = new Node( v );\r
                        break;\r
                case Node.IS_HTML_STRING :\r
                case Node.IS_STRING :\r
-                       v = X.Dom.parse( v, true );\r
-                       if( elm ){\r
-                               for( i = 0, l = v.length; i < l; ++i ){\r
-                                       this.append( v[ i ] );\r
-                               };\r
-                       } else\r
-                       if( v.length ){\r
-                               this._children.push.apply( this._children, v );\r
-                       };\r
+                       this.append( X.Dom.parse( v, true ) );\r
                        break;\r
                case Node.IS_XHNODE :\r
                        if( elm ){\r
@@ -405,12 +414,13 @@ Node.prototype.appendAt = function( start, v ){
        var l = arguments.length,\r
                children = this._children,\r
                node, i, prev, next;\r
-       if( this._nodeType !== 1 ) return;\r
+       if( this._nodeType !== 1 ) return this;\r
        \r
        if( !children ) children = this._children = [];\r
        \r
        if( children.length <= start ){\r
                for( i = 1; i < l; ++i ){\r
+                       // Node.fragment.append( arguments[ i ] )\r
                        return this.append( arguments[ i ] );\r
                };\r
                return this;\r
@@ -418,11 +428,11 @@ Node.prototype.appendAt = function( start, v ){
        if( start < 0 ) start = 0;\r
        if( 2 < l ){\r
                for( ; l; ){\r
+                       // Node.fragment.appendAt( 0, arguments[ i ] )\r
                        this.appendAt( start, arguments[ --l ] );\r
                };\r
                return this;\r
        };\r
-       if( this._nodeType !== 1 ) return this;\r
        \r
        if( !this.parent ){\r
                children.splice( start, 0, v );\r
@@ -491,11 +501,17 @@ Node.prototype.appendAt = function( start, v ){
 };\r
 \r
 Node.prototype.appendTo = function( parent, opt_start ){\r
-       !opt_start ? new Node( parent ).append( this ) : new Node( parent ).appendAt( opt_start, this );\r
+       if( parent.constructor === Node ){\r
+               opt_start === undefined ? parent.append( this ) : parent.appendAt( opt_start, this );\r
+       } else {\r
+               opt_start === undefined ? new Node( parent ).append( this ) : new Node( parent ).appendAt( opt_start, this );\r
+       };\r
+       return this;\r
 };\r
 \r
 Node.prototype.appendToRoot = function( opt_start ){\r
        !opt_start ? Node.root.append( this ) : Node.root.appendAt( opt_start, this );\r
+       return this;\r
 };\r
 \r
 /* --------------------------------------\r
@@ -528,7 +544,7 @@ Node.prototype.remove = function(){
                \r
        };\r
 \r
-       parent._children.splice( parent._children.indexOf( v ), 1 );\r
+       parent._children.splice( parent._children.indexOf( this ), 1 );\r
        delete this.parent;\r
        return this;\r
 };\r
@@ -554,142 +570,94 @@ Node.prototype.destroy = function( v ){
 if( !document.getElementById && document.all ){\r
        Node.prototype._ie4beforeRemove = function(){\r
                var children = this._children,\r
-                       child, i, l, elm;\r
+                       child, i, l, elm, id;\r
                if( children ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
                                child = children[ i ];\r
-                               child.constractor === Node && child._ie4beforeRemove();\r
+                               child.constructor === Node && child._ie4beforeRemove();\r
                        };      \r
                };\r
                if( elm = this._ie4getRawNode() ){\r
                        // イベントの削除\r
-                       if( elm.id && elm.id !== this._ie4uid ){\r
-                               this._id = elm.id;\r
+                       if( ( id = elm.getAttribute( 'id' ) ) && id !== this._ie4uid ){\r
+                               this._id = id;\r
                        } else\r
-                       if( !elm.id ){\r
-                               this._ie4uid = elm.id = 'ie4uid_' + ( ++Node.ie4uid );\r
+                       if( !id ){\r
+                               elm.setAttribute( 'id', ( this._ie4uid = 'ie4uid' + this._uid ) );\r
                        };\r
                        this._htmlText = elm.outerHTML;\r
-                       delete this._rawNode;\r
+                       elm.removeAttribute( 'id' );\r
                };\r
        };\r
        \r
        Node.prototype._ie4getRawNode = function(){\r
-               var elm, uid;\r
-               if( ( elm = this._rawNode ) && elm.parentElement ) return elm;\r
-               if( ( uid = this._id ) && ( elm = document.all[ uid ] ) ){\r
-                       return ( this._rawNode = elm );\r
+               var elm, uid, all, i, l;\r
+               if( elm = this._rawNode ) return elm;\r
+               if( ( uid = this._id ) && ( elm = this._rawNode = document.all[ uid ] ) ){\r
+                       return elm;\r
                };\r
-               if( ( uid = this._ie4uid ) && ( elm = document.all[ uid ] ) ){\r
-                       delete this._ie4uid;\r
-                       delete this._htmlText;\r
-                       if( this._id ) elm.id = this._id;\r
-                       return ( this._rawNode = elm );\r
+               if( ( uid = this._ie4uid ) && ( elm = this._rawNode = document.all[ uid ] ) ){\r
+                       if( this._id ) elm.setAttribute( 'id', this._id );\r
+                       return elm;\r
                };\r
        };\r
        \r
-       Node.ie4uid = 0;\r
-       \r
        Node.prototype._ie4reserveUpdate = function( child ){\r
                var root = Node.root;\r
                child && ( child._ie4dirty = true );\r
                this._ie4dirtyChildren = true;\r
-               if( root._reserved === true ) return;\r
-               root._reserved = true;\r
+               if( root._ie4reserved === true ) return;\r
+               root._ie4reserved = true;\r
                X.Timer.once( 1, root, root._ie4startUpdate );\r
        };\r
        \r
        Node.prototype._ie4startUpdate = function(){\r
-               if( this._reserved !== true ) return;\r
-               //if( this._ie4getRawNode() ) this._rawNode = document.all.tags( 'BODY' )[ 0 ];\r
-               // !this._rawNode && onload(  )\r
-               delete this._reserved;\r
+               if( this._ie4reserved !== true ) return;\r
+               delete this._ie4reserved;\r
                if( !this._children ) return;\r
                this._ie4commitUpdate()._ie4afterUpdate();\r
        };\r
        \r
        Node.prototype._ie4commitUpdate = function(){\r
                var children = this._children,\r
-                       i, l, child, html;\r
-               if( !this._ie4dirtyChildren && !this._ie4dirty ){\r
+                       i, l, html;\r
+               if( !this._ie4dirtyChildren ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
-                               child = children[ i ];\r
-                               child.constractor === Node && child._ie4commitUpdate();\r
+                               children[ i ]._ie4commitUpdate();\r
                        };\r
                        return this;\r
                };\r
                html = [];\r
                for( i = 0, l = children.length; i < l; ++i ){\r
-                       child = children[ i ];\r
-                       html[ html.length ] = child.constractor === Node ?\r
-                               ( child._ie4dirty ? child._ie4commitUpdate() : child._create() ) :\r
-                               ( child.outerHTML || child );\r
-               };\r
-               if( !this._ie4dirty ){\r
-                       this._rawNode.innerHTML = html.join( '' );\r
-                       return this;\r
+                       html[ html.length ] = children[ i ]._create( true );\r
                };\r
-               return html.join( '' );\r
+               this._rawNode.innerHTML = html.join( '' );\r
+               return this;\r
        };\r
        \r
        Node.prototype._ie4afterUpdate = function(){\r
                var children = this._children,\r
-                       i, l, child;\r
-               if( !this._ie4dirtyChildren && !this._ie4dirty ){\r
+                       i, l;\r
+               if( !this._ie4dirtyChildren ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
-                               child = children[ i ];\r
-                               child.constractor === Node && child._ie4afterUpdate();\r
+                               children[ i ]._ie4afterUpdate();\r
                        };\r
+                       return this;\r
                };\r
-\r
                for( i = 0, l = children.length; i < l; ++i ){\r
-                       child = children[ i ];\r
-                       child.constractor === Node &&\r
-                               ( child._ie4dirty ? child._ie4afterUpdate() : child._afterCreate( this ) );\r
+                       children[ i ]._afterCreate( this );\r
                };\r
                delete this._ie4dirtyChildren;\r
-               delete this._ie4dirty;\r
        };\r
        \r
-       /*\r
-        * ie4 に TextNode は存在しない。       よって、Element.children にテキストノードは無視される。\r
-        * そこでテキストノードを判定して控える操作が必要になる。\r
-        * elm と string( TextNode の変わり ) の混在する配列が返る\r
-        * return [ elm, 'text', elm, elm, ...  ]\r
-        */\r
-       Node._ie4getChildNodes = function( elm ){\r
-               var html     = elm.innerHTML,\r
-                       children = elm.children,\r
-                       l        = children.length,\r
-                       _        = '',\r
-                       cr, i, j, child, outer, index, nodes;\r
-               if( l < 1 ){\r
-                       if( html.length ) return [ html ]; // new X.TextNode( html );\r
-                       return [];\r
+       Node.prototype._ie4containsDirty = function(){\r
+               var children, i;\r
+               if( this._nodeType !== 1 ) return;\r
+               if( this._ie4dirtyChildren || this._ie4dirty ) return true;\r
+               if( !( children = this._children ) || !( i = children.length ) ) return;\r
+               for( ; i; ){\r
+                       if( children[ --i ]._ie4containsDirty() ) return true;\r
                };\r
-               cr    = Node._ie4getCRCChars( html );\r
-               nodes = [];\r
-               j     = -1;\r
-               html = html.split( cr ).join( _ );\r
-               for( i = 0; i <= l; ++i ){\r
-                       child = children[ i ];\r
-                       outer = child.outerHTML.split( cr ).join( _ );\r
-                       index = html.indexOf( outer );\r
-                       if( index === -1 ){\r
-                               alert( 'Node._ie4getChildNodes\n' + outer + '\n' + html.substr( 0, 100 ) );\r
-                               continue;\r
-                       };\r
-                       if( 0 < index ) nodes[ ++j ] = html.substr( 0, index ); // new X.TextNode( html );\r
-                       nodes[ ++j ] = child; // Element\r
-                       html = html.substr( index + outer.length );\r
-               };\r
-               if( html.length ) nodes[ ++j ] = html; // new X.TextNode( html );\r
-               return nodes;\r
-       };\r
-       Node._ie4getCRCChars = function( src ){\r
-               return 0 <= src.indexOf( '\r\n' ) ? '\r\n' :\r
-                       0 <= src.indexOf( '\n' ) ? '\n' :\r
-                       0 <= src.indexOf( '\r' ) ? '\r' : '\n';\r
        };\r
 };\r
 \r
@@ -724,31 +692,9 @@ Node.prototype.getChildAt = function( index ){
        var children = this._children,\r
                elm, childNodes, child, xnode;\r
        if( this._nodeType !== 1 || index < 0 ) return;\r
-       if( !children ){\r
-               elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
-               if( !elm ){\r
-                       if( v === 0 && this.text ){\r
-                               children = this._children = [ this.text ];\r
-                       } else {\r
-                               return;\r
-                       };\r
-               } else {\r
-                       /* DOM level2 */\r
-                       if( childNodes = elm.childNodes ){\r
-                               children = this._children = [];\r
-                               children.push.apply( children, childNodes );\r
-                       } else\r
-                       /* ie4 DOM */\r
-                       if( elm.innerHTML ){\r
-                               children = this._children = Node._ie4getChildNodes( elm );\r
-                       } else {\r
-                               return;\r
-                       };\r
-               };\r
-       };\r
        if( children.length <= index ) return;\r
        child = children[ index ];\r
-       if( child.constractor === Node ) return child;\r
+       if( child.constructor === Node ) return child;\r
        xnode = new Node( child );\r
        xnode.parent = this;\r
        return children[ index ] = xnode;\r
@@ -768,7 +714,7 @@ Node.prototype.getByTag = function( tag ){
        } else\r
        if( document.all ){\r
                if( !( elm = this._ie4getRawNode() ) ) return;\r
-               Node.root._reserved === true && Node.root._ie4startUpdate();\r
+               Node.root._ie4reserved === true && Node.root._ie4startUpdate();\r
                new X.Dom.NodeList( elm.all.tags( tag ) );      \r
        } else {\r
                \r
@@ -860,7 +806,8 @@ Node.prototype.getOrder = function(){
 /* --------------------------------------\r
  *  attribute\r
  */\r
-Node.prototype.attr = function(){\r
+Node.prototype.attr = function( v ){\r
+       if( v.length && v[ v.length - 1 ] ) this._attrs = v;\r
 };\r
 \r
 /* --------------------------------------\r
@@ -874,7 +821,7 @@ Node.prototype.width = function(){
        } else\r
        if( document.all ){\r
                if( !( elm = this._ie4getRawNode() ) ) return 0;\r
-               Node.root._reserved === true && Node.root._ie4startUpdate();\r
+               Node.root._ie4reserved === true && Node.root._ie4startUpdate();\r
                return elm.offsetWidth;         \r
        } else {\r
                \r
@@ -889,7 +836,7 @@ Node.prototype.height = function(){
        } else\r
        if( document.all ){\r
                if( !( elm = this._ie4getRawNode() ) ) return 0;\r
-               Node.root._reserved === true && Node.root._ie4startUpdate();\r
+               Node.root._ie4reserved === true && Node.root._ie4startUpdate();\r
                return elm.offsetHeight;                \r
        } else {\r
                \r
@@ -901,11 +848,13 @@ Node.prototype.height = function(){
  */\r
 \r
 \r
-\r
+/* --------------------------------------\r
+ *  load\r
+ */\r
 X.Dom.Event.add( window, 'load', function(){\r
        var r   = Node.root = new Node( document.body ),\r
                elm = r._rawNode,\r
-               createTree;\r
+               createTree, n = 0;\r
        r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );\r
        \r
        if( elm.childNodes ){\r
@@ -921,54 +870,66 @@ X.Dom.Event.add( window, 'load', function(){
                                        _xnode.parent = xnode;\r
                                        child.childNodes.length && createTree( _xnode, child, child.childNodes );\r
                                } else\r
-                               if( child.nodeType === 3 ){\r
+                               if( child.nodeType === 3 && child.data !== '' && Node.cleanupWhiteSpace( child.data ) !== ' ' ){\r
                                        if( !xnode._children ) xnode._children = [];\r
                                        xnode._children[ xnode._children.length ] = new Node( child );\r
                                } else {\r
                                        elm.removeChild( child );\r
                                        --i;\r
                                        --l;\r
+                                       ++n;\r
                                };\r
                        };\r
                };\r
                createTree( r, elm, elm.childNodes );\r
+               alert( n)\r
        } else\r
        if( elm.children ){\r
                createTree = function( xnode, children ){\r
                        var i = 0,\r
                                l = children.length,\r
-                               j = 0, child, _xnode;\r
-                       \r
-                       var nodes = [];\r
-                       for( ; i < xnode._children.length; ++i ){\r
-                               child = xnode._children[ i ];\r
-                               nodes.push( child._tag || child._text );\r
-                       };\r
-                       i = 0;\r
+                               j = 0,\r
+                               child, _xnode, f;\r
+\r
+                       xnode._ie4dirtyChildren = true;\r
                        for( ; i < l; ++i ){\r
                                child = children[ i ];\r
-                               alert( xnode._rawNode.tagName + '[' + nodes.join( ', ' ) + '] > "' + child.tagName + '" ' + j + '/' + xnode._children.length )\r
+                               if( child.tagName === '!' ) continue;\r
+                               f = false;\r
                                while( j < xnode._children.length ){\r
                                        _xnode = xnode._children[ j ];\r
-                                       ++j;\r
+                                       _xnode.parent    = xnode;\r
+                                       _xnode._ie4dirty = true;\r
                                        if( _xnode._nodeType === 1 ){\r
-                                               _xnode._rawNode = child;\r
-                                               _xnode.parent   = xnode;\r
-                                               //alert( _xnode._tag + ' <= ' + child.tagName );\r
-                                               child.children.length && createTree( _xnode, child.children );\r
-                                               break;\r
+                                               if( _xnode._tag !== child.tagName.toLowerCase() ){\r
+                                                       alert( _xnode._tag + ' !== ' + child.tagName + ' * ' + child.outerHTML );\r
+                                               } else {\r
+                                                       _xnode._rawNode = child;\r
+                                                       !child.getAttribute( 'id' ) && child.setAttribute( 'id', ( _xnode._ie4uid = 'ie4uid' + _xnode._uid ) );\r
+                                                       child.setAttribute( 'UID', _xnode._uid );\r
+                                                       child.children.length && createTree( _xnode, child.children );\r
+                                                       f = true;\r
+                                                       ++j;\r
+                                                       break;                  \r
+                                               };\r
+                                       } else\r
+                                       if( _xnode._nodeType === 3 ){\r
+                                               if( !_xnode._text || Node.cleanupWhiteSpace( _xnode._text ) === ' ' ){\r
+                                                       _xnode.remove();\r
+                                                       ++n;\r
+                                                       continue;\r
+                                               };\r
                                        };\r
+                                       ++j;\r
                                };\r
+                               if( !f ) alert( '**** ' + child.outerHTML );\r
                        };\r
                };\r
                r._children = [];\r
-               nodes = X.Dom.parse( elm.innerHTML, true );\r
-               for( i = nodes.length; i; ){\r
-                       r._children[ --i ] = nodes[ i ];\r
-                       alert( nodes[ i ]._tag || nodes[ i ]._text )\r
-               };\r
+               r._children.push.apply( r._children, X.Dom.parse( elm.innerHTML, true ) );\r
                createTree( r, elm.children );\r
-               delete r._reserved;\r
+               r._ie4reserveUpdate();\r
+               //alert(n +  ' ' + elm.innerHTML)\r
        } else {\r
                \r
        };\r