OSDN Git Service

Version 0.6.7
authoritozyun <itozyun@user.sourceforge.jp>
Thu, 22 Aug 2013 23:57:52 +0000 (08:57 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Thu, 22 Aug 2013 23:57:52 +0000 (08:57 +0900)
0.6.x/js/core/00_builtin.js
0.6.x/js/dom/12_XDomParser.js
0.6.x/js/dom/13_XDomEvent.js
0.6.x/js/dom/14_XDomNode.js
0.6.x/js/dom/15_XDomNodeList.js

index b9cd992..ebf6e79 100644 (file)
@@ -6,7 +6,20 @@
 Function.prototype.apply || (Function.prototype.apply = function (x, y) {\r
        var a, i, r, j;\r
        x = x || window;\r
-       y = y ||[];\r
+       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
+       };\r
+       \r
        x.__apply = this;\r
        if (!x.__apply) x.constructor.prototype.__apply = this;\r
        j = y.length;\r
@@ -27,8 +40,19 @@ Function.prototype.apply || (Function.prototype.apply = function (x, y) {
                                a[i] = 'y[' + i + ']';\r
                        r = eval('x.__apply(' + a.join(',') + ')');\r
                        break;\r
-       }\r
-       delete x.__apply ? x.__apply : x.constructor.prototype.__apply;\r
+       };\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
+       };\r
        return r;\r
 });\r
 Function.prototype.call || (Function.prototype.call = function () {\r
index de5c756..1511c35 100644 (file)
@@ -241,7 +241,7 @@ X.Dom = function(){ if( X.Dom._shortcut ) return X.Dom._shortcut.apply( this, ar
 })();
 
 X.Dom._htmlStringToXHtmlNode = {
-       flat : undefined,
+       flat : null,
        nest : [],
        err : function( html ){
                this.flat.length = 0;
@@ -250,24 +250,24 @@ X.Dom._htmlStringToXHtmlNode = {
        start : function( tagName, attrs, noChild ){
                var $,
                        nest = this.nest,
-                       flat = this.flat;
-               if( $ = nest[ nest.length - 1 ] ){
-                       $ = $.create( tagName ).lastChild();
+                       flat = this.flat,
+                       l    = nest.length;
+               if( l ){
+                       $ = nest[ l - 1 ].create( tagName );
                } else {
-                       $ = flat[ flat.length ] = X.Dom.create( tagName );
+                       $ = flat[ flat.length ] = X.Dom.Node.create( tagName );
                };
                $.attr( attrs );
-               if( !noChild ) nest[ nest.length ] = $;
+               if( !noChild ) nest[ l ] = $;
        },
        end : function(){
                0 < this.nest.length && ( --this.nest.length );
        },
        chars : function( text ){
-               var $;
-               if( $ = this.nest[ this.nest.length - 1 ] ){
-                       $.createText( text );
+               if( this.nest.length ){
+                       this.nest[ this.nest.length - 1 ].createText( text );
                } else {
-                       this.flat[ this.flat.length ] = X.Dom.createText( text );
+                       this.flat[ this.flat.length ] = X.Dom.Node.createText( text );
                };
        },
        comment : function(){
@@ -283,6 +283,6 @@ X.Dom.parse = function( html, ignoreError ){
        X.Dom.Parser( html, worker );
        ret = worker.flat;
        delete worker.flat;
-       return ret.length < 2 ? ret[ 0 ] : ret; 
+       return ret;
 };
 
index 2da4b0e..49bfc51 100644 (file)
@@ -109,12 +109,11 @@ X.Dom.Event._Helper.prototype.handleEvent =
        window.addEventListener ?
                (function( e ){
                        var list = this.list,
-                               l    = list.length,
                                e    = new X.Dom.Event( e ),
                                i    = 0,
                                ret  = 0,
                                f, r;
-                       for( ; i < l; ++i ){
+                       for( ; i < list.length; ){
                                f = list[ i ];
                                r = f( e );
                                ret |= r;
@@ -122,6 +121,8 @@ X.Dom.Event._Helper.prototype.handleEvent =
                                        list.splice( i, 1 );
                                        X.Callback._correct( f );
                                        list.length === 0 && this.removeEvent();
+                               } else {
+                                       ++i;
                                };
                                if( r & X.Callback.CANCEL_NOW ) break;
                        };
@@ -135,12 +136,11 @@ X.Dom.Event._Helper.prototype.handleEvent =
                }) :
                (function(){
                        var list = this.list,
-                               l    = list.length,
                                e    = new X.Dom.Event( event, this.elm ),
                                i    = 0,
                                ret  = 0,
                                r, f;
-                       for( ; i < l; ++i ){
+                       for( ; i < list.length; ){
                                f = list[ i ];
                                r = f( e );
                                ret |= r;
@@ -148,6 +148,8 @@ X.Dom.Event._Helper.prototype.handleEvent =
                                        list.splice( i, 1 );
                                        X.Callback._correct( f );
                                        list.length === 0 && this.removeEvent();
+                               } else {
+                                       ++i;
                                };
                                if( r & X.Callback.CANCEL_NOW ) break;
                        };
@@ -179,7 +181,7 @@ X.Dom.Event._Helper.prototype.removeEvent =
                        X.Dom.Event._LIST.splice( X.Dom.Event._LIST.indexOf( this ), 1 );
                }) :
                (function(){
-                       this.elm[ 'on' + this.type ] = emptyFunc;
+                       this.elm[ 'on' + this.type ] = X.Dom.Event.emptyFunc;
                        this.elm[ 'on' + this.type ] = '';
                        X.Callback._correct( this.callback );
                        delete this.elm;
index dbd7648..c36f2b7 100644 (file)
@@ -1,43 +1,45 @@
 \r
 /*\r
  * Node( rawElement | rawTextnode | htmlString | textString )\r
- * input=text ui#only.first > li.odd, li.even, li.odd\r
  */\r
-\r
-var Node = X.Dom.Node = function( v ){\r
-       var nodeList, xnode, uid;\r
+;(function( window, document, undeifned ){\r
+X.Dom.Node = function( v ){\r
+       var nodeList, xnode, parent, uid;\r
        \r
        if( Node._newByTag ){\r
-               delete Node._createByTag;\r
-               this._tag = v;\r
+               delete Node._newByTag;\r
+               this._tag      = v;\r
+               this._nodeType = 1;\r
        } else\r
        if( Node._newByText ){\r
-               delete Node._createByText;\r
-               this._text = v;\r
+               delete Node._newByText;\r
+               this._text     = v;\r
+               this._nodeType = 3;\r
        } else {\r
                if( 1 < arguments.length ){\r
                        return new X.Dom.NodeList( arguments );\r
                };\r
-               if( v && 1 < v.length ){\r
+               if( v && 1 < v.length && typeof v !== 'string' && v[ v.length - 1 ] ){\r
                        return new X.Dom.NodeList( v );\r
                };\r
-               \r
-               if( !this || this.constractor !== Node ) return new Node( v );\r
-               \r
+\r
+               if( !this || this.append !== Node.prototype.append ) return new Node( v );\r
+\r
                switch( Node._getType( v ) ){\r
                        case Node.IS_XHNODE :\r
                                return v;\r
                        case Node.IS_RAW_HTML :\r
                                if( xnode = Node._getXNode( v ) ) return xnode;\r
-                               ( uid = v.parentNode.uid ) && ( this.parent = Node._chashe[ uid ] );\r
-                               this._rawNode = v;\r
-                               this._type    = 1;\r
+                               // dom2 || dom0\r
+                               this.parent    = v !== document.body && ( parent = v.parentNode || v.parent ) && Node._getXNode( parent, v );\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
-                               ( uid = v.parentNode.uid ) && ( this.parent = Node._chashe[ uid ] );\r
-                               this._rawNode = v;\r
-                               this._type    = 3;\r
+                               // v.parentNode && ( this.parent = Node._getXNode( v.parentNode ) );\r
+                               this._rawNode  = v;\r
+                               this._nodeType = 3;\r
                                break;\r
                        case Node.IS_HTML_STRING :\r
                        case Node.IS_STRING :\r
@@ -45,18 +47,26 @@ var Node = X.Dom.Node = function( v ){
                                if( nodeList.length ) return nodeList[ 0 ];\r
                                return Node._chashe[ 0 ];\r
                        default :\r
-                               return Node._chashe[ 0 ];\r
+                               if( Node._chashe.length ) return Node._chashe[ 0 ];\r
+                               return;\r
                };              \r
        };\r
        \r
        this._uid = Node._chashe.length;\r
        Node._chashe[ this._uid ] = this;\r
-       this._rawNode &&\r
-               ( this._type === 1 && 4 < X.UA.IE && X.UA.IE < 6 ) ?\r
-                       this._rawNode.setAttribute( 'uid', this._uid ) :\r
-                       ( this._rawNode.uid = this._uid );\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
 };\r
 \r
+var Node = X.Dom.Node;\r
+\r
 Node._getType = function( v ){\r
        if( v === '' ) return Node.IS_STRING;\r
        if( !v ) return 0;\r
@@ -68,10 +78,26 @@ Node._getType = function( v ){
        };\r
        return 0;\r
 };\r
+Node.create = function( tag ){\r
+       Node._newByTag = true;\r
+       return new Node( tag );\r
+};\r
+Node.createText = function( text ){\r
+       Node._newByText = true;\r
+       return new Node( text );\r
+};\r
 \r
-Node._chashe = [ new Node() ];\r
-Node._getXNode = function( node ){\r
-       return node.uid && Node._chashe[ node.uid ];\r
+Node._chashe = [];\r
+Node._chashe[ 0 ] = new Node();\r
+Node._getXNode = function( node, v ){\r
+       if( !node ) return;\r
+       var uid;\r
+       if( X.UA.IE && X.UA.IE < 5 ){\r
+               uid = parseFloat( node.getAttribute( 'uid' ) );\r
+               return uid && Node._chashe[ uid ];\r
+       } else {\r
+               return node.uid && Node._chashe[ node.uid ];\r
+       };\r
 };\r
 \r
 Node.hasClass = function( elm , className ){\r
@@ -94,13 +120,15 @@ Node.IS_HTML_STRING = 4;
 Node.IS_STRING      = 5;\r
 \r
 Node.prototype._uid       = 0;\r
-Node.prototype._type      = 0;\r
+Node.prototype._nodeType  = 0;\r
 Node.prototype._rawNode   = null;\r
 Node.prototype._tag       = null;\r
 Node.prototype._text      = null;\r
 Node.prototype._id        = null;\r
 Node.prototype._className = null;\r
 Node.prototype._attr      = null;\r
+Node.prototype._children  = null;\r
+Node.prototype._events    = null;\r
 Node.prototype.parent     = null;\r
 \r
 /* --------------------------------------\r
@@ -134,7 +162,8 @@ if( document.getElementById ){
  *  Create\r
  */\r
 Node.prototype._create =\r
-       document.createElement ? (function( isChild ){\r
+       // document.createElement of ie4 is only for OPTION & IMAGE.\r
+       ( document.appendChild ) ? (function( isChild ){\r
                var tag = this._tag, node, frg;\r
                if( tag === 'input' ){\r
                        // ie7 以下では createElement では name 等が働かない!\r
@@ -177,7 +206,7 @@ Node.prototype._create =
        (function(){});\r
 \r
 Node.prototype._afterCreate =\r
-       document.createElement ? (function( parent ){\r
+       ( document.appendChild ) ? (function( parent ){\r
                var _children = this._children,\r
                        node      = this._rawNode,\r
                        eChildren = node.childNodes,\r
@@ -193,7 +222,7 @@ Node.prototype._afterCreate =
                        delete this._isNew;\r
                };\r
                /*\r
-                * elm.childNodes を __.children にリンクさせる\r
+                * elm.childNodes を this._children にリンクさせる\r
                 */\r
                if( _children ){\r
                        for( i = 0, l = _children.length; i < l; ++i ){\r
@@ -208,13 +237,13 @@ Node.prototype._afterCreate =
                return this;\r
        }) :\r
        document.all ? (function( parent ){\r
-               var elm       = this._ie4getRawNode(),\r
+               var elm       = this._nodeType === 1 && this._ie4getRawNode(),\r
                        _children = this._children,\r
-                       eChildren = elm.innerHTML && Node._ie4getChildNodes( elm ),\r
+                       eChildren = elm && elm.innerHTML && Node._ie4getChildNodes( elm ),\r
                        _child, i, l;\r
                this.parent = parent;\r
                /*\r
-                * elm.children を __.children にリンクさせる\r
+                * elm.children を this._children にリンクさせる\r
                 */\r
                if( _children ){\r
                        for( i = 0; i < l; ++i ){\r
@@ -231,13 +260,13 @@ Node.prototype._afterCreate =
                                };\r
                        };\r
                } else\r
-               if( elm.innerHTML ){\r
+               if( eChildren ){\r
                        this._children = eChildren;\r
                } else {\r
 \r
                };\r
                /*\r
-                * イベントの復帰 if( __.events && ( elm = this._ie4getRawNode() ) )\r
+                * イベントの復帰 if( this._events && ( elm = this._ie4getRawNode() ) )\r
                 */\r
                \r
                delete this._ie4dirty;\r
@@ -249,61 +278,61 @@ Node.prototype._afterCreate =
  *  Create\r
  */\r
 Node.prototype.create = function( tag ){\r
-       var elm, v;\r
-       if( this.type !== 1 ) return;\r
+       var elm, xnode;\r
+       if( this._nodeType !== 1 ) return;\r
        if( !this._children ) this._children = [];\r
        \r
        elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
        \r
        if( elm ){\r
-               if( document.createElement ){\r
+               if( document.appendChild ){\r
                        elm.appendChild( document.createElement( tag ) );\r
-                       v = new Node( elm.lastChild );\r
+                       xnode = new Node( elm.lastChild );\r
                } else\r
                if( document.all ){\r
                        elm.insertAdjacentHTML( 'BeforeEnd', '<' + tag + '>' );\r
-                       v = new Node( elm.children[ elm.children.length - 1 ] );\r
+                       xnode = new Node( elm.children[ elm.children.length - 1 ] );\r
                } else {\r
                        \r
                };\r
        } else {\r
                Node._newByTag = true;\r
-               v = new Node( v );\r
+               xnode = new Node( tag );\r
        };\r
-       v.parent = this;\r
-       this._children[ this._children.length ] = v;\r
-       return v;\r
+       xnode.parent = this;\r
+       this._children[ this._children.length ] = xnode;\r
+       return xnode;\r
 };\r
 \r
 /* --------------------------------------\r
- *  Create\r
+ *  CreateText\r
  */\r
 Node.prototype.createText = function( text ){\r
-       var elm, v;\r
-       if( this.type !== 1 ) return;\r
+       var elm, xnode;\r
+       if( this._nodeType !== 1 ) return;\r
        if( !this._children ) this._children = [];\r
        \r
        elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
        \r
        if( elm ){\r
-               if( document.createElement ){\r
+               if( document.createTextNode ){\r
                        elm.appendChild( document.createTextNode( text ) );\r
-                       v = new Node( elm.lastChild );\r
+                       xnode = new Node( elm.lastChild );\r
                } else\r
                if( document.all ){\r
                        elm.insertAdjacentHTML( 'BeforeEnd', text );\r
                        Node._newByText = true;\r
-                       v = new Node( v );\r
+                       xnode = new Node( text );\r
                } else {\r
                        \r
                };\r
        } else {\r
                Node._newByText = true;\r
-               v = new Node( v );\r
+               xnode = new Node( text );\r
        };\r
-       v.parent = this;\r
-       this._children[ this._children.length ] = v;\r
-       return v;\r
+       xnode.parent = this;\r
+       this._children[ this._children.length ] = xnode;\r
+       return xnode;\r
 };\r
 \r
 /* --------------------------------------\r
@@ -313,7 +342,7 @@ Node.prototype.createText = function( text ){
  */\r
 Node.prototype.append = function( v ){\r
        var elm, i, l, children;\r
-       if( this.type !== 1 ) return;\r
+       if( this._nodeType !== 1 ) return;\r
        \r
        if( 1 < arguments.length ){\r
                for( i = 0, l = arguments.length; i < l; ++i ){\r
@@ -349,11 +378,8 @@ Node.prototype.append = function( v ){
                                        this.append( v[ i ] );\r
                                };\r
                        } else\r
-                       if( 1 < v.length ){\r
+                       if( v.length ){\r
                                this._children.push.apply( this._children, v );\r
-                       } else\r
-                       if( v ){\r
-                               this._children[ this._children.length ] = v;\r
                        };\r
                        break;\r
                case Node.IS_XHNODE :\r
@@ -379,7 +405,7 @@ Node.prototype.appendAt = function( start, v ){
        var l = arguments.length,\r
                children = this._children,\r
                node, i, prev, next;\r
-       if( this.type !== 1 ) return;\r
+       if( this._nodeType !== 1 ) return;\r
        \r
        if( !children ) children = this._children = [];\r
        \r
@@ -396,7 +422,7 @@ Node.prototype.appendAt = function( start, v ){
                };\r
                return this;\r
        };\r
-       if( this._type !== 1 ) return this;\r
+       if( this._nodeType !== 1 ) return this;\r
        \r
        if( !this.parent ){\r
                children.splice( start, 0, v );\r
@@ -415,12 +441,12 @@ Node.prototype.appendAt = function( start, v ){
                                                elm.insertAdjacentHTML( 'AfterBegin', v.outerHTML );\r
                                                v = elm.children[ 0 ];\r
                                        } else\r
-                                       if( ( next = children[ start ] ) && typeof next !== 'string' && next._type !== 2 &&\r
+                                       if( ( next = children[ start ] ) && typeof next !== 'string' && next._nodeType !== 3 &&\r
                                                ( next = ( next._ie4getRawNode ? next._ie4getRawNode() : next ) ) ){\r
                                                next.insertAdjacentHTML( 'BeforeBegin', v.outerHTML );\r
                                                v = elm.children[ ( Array.prototype.indexOf.call( elm.children, next ) ) - 1 ];\r
                                        } else\r
-                                       if( 0 < start && ( prev = children[ start - 1 ] ) && typeof prev !== 'string' && prev._type !== 2 &&\r
+                                       if( 0 < start && ( prev = children[ start - 1 ] ) && typeof prev !== 'string' && prev._nodeType !== 3 &&\r
                                                ( prev = ( prev._ie4getRawNode ? prev._ie4getRawNode() : prev ) ) ){\r
                                                prev.insertAdjacentHTML( 'AfterEnd', v.outerHTML );\r
                                                v = elm.children[ ( Array.prototype.indexOf.call( elm.children, prev ) ) + 1 ];\r
@@ -443,11 +469,8 @@ Node.prototype.appendAt = function( start, v ){
                                        this.appendAt( start, v[ --i ] );\r
                                };\r
                        } else\r
-                       if( 1 < v.length ){\r
+                       if( v.length ){\r
                                children.push.apply( children, v );\r
-                       } else\r
-                       if( v ){\r
-                               children[ children.length ] = v;\r
                        };\r
                        break;\r
                case Node.IS_XHNODE :\r
@@ -530,8 +553,7 @@ Node.prototype.destroy = function( v ){
  */\r
 if( !document.getElementById && document.all ){\r
        Node.prototype._ie4beforeRemove = function(){\r
-               var __       = this.__,\r
-                       children = __.children,\r
+               var children = this._children,\r
                        child, i, l, elm;\r
                if( children ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
@@ -541,27 +563,27 @@ if( !document.getElementById && document.all ){
                };\r
                if( elm = this._ie4getRawNode() ){\r
                        // イベントの削除\r
-                       if( elm.id && elm.id !== __.ie4uid ){\r
-                               __.id = elm.id;\r
+                       if( elm.id && elm.id !== this._ie4uid ){\r
+                               this._id = elm.id;\r
                        } else\r
                        if( !elm.id ){\r
-                               __.ie4uid = elm.id = 'ie4uid_' + ( ++Node.ie4uid );\r
+                               this._ie4uid = elm.id = 'ie4uid_' + ( ++Node.ie4uid );\r
                        };\r
-                       __.htmlText = elm.outerHTML;\r
+                       this._htmlText = elm.outerHTML;\r
                        delete this._rawNode;\r
                };\r
        };\r
        \r
        Node.prototype._ie4getRawNode = function(){\r
-               var __ = this.__, elm, uid;\r
+               var elm, uid;\r
                if( ( elm = this._rawNode ) && elm.parentElement ) return elm;\r
-               if( ( uid = __.id ) && ( elm = document.all[ uid ] ) ){\r
+               if( ( uid = this._id ) && ( elm = document.all[ uid ] ) ){\r
                        return ( this._rawNode = elm );\r
                };\r
-               if( ( uid = __.ie4uid ) && ( elm = document.all[ uid ] ) ){\r
-                       delete __.ie4uid;\r
-                       delete __.htmlText;\r
-                       if( __.id ) elm.id = __.id;\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
                };\r
        };\r
@@ -570,28 +592,26 @@ if( !document.getElementById && document.all ){
        \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
+               child && ( child._ie4dirty = true );\r
+               this._ie4dirtyChildren = true;\r
+               if( root._reserved === true ) return;\r
+               root._reserved = true;\r
                X.Timer.once( 1, root, root._ie4startUpdate );\r
        };\r
        \r
-       Node.root._ie4startUpdate = function(){\r
-               var __ = this.__;\r
-               if( __.reserved !== true ) return;\r
-               if( this._ie4getRawNode() ) this._rawNode = document.all.tags( 'BODY' )[ 0 ];\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 __.reserved;\r
-               if( !__.children ) return;\r
+               delete this._reserved;\r
+               if( !this._children ) return;\r
                this._ie4commitUpdate()._ie4afterUpdate();\r
        };\r
        \r
        Node.prototype._ie4commitUpdate = function(){\r
-               var __       = this.__,\r
-                       children = __.children,\r
+               var children = this._children,\r
                        i, l, child, html;\r
-               if( !__.ie4dirtyChildren && !__.ie4dirty ){\r
+               if( !this._ie4dirtyChildren && !this._ie4dirty ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
                                child = children[ i ];\r
                                child.constractor === Node && child._ie4commitUpdate();\r
@@ -602,10 +622,10 @@ if( !document.getElementById && document.all ){
                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._ie4dirty ? child._ie4commitUpdate() : child._create() ) :\r
                                ( child.outerHTML || child );\r
                };\r
-               if( !__.ie4dirty ){\r
+               if( !this._ie4dirty ){\r
                        this._rawNode.innerHTML = html.join( '' );\r
                        return this;\r
                };\r
@@ -613,10 +633,9 @@ if( !document.getElementById && document.all ){
        };\r
        \r
        Node.prototype._ie4afterUpdate = function(){\r
-               var __       = this.__,\r
-                       children = __.children,\r
+               var children = this._children,\r
                        i, l, child;\r
-               if( !__.ie4dirtyChildren && !__.ie4dirty ){\r
+               if( !this._ie4dirtyChildren && !this._ie4dirty ){\r
                        for( i = 0, l = children.length; i < l; ++i ){\r
                                child = children[ i ];\r
                                child.constractor === Node && child._ie4afterUpdate();\r
@@ -626,10 +645,10 @@ if( !document.getElementById && document.all ){
                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
+                               ( child._ie4dirty ? child._ie4afterUpdate() : child._afterCreate( this ) );\r
                };\r
-               delete __.ie4dirtyChildren;\r
-               delete __.ie4dirty;\r
+               delete this._ie4dirtyChildren;\r
+               delete this._ie4dirty;\r
        };\r
        \r
        /*\r
@@ -679,7 +698,7 @@ if( !document.getElementById && document.all ){
  */\r
 Node.prototype.contains = function( v ){\r
        var node, _node;\r
-       if( !this.parent || this._type !== -1 ) return false;\r
+       if( !this.parent || this._nodeType !== -1 ) return false;\r
        node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
        switch( Node._getType( v ) ){\r
                case Node.IS_RAW_HTML :\r
@@ -704,7 +723,7 @@ Node.prototype.contains = function( v ){
 Node.prototype.getChildAt = function( index ){\r
        var children = this._children,\r
                elm, childNodes, child, xnode;\r
-       if( this._type !== 1 || index < 0 ) return;\r
+       if( this._nodeType !== 1 || index < 0 ) return;\r
        if( !children ){\r
                elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
                if( !elm ){\r
@@ -742,14 +761,14 @@ Node.prototype.getChildAt = function( index ){
  */\r
 Node.prototype.getByTag = function( tag ){\r
        var parent = this.parent, elm, tags;\r
-       if( !parent || this._type !== -1 ) return;\r
+       if( !parent || this._nodeType !== -1 ) return;\r
        if( document.getElementsByTagName ){\r
                if( !( elm = this._rawNode ) ) return;\r
                new X.Dom.NodeList( elm.getElementsByTagName( tag ) );\r
        } else\r
        if( document.all ){\r
                if( !( elm = this._ie4getRawNode() ) ) return;\r
-               Node.root.__.reserved === true && Node.root._ie4startUpdate();\r
+               Node.root._reserved === true && Node.root._ie4startUpdate();\r
                new X.Dom.NodeList( elm.all.tags( tag ) );      \r
        } else {\r
                \r
@@ -841,7 +860,8 @@ Node.prototype.getOrder = function(){
 /* --------------------------------------\r
  *  attribute\r
  */\r
-\r
+Node.prototype.attr = function(){\r
+};\r
 \r
 /* --------------------------------------\r
  *  Width, Height\r
@@ -854,7 +874,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._reserved === true && Node.root._ie4startUpdate();\r
                return elm.offsetWidth;         \r
        } else {\r
                \r
@@ -869,7 +889,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._reserved === true && Node.root._ie4startUpdate();\r
                return elm.offsetHeight;                \r
        } else {\r
                \r
@@ -881,9 +901,79 @@ Node.prototype.height = function(){
  */\r
 \r
 \r
+\r
 X.Dom.Event.add( window, 'load', function(){\r
-       var r = Node.root = new Node( document.body );\r
-       r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function();\r
-       r = null;\r
+       var r   = Node.root = new Node( document.body ),\r
+               elm = r._rawNode,\r
+               createTree;\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
+               createTree = function( xnode, elm, children ){\r
+                       var i = 0,\r
+                               l = children.length,\r
+                               child, _xnode;\r
+                       for( ; i < l; ++i ){\r
+                               child = children[ i ];\r
+                               if( child.nodeType === 1 ){\r
+                                       if( !xnode._children ) xnode._children = [];\r
+                                       xnode._children[ xnode._children.length ] = _xnode = new Node( child );\r
+                                       _xnode.parent = xnode;\r
+                                       child.childNodes.length && createTree( _xnode, child, child.childNodes );\r
+                               } else\r
+                               if( child.nodeType === 3 ){\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
+                               };\r
+                       };\r
+               };\r
+               createTree( r, elm, elm.childNodes );\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
+                       for( ; i < l; ++i ){\r
+                               child = children[ i ];\r
+                               alert( xnode._rawNode.tagName + '[' + nodes.join( ', ' ) + '] > "' + child.tagName + '" ' + j + '/' + xnode._children.length )\r
+                               while( j < xnode._children.length ){\r
+                                       _xnode = xnode._children[ j ];\r
+                                       ++j;\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
+                                       };\r
+                               };\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
+               createTree( r, elm.children );\r
+               delete r._reserved;\r
+       } else {\r
+               \r
+       };\r
+       \r
        return X.Callback.UN_LISTEN;\r
-} );
\ No newline at end of file
+} );\r
+\r
+})( window, document );
\ No newline at end of file
index 4a21283..b2182ec 100644 (file)
@@ -29,7 +29,7 @@ X.Dom.NodeList.prototype.length = 0;
        var target = X.Dom.NodeList.prototype,\r
                src    = X.Dom.Node.prototype,\r
                p, v, multi;\r
-               \r
+\r
        for( p in src ){\r
                v = src[ p ];\r
                if( typeof v === 'funciton' && !target[ p ] ){\r