OSDN Git Service

Version 0.6.57, fixed NS of X.UI & X.Class for __proto__.
[pettanr/clientJs.git] / 0.6.x / js / dom / 11_XDomNode.js
index 86c75db..bc48a70 100644 (file)
@@ -6,7 +6,7 @@ X.Dom.Dirty = {
        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 ? 64 : 0,\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
@@ -25,15 +25,17 @@ X.Dom.State = {
        HAS_HEIGHT_LENGTH  : 512,\r
        HAS_HEIGHT_PERCENT : 1024,\r
        IE4_ONLY_TEXT      : 2048,\r
-       IE5_DISPLAY_NONE_FIX : 5 <= X.UA.IE && X.UA.IE < 5.5 ? 4096 : 0 // MacIE5.2- は ?\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.IE && X.UA.IE < 9;// && !X.UA.MacIE;\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
@@ -57,7 +59,7 @@ X.Dom.Node = X.EventDispatcher.inherits(
 \r
                _attrs     : null, // X.Dom.Attr\r
                _newAttrs  : null,\r
-               _attrText  : ' ', // X.Dom.Attr.objToAttrText が必要な場合は false が入っている\r
+               _attrText  : '', // X.Dom.Attr.objToAttrText が必要な場合は false が入っている\r
                \r
                _css       : null, // X.Dom.Style\r
                _cssText   : null,\r
@@ -167,8 +169,6 @@ 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
@@ -239,7 +239,7 @@ 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
@@ -255,7 +255,7 @@ 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
@@ -469,7 +469,7 @@ 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
@@ -753,7 +753,7 @@ Node.prototype.html = function( html ){
                '<', this._tag,\r
                this._id ? ' id="' + this._id + q : _,\r
                this._className ? ' class="' + this._className + q : _,\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 + q : _,\r
        '>' ];\r
        \r
@@ -821,7 +821,7 @@ 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
@@ -843,7 +843,9 @@ Node.prototype._startUpdate = function(){
        \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
@@ -852,9 +854,13 @@ Node.prototype._startUpdate = function(){
                };\r
                removal.length = 0;\r
        };\r
-       \r
+\r
+       console.log( 'start _startUpdate().' );\r
+\r
        Node._html._dirty ? Node._html._commitUpdate() : this._commitUpdate();\r
        \r
+       //console.log( 'end of _startUpdate().' );\r
+       \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
@@ -881,7 +887,7 @@ Node.prototype._commitUpdate =
                        } 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
@@ -963,31 +969,23 @@ Node.prototype._updateRawNode =
                        };\r
                        // id\r
                        if( this._dirty & X.Dom.Dirty.ID ){\r
-                               //if( X.UA.IE && X.UA.IE < 7 ){\r
-                                       this._id ? ( elm.id = this._id ) : ( elm.id && elm.removeAttribute( '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 < 8 ){\r
-                                       //elm.className = this._className;\r
+                               this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( X.UA.IE ? 'className' : 'class' ) );                                    \r
 \r
-                               //} else {\r
-                                       this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( '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
+                               // 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
-                                       X.UA.Opera && X.UA.Opera < 9 ?\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
@@ -1005,7 +1003,7 @@ Node.prototype._updateRawNode =
                        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 < 6 ){ // IETester 5.5 ではエラーが出なかった.MultipulIE5.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
@@ -1013,9 +1011,10 @@ 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
@@ -1047,7 +1046,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
@@ -1066,7 +1065,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
@@ -1086,7 +1085,7 @@ 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
@@ -1115,14 +1114,14 @@ Node.prototype._actualCreate =
                                                        ' 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
                                        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
@@ -1149,7 +1148,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
@@ -1179,7 +1178,7 @@ Node.prototype._actualCreate =
 Node.prototype._afterActualCreate =\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
@@ -1191,15 +1190,11 @@ 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 && X.UA.IE < 5.5 ){\r
-                       //      this._dirty = X.Dom.Dirty.CSS | X.Dom.Dirty.IE_FILTER;\r
-                       //      this._updateRawNode( elm );\r
-                       //} else\r
                        if( !X.Dom._strictElmCreation ){\r
                                elm.UID = this._uid;\r
                                this._newAttrs = this._attrs;\r
@@ -1261,7 +1256,11 @@ 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
        X.Dom.DOM_IE4 ?\r
                ( function( isChild ){\r
@@ -1281,15 +1280,11 @@ Node.prototype._actualRemove =
                                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