OSDN Git Service

Version 0.6.66, fixed around X.Callback.
[pettanr/clientJs.git] / 0.6.x / js / dom / 11_XDomNode.js
index 9ec6353..7484184 100644 (file)
@@ -1,43 +1,41 @@
-\r
 X.Dom.Dirty = {\r
        CLEAN            :  0,\r
-       ID               :  1, // width, height, x, y\r
-       CONTENT          :  2,  // width, height, x, y textNode の内容\r
-       CLASSNAME        :  4, // _getCharSize, width, height, x, y\r
-       CSS              :  8, // _getCharSize, width, height, x, y\r
-       ATTR             : 16,  // _getCharSize, width, height, x, y\r
-       IE_FILTER        : X.UA.IE && X.UA.IE < 9 ? 32 : 0,\r
-       IE4_TEXTNODE_FIX : 64\r
+       CHILD_IS_DIRTY   :  1,\r
+       ID               :  2, // width, height, x, y\r
+       CONTENT          :  4, // width, height, x, y textNode の内容\r
+       CLASSNAME        :  8, // _getCharSize, width, height, x, y\r
+       ATTR             : 16, // _getCharSize, width, height, x, y\r
+       CSS              : 32, // _getCharSize, width, height, x, y\r
+       IE_FILTER        : X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ? 64 : 0,\r
+       UNKNOWN_TAG_FIX  : 128,\r
+       IE4_TEXTNODE_FIX : 256\r
 };\r
 \r
-/*\r
- * \r
- *\r
- * destroyed\r
- * display:none\r
- * display:block\r
- * display:inline\r
- * \r
- */\r
-\r
 X.Dom.State = {\r
        DESTROYED          : 0,\r
-       DISPLAY_NONE       : 1,\r
-       DISPLAY_BLOCK      : 2,\r
-       DISPLAY_INLINE     : 4,\r
-       POSITION_ABSOLUTE  : 2,\r
-       OVERFLOW_HIDDEN    : 4,\r
-       HAS_WIDTH_LENGTH   : 8,\r
-       HAS_WIDTH_PERCENT  : 16,\r
-       HAS_HEIGHT_LENGTH  : 16,\r
-       HAS_HEIGHT_PERCENT : 32,\r
-       IE4_ONLY_TEXT      : 64\r
+       EXIST              : 1,\r
+       BELONG_TREE        : 2,\r
+       DISPLAY_NONE       : 4,\r
+       DISPLAY_BLOCK      : 8,\r
+       DISPLAY_INLINE     : 16,\r
+       POSITION_ABSOLUTE  : 32,\r
+       OVERFLOW_HIDDEN    : 64,\r
+       HAS_WIDTH_LENGTH   : 128,\r
+       HAS_WIDTH_PERCENT  : 256,\r
+       HAS_HEIGHT_LENGTH  : 512,\r
+       HAS_HEIGHT_PERCENT : 1024,\r
+       IE4_ONLY_TEXT      : 2048,\r
+       IE5_DISPLAY_NONE_FIX : !X.UA.MacIE && 5 <= X.UA.IE && X.UA.IE < 5.5 ? 4096 : 0 // filterがかかっていると不可? MacIE5.2- は ?\r
 };\r
 \r
+X.Dom._strictElmCreation = !X.UA.MacIE && X.UA.IE5678;// && !X.UA.MacIE;\r
+\r
+X.Dom._useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 5.5 <= X.UA.IE ) && document.createDocumentFragment();\r
+\r
 /*\r
  * Node( rawElement | rawTextnode | htmlString | textString )\r
  */\r
