OSDN Git Service

Version 0.6.87, fix SuperConstructor @ X.Class & force convert to PointerEvent @...
[pettanr/clientJs.git] / 0.6.x / js / 01_dom / 11_XDomNode.js
index 8d8d309..ff29163 100644 (file)
@@ -46,7 +46,7 @@ X.Dom.Node = X.EventDispatcher.inherits(
                \r
                _isNew     : false,\r
                \r
-               _rawObject   : null,\r
+               _rawObject : null,\r
                _rect      : null, // \r
                \r
                _root      : null, // xnode が文書ツリーに属しているか?はこれを見る\r
@@ -70,6 +70,9 @@ X.Dom.Node = X.EventDispatcher.inherits(
                \r
                _anime     : null,\r
                \r
+       /*\r
+        * TODO Node の継承ができない!\r
+        */\r
                Constructor : function( v ){\r
                        var css, xnodes, xnode, parent, uid = Node._chashe.length;\r
                        \r
@@ -102,7 +105,7 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                // v.parentNode || v.parentElement : dom1 || dom0\r
                                                this.parent     = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && Node._getXNode( parent );\r
                                                this._root      = this.parent ? this.parent._root : null;\r
-                                               this._rawObject   = v;\r
+                                               this._rawObject = v;\r
                                                this._xnodeType = 1;\r
                                                this._state     = X.Dom.State.DISPLAY_BLOCK; // todo\r
                                                this._tag       = v.tagName.toUpperCase();\r
@@ -123,7 +126,7 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                if( xnode = Node._getXNode( v ) ) return xnode;\r
                                                this.parent     = Node._getXNode( v.parentNode );\r
                                                this._root      = this.parent ? this.parent._root : null;\r
-                                               this._rawObject   = v;\r
+                                               this._rawObject = v;\r
                                                this._xnodeType = 3;\r
                                                this._state     = X.Dom.State.DISPLAY_INLINE;\r
                                                this._text      = v.data;\r
@@ -136,18 +139,19 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                return Node.none;\r
                                        case Node.IS_IMAGE :\r
                                                if( xnode = Node._getXNode( v ) ) return xnode;\r
-                                               this._rawObject   = v;\r
+                                               this._rawObject = v;\r
                                                this._xnodeType = 4;\r
                                                v.UID           = uid;\r
                                                this._state     = X.Dom.State.EXIST;\r
                                                break;\r
+                                       /*\r
                                        case Node.IS_WINDOW :\r
                                        case Node.IS_DOCUMENT :\r
                                                if( xnode = Node._getXNode( v ) ) return xnode;\r
-                                               this._rawObject   = v;\r
+                                               this._rawObject = v;\r
                                                this._xnodeType = 2;\r
                                                this._state     = X.Dom.State.DISPLAY_BLOCK;\r
-                                               break;\r
+                                               break; */\r
                                        default :\r
                                                if( Node.none ) return Node.none;\r
                                                return;\r
@@ -177,16 +181,11 @@ Node._getType = function( v ){
        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( X.Type.isHTMLElement( v ) ) return Node.IS_RAW_HTML;\r
        if( v.nodeType === 3 ) return Node.IS_RAW_TEXT;\r
+       if( X.Type.isImage( v ) ) return Node.IS_IMAGE;\r
        if( typeof v === 'string' ){\r
                return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING;\r
        };\r
@@ -255,11 +254,11 @@ Node.isXmlDocument =
 \r
 Node._chashe     = [];\r
 Node.none        = Node._chashe[ 0 ] = new Node();\r
-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._body       = null;// = Node._chashe[ 4 ] body\r
-Node._systemNode = null;// = Node._chashe[ ? ]\r
+Node._window     = new X.EventDispatcher( window );\r
+Node._document   = new X.EventDispatcher( document );\r
+Node._html       = null; // = Node._chashe[ 1 ] <html>\r
+Node._body       = null; // = Node._chashe[ 2 ] <body>\r
+Node._systemNode = null; // = Node._chashe[ ? ]\r
 \r
 Node._reserveRemoval = [];\r
 \r
@@ -289,7 +288,9 @@ Node.prototype.create = function( tag, opt_attrs, opt_css ){
        return xnode;\r
 };\r
 Node.prototype.createAt = function( index, tag, opt_attrs, opt_css ){\r
-       // TODO\r
+       var xnode = Node.create( tag, opt_attrs, opt_css );\r
+       this.appendAt( index, xnode );\r
+       return xnode;\r
 };\r
 \r
 /* --------------------------------------\r
@@ -309,7 +310,9 @@ Node.prototype.createText = function( text ){
        return xnode;\r
 };\r
 Node.prototype.createTextAt = function( index, text ){\r
-       // TODO\r
+       var xtext = Node.createText( text );\r
+       this.appendAt( index, xtext );\r
+       return xtext;\r
 };\r
 \r
 /* --------------------------------------\r
@@ -909,7 +912,7 @@ Node.prototype._startUpdate = function(){
                return;\r
        };\r
        if( this._updateTimerID ){\r
-               //X.Timer.cancelFrame( this._updateTimerID ); // fire 中の cancel が動かない、、、\r
+               X.Timer.cancelFrame( this._updateTimerID );\r
                this._updateTimerID = 0;\r
        } else {\r
                return;\r
@@ -951,6 +954,8 @@ Node.prototype._commitUpdate =
 \r
                        if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
                                //alert( this._tag + ' ' + !!elm );\r
+                               // filter の効いている要素だけdisplay:none が無視される模様。filter を切ればよい?\r
+                               // 親が、display:none の場合は?\r
                                elm && elm.parentNode && this._actualRemove();\r
                                return nextElement;\r
                        };\r
@@ -1061,6 +1066,7 @@ Node.prototype._updateRawNode =
                                };\r
                        };\r
                        // style\r
+                       // TODO display:none の場合、更新をスキップ\r
                        if( this._dirty & X.Dom.Dirty.CSS ){\r
                                if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                                        X.UA.Opera78 || X.UA.NN6 ?\r
@@ -1078,6 +1084,7 @@ Node.prototype._updateRawNode =
                        };\r
                        \r
                        // attr\r
+                       // TODO display:none の場合、更新をスキップ\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
@@ -1089,11 +1096,9 @@ Node.prototype._updateRawNode =
                                                        continue;\r
                                                };\r
                                        };\r
-\r
+                                       // TODO IE では input, なぜか buttonも、type の変更が出来ない、k === 'type' && alert( this._dirty + ' ' + elm.outerHTML );\r
                                        ( v = attrs[ k ] ) === undefined ?\r
                                                elm.removeAttribute( rename[ k ] || k ) :\r
-                                       X.UA.IE === 8 ?\r
-                                               elm.setAttribute( rename[ k ] || k, X.Dom.Attr.noValue[ k ] ? k : v ) :\r
                                                ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v );                          \r
 \r
                                };\r
@@ -1298,7 +1303,7 @@ Node.prototype._afterActualCreate =
                };\r
                // src の onload があるので先ではないか?\r
                // ie の str から要素を作る場合、srcだけ イベント設定後ではないか?\r
-               this._restoreEvent();// イベントの復帰\r
+               X_EventDispatcher_toggleAllEvents( this, true );// イベントの復帰\r
        }) :\r
        X.Dom.DOM_IE4 ? (function(){\r
                var xnodes, i;\r
@@ -1316,7 +1321,7 @@ Node.prototype._afterActualCreate =
                        this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
                };\r
                delete this._dirty;\r
-               this._restoreEvent();// イベントの復帰\r
+               X_EventDispatcher_toggleAllEvents( this, true );// イベントの復帰\r
        }) :\r
        (function(){});\r
 \r
@@ -1334,7 +1339,7 @@ Node.prototype._actualRemove =
                        };\r
 \r
                        if( !elm ) return;\r
-                       this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
+                       this._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( this, false );// イベントの退避\r
                        // elm.parentNode.tagName for ie7\r
                        if( !X.UA.MacIE ){\r
                                !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
@@ -1354,13 +1359,13 @@ Node.prototype._actualRemove =
                        };\r
 \r
                        if( !elm ) return;\r
-                       this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
+                       this._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( this, false );// イベントの退避\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; // MacIE5 でエラー\r
+                       //document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // MacIE5 でエラー\r
                        if( !isChild ) elm.outerHTML = '';\r
                        delete this._rawObject;\r
                }) :\r