-//;(function( window, document, undeifned ){\r
+\r
 X.Dom.Node = X.EventDispatcher.inherits(\r
        'XDomNode',\r
        X.Class.POOL_OBJECT,\r
@@ -46,7 +44,11 @@ X.Dom.Node = X.EventDispatcher.inherits(
                _state     : 0,\r
                _dirty     : 0,\r
                \r
+               _isNew     : false,\r
+               \r
                _rawNode   : null,\r
+               _rect      : null, // \r
+               \r
                _root      : null, // xnode が文書ツリーに属しているか?はこれを見る\r
                parent     : null, // remove された枝も親子構造は維持している。\r
                _xnodes    : null,\r
@@ -59,11 +61,13 @@ X.Dom.Node = X.EventDispatcher.inherits(
 \r
                _attrs     : null, // X.Dom.Attr\r
                _newAttrs  : null,\r
-               _attrText  : '',\r
+               _attrText  : '', // X.Dom.Attr.objToAttrText が必要な場合は false が入っている\r
                \r
                _css       : null, // X.Dom.Style\r
                _cssText   : null,\r
                \r
+               _fontSize  : 0,\r
+               \r
                _anime     : null,\r
                \r
                Constructor : function( v ){\r
@@ -71,11 +75,11 @@ X.Dom.Node = X.EventDispatcher.inherits(
                        \r
                        if( Node._newByTag ){\r
                                Node._newByTag  = false;\r
-                               this._tag       = v;\r
+                               this._tag       = v.toUpperCase();\r
                                this._xnodeType = 1;\r
                                this._state     = X.Dom.State.DISPLAY_INLINE; // todo\r
                                arguments[ 1 ] && this.attr( arguments[ 1 ] );\r
-                               css = arguments[ 2 ];\r
+                               css = arguments[ 2 ] || arguments[ 1 ];\r
                                css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css );\r
                        } else\r
                        if( Node._newByText ){\r
@@ -100,14 +104,14 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                this._rawNode   = v;\r
                                                this._xnodeType = 1;\r
                                                this._state     = X.Dom.State.DISPLAY_BLOCK; // todo\r
-                                               this._tag       = v.tagName;\r
+                                               this._tag       = v.tagName.toUpperCase();\r
                                                this._id        = v.id;\r
                                                this._className = v.className;\r
                                                this.cssText( v.style.cssText );\r
                                                // X.Dom.Dirty.CSS を落とす\r
                                                this._dirty = 0;\r
                                                // attr の回収は不可能、、、\r
-                                               if( X.UA.IE && X.UA.IE < 5 ){\r
+                                               if( X.Dom.DOM_IE4 ){\r
                                                        v.setAttribute( 'UID', '' + uid );\r
                                                } else {\r
                                                        v.UID = uid;\r
@@ -130,9 +134,15 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                if( xnodes.length ) return xnodes[ 0 ];\r
                                                return Node.none;\r
                                        case Node.IS_IMAGE :\r
-                                               v.UID = uid;\r
+                                               if( xnode = Node._getXNode( v ) ) return xnode;\r
+                                               this._rawNode   = v;\r
+                                               this._xnodeType = 4;\r
+                                               v.UID           = uid;\r
+                                               this._state     = X.Dom.State.EXIST;\r
+                                               break;\r
                                        case Node.IS_WINDOW :\r
                                        case Node.IS_DOCUMENT :\r
+                                               if( xnode = Node._getXNode( v ) ) return xnode;\r
                                                this._rawNode   = v;\r
                                                this._xnodeType = 2;\r
                                                this._state     = X.Dom.State.DISPLAY_BLOCK;\r
@@ -161,14 +171,17 @@ Node.IS_WINDOW      = 8;
 Node.IS_DOCUMENT    = 9;\r
 Node.IS_IMAGE       = 10;\r
 \r
-Node._useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 6 <= X.UA.IE ) && document.createDocumentFragment();\r
-\r
 Node._getType = function( v ){\r
        if( v === '' ) return Node.IS_STRING;\r
        if( !v ) return 0;\r
        if( v === window ) return Node.IS_WINDOW;\r
        if( v === document ) return Node.IS_DOCUMENT;\r
        if( v.constructor === window.Image ) return Node.IS_IMAGE;\r
+       if( X.UA.WebKit < 525.13 ){ // Safari3-\r
+               if( v.src !== undefined && v.onload !== undefined && X.Type.isNumber( v.height ) && X.Type.isNumber( v.width ) && X.Type.isBoolean( v.complete ) ){\r
+                       return Node.IS_IMAGE;\r
+               };\r
+       };      \r
        if( v.constructor === Node ) return Node.IS_XNODE;\r
        if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST;\r
        if( v.tagName ) return Node.IS_RAW_HTML;\r
@@ -188,7 +201,7 @@ Node._getXNode = function( v ){
                case Node.IS_RAW_HTML :\r
                case Node.IS_IMAGE :\r
                        // fake TextNode too.\r
-                       if( X.UA.IE && X.UA.IE < 5 ){\r
+                       if( X.Dom.DOM_IE4 ){\r
                                uid = v.getAttribute( 'UID' );\r
                                return uid && Node._chashe[ uid ];\r
                        };\r
@@ -198,6 +211,7 @@ Node._getXNode = function( v ){
                case Node.IS_DOCUMENT :\r
                        return Node._document;\r
                case Node.IS_RAW_TEXT :\r
+                       if( v.UID ) return Node._chashe[ v.UID ];\r
                        for( chashe = Node._chashe, i = chashe.length; i; ){\r
                                if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawNode === v ) ) return xnode;\r
                        };\r
@@ -227,14 +241,15 @@ Node.createText = function( text ){
 \r
 Node.getRoot = function( xnode ){\r
        return Node._document;\r
-       //return xnode.root._rawNode.documentElement ? node : node.ownerDocument || node.document;\r
+       //return xNode._body._rawNode.documentElement ? node : node.ownerDocument || node.document;\r
 };\r
        // XMLかどうかを判別する\r
 Node.isXmlDocument =\r
-       X.UA.IE && X.UA.IE < 5 ?\r
+       X.Dom.DOM_IE4 ?\r
                X.emptyFunction :\r
                (function( root ){\r
-                       return root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName;\r
+                       if( X.Type.isBoolean( root.isXML ) ) return root.isXML;\r
+                       return root.isXML = root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName;\r
                });\r
 \r
 Node._chashe     = [];\r
@@ -242,12 +257,12 @@ Node.none        = Node._chashe[ 0 ] = new Node();
 Node._window     = new Node( window ); // Node._chashe[ 1 ]\r
 Node._document   = new Node( document ); // Node._chashe[ 2 ]\r
 Node._html       = null; // Node._chashe[ 3 ]\r
-Node.root        = null;// = Node._chashe[ 4 ] body\r
+Node._body       = null;// = Node._chashe[ 4 ] body\r
 Node._systemNode = null;// = Node._chashe[ ? ]\r
 \r
 Node._reserveRemoval = [];\r
 \r
-if( !document.getElementById && document.all ){\r
+if( X.Dom.DOM_IE4 ){\r
        Node.prototype._ie4getRawNode = function(){\r
                var elm = this._rawNode;\r
                return elm ||\r
@@ -272,6 +287,9 @@ Node.prototype.create = function( tag, opt_attrs, opt_css ){
        this._root && this._reserveUpdate();\r
        return xnode;\r
 };\r
+Node.prototype.createAt = function( index, tag, opt_attrs, opt_css ){\r
+       // TODO\r
+};\r
 \r
 /* --------------------------------------\r
  *  CreateText\r
@@ -289,6 +307,9 @@ Node.prototype.createText = function( text ){
        this._xnodes[ this._xnodes.length ] = xnode;\r
        return xnode;\r
 };\r
+Node.prototype.createTextAt = function( index, text ){\r
+       // TODO\r
+};\r
 \r
 /* --------------------------------------\r
  *  Clone\r
@@ -350,19 +371,19 @@ Node.prototype.append = function( v ){
                        if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
                        // 親の xnodes から v を消す\r
                        if( v.parent ){\r
-                               //if( document.getElementById ){\r
+                               //if( X.Dom.DOM_W3C ){\r
                                //      v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
                                //} else\r
-                               //if( document.all ){\r
+                               //if( X.Dom.DOM_IE4 ){\r
                                        v.remove();\r
                                //} else {\r
                                        \r
                                //};\r
-                       } else\r
-                       if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
-                               if( !this._state ) alert( 'xnode already destroyed!' );\r
-                               Node._reserveRemoval.splice( i, 1 );\r
-                       };\r
+                       };// else\r
+                       //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
+                       //      if( !this._state ) alert( 'xnode already destroyed!' );\r
+                       //      Node._reserveRemoval.splice( i, 1 );\r
+                       //};\r
                        break;\r
                default :\r
                        return this;\r
@@ -414,19 +435,19 @@ Node.prototype.appendAt = function( start, v ){
                        if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
                        // 親の xnodes から v を消す\r
                        if( v.parent ){\r
-                               //if( document.getElementById ){\r
+                               //if( X.Dom.DOM_W3C ){\r
                                //      v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
                                //} else\r
-                               //if( document.all ){\r
+                               //if( X.Dom.DOM_IE4 ){\r
                                        v.remove();\r
                                //} else {\r
                                        \r
                                //};\r
-                       } else\r
-                       if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
-                               if( !this._state ) alert( 'xnode already destroyed!' );\r
-                               Node._reserveRemoval.splice( i, 1 );\r
-                       };\r
+                       };// else\r
+                       //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
+                       //      if( !this._state ) alert( 'xnode already destroyed!' );\r
+                       //      Node._reserveRemoval.splice( i, 1 );\r
+                       //};\r
                        break;\r
                default :\r
                        return this;\r
@@ -456,16 +477,25 @@ Node.prototype.appendTo = function( parent, opt_index ){
 };\r
 \r
 Node.prototype.appendToRoot = function( opt_index ){\r
-       opt_index === undefined ? Node.root.append( this ) : Node.root.appendAt( opt_index, this );\r
+       opt_index === undefined ? Node._body.append( this ) : Node._body.appendAt( opt_index, this );\r
        return this;\r
 };\r
 \r
 /* --------------------------------------\r
  *  Before , After, Replace\r
  */\r
-Node.prototype.before = function( v ){\r
-       var parent, l, start;\r
-       if( !( parent = this.parent ) ) return this;\r
+Node.prototype.before = Node.prototype.prevNode = function( v ){\r
+       var parent = this.parent, xnodes, i, l, start;\r
+       \r
+       // getter\r
+       if( v === undefined ){\r
+               if( !parent ) return;\r
+               xnodes = parent._xnodes;\r
+               i      = xnodes.indexOf( this );\r
+               return 0 < i ? xnodes[ i - 1 ] : v;\r
+       };\r
+       \r
+       if( !parent ) return this;\r
        \r
        l = arguments.length;\r
        start = this.getOrder();\r
@@ -479,9 +509,18 @@ Node.prototype.before = function( v ){
        return this;\r
 };\r
 \r
-Node.prototype.after = function( v ){\r
-       var parent, l, i, start;\r
-       if( !( parent = this.parent ) ) return this;\r
+Node.prototype.after = Node.prototype.nextNode = function( v ){\r
+       var parent = this.parent, xnodes, i, l, start;\r
+       \r
+       // getter\r
+       if( v === undefined ){\r
+               if( !parent ) return;\r
+               xnodes = parent._xnodes;\r
+               i      = xnodes.indexOf( this );\r
+               return ++i < xnodes.length ? xnodes[ i ] : v;\r
+       };\r
+       \r
+       if( !parent ) return this;\r
        \r
        l = arguments.length;\r
        start = this.getOrder() + 1;\r
@@ -542,6 +581,8 @@ Node.prototype.empty = function(){
 /* --------------------------------------\r
  *  destory\r
  */\r
+Node._destroyChildFlag = false; // TODO\r
+\r
 Node.prototype.destroy = function( isChild ){\r
        var xnodes = this._xnodes, i, elm;\r
        \r
@@ -602,23 +643,8 @@ Node.prototype.getChildAt = function( i ){
 \r
 \r
 /* --------------------------------------\r
- *  prevNode, nextNode, firstChild, lastChild\r
+ *  firstChild, lastChild\r
  */\r
-\r
-Node.prototype.prevNode = function(){\r
-       var parent = this.parent, xnodes, index;\r
-       if( !parent ) return;\r
-       xnodes = parent._xnodes;\r
-       index = xnodes.indexOf( this );\r
-       if( 0 < index ) return xnodes[ index - 1 ];\r
-};\r
-Node.prototype.nextNode = function(){\r
-       var parent = this.parent, xnodes, index;\r
-       if( !parent ) return;\r
-       xnodes = parent._xnodes;\r
-       index  = xnodes.indexOf( this );\r
-       if( index + 1 < xnodes.length ) return xnodes[ index + 1 ];\r
-};\r
 Node.prototype.firstChild = function(){\r
        return this.getChildAt( 0 );\r
 };\r
@@ -672,12 +698,12 @@ Node.prototype.addClass = function( v ){
                if( !name ) continue;\r
                !this.hasClass( name ) && ( v += ( v ? ' ' : '' ) + name );\r
        };\r
-       return v ? his.className( this._className + ( this._className ? ' ' : '' ) + v ) : this;\r
+       return v ? this.className( this._className + ( this._className ? ' ' : '' ) + v ) : this;\r
 };\r
 Node.prototype.removeClass = function( v ){\r
        var _          = ' ',\r
                className  = this._className,\r
-               names      = v.split( ' ' ),\r
+               names      = v.split( _ ),\r
                classNames, i, f, j;\r
        if( !className ) return this;\r
        for( classNames = className.split( _ ), i = classNames.length; i; ){\r
@@ -691,10 +717,19 @@ Node.prototype.removeClass = function( v ){
                        };\r
                };\r
        };\r
-       return f ? this.className( classNames.join( ' ' ) ) : this;\r
+       return f ? this.className( classNames.join( _ ) ) : this;\r
 };\r
-Node.prototype.toggleClass = function( v ){\r
-\r
+Node.prototype.toggleClass = function( v, opt_toggle ){\r
+       var names, i, name;\r
+       if( opt_toggle !== undefined ){\r
+               return !!opt_toggle ? this.addClass( v ) : this.removeClass( v );       \r
+       };\r
+       names = v.split( ' ' );\r
+       for( i = names.length; i; ){\r
+               name = names[ --i ];\r
+               this.hassClass( name ) ? this.removeClass( name ) : this.addClass( name );\r
+       };\r
+       return this;\r
 };\r
 Node.prototype.hasClass = function( v ){\r
        var _ = ' ',\r
@@ -717,20 +752,17 @@ Node.prototype.hasClass = function( v ){
 /* --------------------------------------\r
  *  html, text\r
  */\r
+\r
+Node._outerFlag = null;\r
+\r
 Node.prototype.html = function( html ){\r
-       var _ = '', xnodes, n, i, l;\r
+       var _ = '', q = '"', xnodes, n, i, l;\r
        // setter\r
-       if( html || html === '' ){\r
-               if( this._xnodeType === 3 ){\r
-                       if( this._text !== html ){\r
-                               this._text = html;\r
-                               this._root && this._reserveUpdate();\r
-                               this._dirty |= X.Dom.Dirty.CONTENT;\r
-                       };\r
-                       return this;\r
-               };\r
-               return this.empty().append.apply( this, X.Dom.parse( html, true ) );\r
+       if( X.Type.isString( html ) ){\r
+               if( this._xnodeType === 3 ) return this.text( html );\r
+               return html ? this.empty().append.apply( this, X.Dom.parse( html, true ) ) : this.empty();\r
        };\r
+       \r
        // getter\r
        if( this._xnodeType === 3 ){\r
                return this._text;\r
@@ -739,42 +771,46 @@ Node.prototype.html = function( html ){
        if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                delete this._cssText;\r
        };\r
-       html = !Node._needOuter ? [] : [\r
+       html = !Node._outerFlag ? [] : [\r
                '<', this._tag,\r
-               this._id ? ' id=' + this._id : _,\r
-               this._className ? ' class="' + this._className + '"' : _,\r
-               this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
-               this._cssText ? ' style="' + this._cssText + '"' : _,\r
+               this._id ? ' id="' + this._id + q : _,\r
+               this._className ? ' class="' + this._className + q : _,\r
+               this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText,\r
+               this._cssText ? ' style="' + this._cssText + q : _,\r
        '>' ];\r
        \r
        n = html.length;\r
        if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
-               Node._needOuter = true;\r
+               if( !Node._outerFlag ) Node._outerFlag = this;\r
                for( i = 0; i < l; ++i ){\r
-                       html[ n ] = xnodes[ i ].html( undefined );\r
+                       html[ n ] = xnodes[ i ].html();\r
                        ++n;\r
                };\r
-               Node._needOuter = false;\r
+               if( Node._outerFlag === this )  Node._outerFlag = null;\r
        };\r
-       !Node._needOuter || X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
-\r
+       !Node._outerFlag || X.Dom.DTD.EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
        return html.join( _ );\r
 };\r
 \r
 Node.prototype.text = function( text ){\r
        var xnodes, texts, i, l;\r
        // setter\r
-       if( text || text === '' ){\r
+       if( X.Type.isString( text ) ){\r
                if( this._xnodeType === 3 ){\r
                        if( this._text !== text ){\r
-                               this._text = text;\r
+                               text ? ( this._text = text ) : delete this.text;\r
                                this._root && this._reserveUpdate();\r
                                this._dirty |= X.Dom.Dirty.CONTENT;\r
                        };\r
                        return this;\r
                };\r
+               if( !text ) return this.empty();\r
+               if( ( xnodes = this._xnodes ) && xnodes.length === 1 && xnodes[ 0 ]._xnodeType === 3 ){\r
+                       xnodes[ 0 ].text( text );\r
+                       return this;\r
+               };\r
                this.empty().createText( text );\r
-               return this;    \r
+               return this;\r
        };\r
        // getter\r
        if( this._xnodeType === 1 ){\r
@@ -800,7 +836,8 @@ Node.prototype.each = function( func ){
  * \r
  * state:\r
  *  0 : no_rawnode\r
- *  1 : not_added\r
+ *  1 : no_parent\r
+ *  2 : no_root\r
  *  3 : dirty\r
  *  4 : clean\r
  * \r
@@ -811,61 +848,73 @@ Node.prototype.each = function( func ){
  */\r
        \r
 Node.prototype._reserveUpdate = function(){\r
-       var root = Node.root;\r
+       var root = Node._body;\r
        if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( root, root._startUpdate );\r
 };\r
 \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
        } else {\r
                return;\r
        };\r
-\r
-\r
-       X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.BEFORE_UPDATE ] && X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UPDATE } );\r
+       // このイベントでサイズを取ると無限ループに\r
+       // X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.BEFORE_UPDATE ] && X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UPDATE } );\r
 \r
        removal = Node._reserveRemoval;\r
        \r
        tmp = this._rawNode.style.visibility;\r
        //this._rawNode.style.visibility = 'hidden';\r
-       \r
+\r
+       //console.log( '_actualRemove().' );\r
+\r
        if( i = removal.length ){\r
                for( ; i; ){\r
                        xnode = removal[ --i ];\r
                        xnode._actualRemove();\r
                        !this._state && xnode.kill();\r
                };\r
-               removal.length = 0;             \r
+               removal.length = 0;\r
        };\r
+\r
+       //console.log( 'start _startUpdate().' );\r
+\r
+       Node._html._dirty ? Node._html._commitUpdate() : this._commitUpdate();\r
        \r
-       this._commitUpdate();\r
+       //console.log( 'end of _startUpdate().' );\r
        \r
-       X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.AFTER_UPDATE ] && X.Dom.dispatch( { type : X.Dom.Event.AFTER_UPDATE } );\r
+       X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.AFTER_UPDATE ] && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.AFTER_UPDATE } );\r
        //this._rawNode.style.visibility = tmp;\r
 };\r
 \r
 Node.prototype._commitUpdate =\r
-       document.getElementById ?\r
+       X.Dom.DOM_W3C ?\r
                ( function( parentElement, nextElement ){\r
                        var elm = this._rawNode,\r
                                xnodes, l, i, frg, next, k, v;\r
 \r
+                       if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
+                               //alert( this._tag + ' ' + !!elm );\r
+                               elm && elm.parentNode && this._actualRemove();\r
+                               return nextElement;\r
+                       };\r
+\r
                        if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){\r
                                nextElement ?\r
                                        parentElement.insertBefore( this._actualCreate(), nextElement ) :\r
                                        parentElement.appendChild( this._actualCreate() );\r
                                this._afterActualCreate();\r
-                               \r
-                               \r
+\r
                                return elm || this._rawNode;\r
                        } else\r
                        if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) {\r
                                \r
-                               /*if( elm.childNodes.length !== l && ( frg = Node._useDocumentFragment ) ){\r
+                               /*if( elm.childNodes.length !== l && ( frg = X.Dom._useDocumentFragment ) ){\r
                                        for( i = 0; i < l; ++i ){\r
                                                frg.appendChild( xnodes[ i ]._actualCreate( true ) );\r
                                        };\r
@@ -880,10 +929,14 @@ Node.prototype._commitUpdate =
                                //};\r
                        };\r
 \r
+                       delete this._fontSize;\r
                        this._dirty && this._updateRawNode( elm );\r
+                       if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
+                               return nextElement;\r
+                       };\r
                        return elm;\r
                }) :\r
-       document.all ? \r
+       X.Dom.DOM_IE4 ? \r
                ( function( parentElement, prevElement ){\r
                        var elm    = this._rawNode || this._ie4getRawNode(),\r
                                xnodes, l, i, html, text, prev;\r
@@ -923,13 +976,15 @@ Node.prototype._commitUpdate =
                                        prev = xnodes[ i ]._commitUpdate( elm, prev );\r
                                };\r
                        };\r
+                       \r
+                       delete this._fontSize;\r
                        this._dirty && this._updateRawNode( elm );\r
                        return elm;\r
                }) :\r
                (function(){});\r
 \r
 Node.prototype._updateRawNode =\r
-       document.getElementById ?\r
+       X.Dom.DOM_W3C ?\r
                ( function( elm ){\r
                        var attrs, rename, k, v;\r
 \r
@@ -941,24 +996,25 @@ Node.prototype._updateRawNode =
                        };\r
                        // id\r
                        if( this._dirty & X.Dom.Dirty.ID ){\r
-                               if( X.UA.IE && X.UA.IE < 7 ){\r
-                                       elm.id = this._id;\r
-                               } else {\r
-                                       this._id ? ( elm.id = this._id ) : elm.removeAttribute( 'id' );                                 \r
-                               };\r
+                               this._id ? ( elm.id = this._id ) : ( elm.id && elm.removeAttribute( 'id' ) );           \r
                        };\r
                        // className\r
                        if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
-                               if( X.UA.IE && X.UA.IE < 7 ){\r
-                                       elm.className = this._className;\r
-                               } else {\r
-                                       this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' );                                 \r
+                               this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( X.UA.IE ? 'className' : 'class' ) );                                    \r
+\r
+                               // ie5 only\r
+                               if( X.Dom.State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){\r
+                                       this._actualRemove();\r
+                                       this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX;\r
+                                       return;\r
                                };\r
                        };\r
                        // style\r
                        if( this._dirty & X.Dom.Dirty.CSS ){\r
-                               if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
-                                       elm.style.cssText = this._cssText;\r
+                               if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
+                                       X.UA.Opera78 || X.UA.NN6 ?\r
+                                               elm.setAttribute( 'style', this._cssText ) : // opera8用\r
+                                               ( elm.style.cssText = this._cssText );\r
                                } else {\r
                                        elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要\r
                                        elm.removeAttribute( 'style' );\r
@@ -967,14 +1023,14 @@ Node.prototype._updateRawNode =
                        };\r
                        \r
                        if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
-                               this._rawNode.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
+                               elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
                        };\r
                        \r
                        // attr\r
                        if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){\r
                                rename = X.Dom.Attr.renameForDOM;\r
                                for( k in attrs ){\r
-                                       if( 5 <= X.UA.IE && X.UA.IE < 5.5 ){\r
+                                       if( !X.UA.MacIE && 5 <= X.UA.IE && X.UA.IE < 6 ){ // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので\r
                                                if( this._tag === 'TEXTAREA' && k === 'value' ){\r
                                                        elm.firstChild ?\r
                                                                ( elm.firstChild.data = attrs[ k ] ) :\r
@@ -982,16 +1038,18 @@ Node.prototype._updateRawNode =
                                                        continue;\r
                                                };\r
                                        };\r
+                                       k = \r
                                        ( v = attrs[ k ] ) === undefined ?\r
                                                elm.removeAttribute( rename[ k ] || k ) :\r
-                                               ( elm[ rename[ k ] || k ] = v );\r
+                                               ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v );                          \r
+\r
                                };\r
                                delete this._newAttrs;\r
                        };\r
                        \r
                        delete this._dirty;\r
                }) :\r
-       document.all ? \r
+       X.Dom.DOM_IE4 ? \r
                ( function( elm ){\r
                        var attrs, rename, k, v;\r
 \r
@@ -1015,7 +1073,7 @@ Node.prototype._updateRawNode =
                        };\r
                        // style\r
                        if( this._dirty & X.Dom.Dirty.CSS ){\r
-                               if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
+                               if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                                        elm.style.cssText = this._cssText;\r
                                } else {\r
                                        elm.style.cssText = '';\r
@@ -1034,7 +1092,7 @@ Node.prototype._updateRawNode =
                                for( k in attrs ){\r
                                        ( v = attrs[ k ] ) === undefined ?\r
                                                elm.removeAttribute( rename[ k ] || k ) :\r
-                                               elm.setAttribute( rename[ k ] || k, v );\r
+                                               elm.setAttribute( rename[ k ] || k, v ); // TODO X.Dom.Attr.noValue\r
                                };\r
                                delete this._newAttrs;\r
                        };\r
@@ -1054,14 +1112,14 @@ Node.prototype._updateRawNode =
  * ie7 以下では iframe の frameborder や、input name は、createElement 後に setAttribute しても無視される\r
  * \r
  * fragument がある場合 children も足して\r
- * Mozilla: 1.0+, IE: 6.0+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+\r
+ * Mozilla: 1.0+, IE: 5.5+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+\r
  * ie6 大丈夫?fragment の場合リークしないか?チェックが必要\r
  * http://msdn.microsoft.com/ja-jp/library/bb250448%28v=vs.85%29.aspx\r
  * \r
  * document.createElement of ie4 is only for OPTION & IMAGE.\r
  */\r
 Node.prototype._actualCreate =\r
-       document.getElementById ? (function( isChild ){\r
+       X.Dom.DOM_W3C ? (function( isChild ){\r
                var elm = this._rawNode,\r
                        xnodes, frg, i, l;\r
                \r
@@ -1077,20 +1135,20 @@ Node.prototype._actualCreate =
                        };\r
                        this._isNew = true;\r
                        this._rawNode = elm =\r
-                               X.UA.IE && X.UA.IE < 9 ?\r
+                               X.Dom._strictElmCreation ?\r
                                        document.createElement( [\r
                                                '<', this._tag,\r
                                                        ' UID="', this._uid, '"',\r
                                                        this._id ? ' id="' + this._id + '"' : '',\r
                                                        this._className ? ' class="' + this._className + '"' : '',\r
-                                                       this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
+                                                       this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText,\r
                                                        this._cssText ? ' style="' + this._cssText + '"' : '',\r
-                                               '>' ].join( '' ) ):\r
+                                               '>' ].join( '' ) ) :\r
                                        document.createElement( this._tag );\r
                };\r
-               if( Node._useDocumentFragment ){\r
+               if( X.Dom._useDocumentFragment ){\r
                        if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
-                               !isChild && ( frg = Node._useDocumentFragment ).appendChild( elm );\r
+                               !isChild && ( frg = X.Dom._useDocumentFragment ).appendChild( elm );\r
                                for( i = 0; i < l; ++i ){\r
                                        elm.appendChild( xnodes[ i ]._actualCreate( true ) );\r
                                };\r
@@ -1100,7 +1158,7 @@ Node.prototype._actualCreate =
                \r
                return elm;\r
        }) :\r
-       document.all ? (function( isChild ){\r
+       X.Dom.DOM_IE4 ? (function( isChild ){\r
                var uid = this._uid,\r
                        html, xnodes, n, i, l;\r
                \r
@@ -1117,7 +1175,7 @@ Node.prototype._actualCreate =
                        html = [\r
                                '<', this._tag, ' id=', ( this._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',\r
                                this._className ? ' class="' + this._className + '"' : '',\r
-                               this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
+                               this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText,\r
                                this._cssText ? ' style="' + this._cssText + '"' : '',\r
                        '>' ];\r
                        \r
@@ -1135,7 +1193,7 @@ Node.prototype._actualCreate =
                                        };                                      \r
                                };\r
                        };\r
-                       X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
+                       X.Dom.DTD.EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
                        \r
                        delete this._newAttrs;\r
                };\r
@@ -1145,9 +1203,9 @@ Node.prototype._actualCreate =
        (function(){});\r
 \r
 Node.prototype._afterActualCreate =\r
-       document.getElementById ? (function(){\r
+       X.Dom.DOM_W3C ? (function(){\r
                var elm = this._rawNode, xnodes, l, attrs, k, i;\r
-               \r
+\r
                this._root  = this.parent._root;\r
                \r
                if( this._xnodeType === 3 ){\r
@@ -1159,12 +1217,12 @@ Node.prototype._afterActualCreate =
                l      = xnodes && xnodes.length;\r
                \r
                if( this._isNew ){\r
-                       if( !Node._useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加\r
+                       if( !X.Dom._useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加\r
                                for( i = 0; i < l; ++i ){\r
                                        elm.appendChild( xnodes[ i ]._actualCreate( true ) );\r
                                };\r
                        };\r
-                       if( !X.UA.IE || 8 < X.UA.IE ){\r
+                       if( !X.Dom._strictElmCreation ){\r
                                elm.UID = this._uid;\r
                                this._newAttrs = this._attrs;\r
                                this._dirty = X.Dom.Dirty.ID | X.Dom.Dirty.CLASSNAME | X.Dom.Dirty.CSS | X.Dom.Dirty.ATTR | X.Dom.Dirty.IE_FILTER;\r
@@ -1174,7 +1232,7 @@ Node.prototype._afterActualCreate =
                                elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
                                delete this._dirty;\r
                        };\r
-                       this._restoreEvent();// イベントの復帰\r
+                       \r
                        delete this._isNew;\r
                } else {\r
                        this._dirty && this._updateRawNode( elm );\r
@@ -1185,10 +1243,11 @@ Node.prototype._afterActualCreate =
                                xnodes[ i ]._afterActualCreate();\r
                        };\r
                };\r
-               \r
-               return this;\r
+               // src の onload があるので先ではないか?\r
+               // ie の str から要素を作る場合、srcだけ イベント設定後ではないか?\r
+               this._restoreEvent();// イベントの復帰\r
        }) :\r
-       document.all ? (function(){\r
+       X.Dom.DOM_IE4 ? (function(){\r
                var xnodes, i;\r
                this._root = this.parent._root;\r
                \r
@@ -1199,16 +1258,17 @@ Node.prototype._afterActualCreate =
                                xnodes[ --i ]._afterActualCreate();\r
                        };\r
                };\r
+               // textarea への value の適用はここで\r
                if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
                        this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
                };\r
                delete this._dirty;\r
-               return this._restoreEvent();// イベントの復帰\r
+               this._restoreEvent();// イベントの復帰\r
        }) :\r
        (function(){});\r
 \r
 Node.prototype._actualRemove =\r
-       document.getElementById ?\r
+       X.Dom.DOM_W3C ?\r
                ( function( isChild ){\r
                        var xnodes = this._xnodes,\r
                                elm    = this._rawNode,\r
@@ -1223,9 +1283,13 @@ Node.prototype._actualRemove =
                        if( !elm ) return;\r
                        this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
                        // elm.parentNode.tagName for ie7\r
-                       !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
+                       if( !X.UA.MacIE ){\r
+                               !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
+                       } else {\r
+                               !isChild && elm.parentNode && elm.parentNode.tagName && X.Dom._fixed_remove( elm, this );\r
+                       };\r
                }) :\r
-       document.all ?\r
+       X.Dom.DOM_IE4 ?\r
                ( function( isChild ){\r
                        var xnodes = this._xnodes,\r
                                elm    = this._rawNode || this._ie4getRawNode(),\r
@@ -1239,16 +1303,15 @@ Node.prototype._actualRemove =
                        if( !elm ) return;\r
                        this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
                        \r
+                       if( X.Dom.Attr.HAS_VALUE[ this._tag ] && ( !this._newAttrs || !X.inObject( 'value', this._newAttrs ) ) ){\r
+                               this._attrs.value = elm.value;\r
+                       };\r
                        elm.removeAttribute( 'id' ); // ?\r
-                       document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // ?\r
+                       document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // MacIE5 でエラー\r
                        if( !isChild ) elm.outerHTML = '';\r
                        delete this._rawNode;\r
                }) :\r
                (function(){});\r
-       \r
-       \r
-//})( window, document );\r
-\r
-\r
 \r
+console.log( 'X.Dom.Node' );\r
 \r