From babda23632a3176d9fe546fbab6f79c1fef0e3d4 Mon Sep 17 00:00:00 2001 From: itozyun Date: Sat, 31 Jan 2015 19:46:48 +0900 Subject: [PATCH] Version 0.6.129, fix X.Node. --- 0.6.x/js/02_dom/02_XNode.js | 49 +++++++++++++++++++++++++--------------- 0.6.x/js/02_dom/04_XBoxModel.js | 24 ++++++++++---------- 0.6.x/js/02_dom/10_XNodeAnime.js | 8 +++---- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index 9c6d66d..da8f553 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -1109,12 +1109,14 @@ var X_Node__commitUpdate = if( X_Node_displayNoneFixForIE5 ){ // filter の効いている要素を含む要素は display:none が無視される。 // filter = '' で削除はできるが、再表示時に filter が消える。 -> filter な要素を削除してしまう。 - elm && elm.parentNode && X_Node__actualRemove( that ); + if( elm && elm.parentNode ){ + X_Node__actualRemove( that ); + }; return nextElement; }; elm && ( elm.style.display = 'none' ); return elm || nextElement; - }; + }; // 5. ie5 非表示fixフラグ accumulatedFlags |= that._flags; @@ -1123,7 +1125,6 @@ var X_Node__commitUpdate = if( accumulatedFlags & ( X_Node_State.DIRTY_POSITION | X_Node_State.DIRTY_ID | X_Node_State.DIRTY_CLASSNAME ) === 0 ){ return nextElement; }; - }; // 6. 要素の生成 @@ -1208,8 +1209,9 @@ var X_Node__commitUpdate = // 9. ie5 only // 親及び自身へのクラス・id指定で display : none になるケースがありそれを検出 // 生成と破棄が繰り返されてしまう、親と自身の id, class が変わった場合だけ再生成。 accumulatedFlags & ( ID | CLASSNAME ) + // currentStyle を観ていたときはエラーで停止する、alert と挟むと正常に動いて支離滅裂 if( X_Node_displayNoneFixForIE5 && that._tag ){ - if( elm.currentStyle.display === 'none' ){ + if( elm.runtimeStyle.display === 'none' ){ X_Node__actualRemove( that ); that._flags |= X_Node_State.IE5_DISPLAY_NONE_FIX; return nextElement; @@ -1245,6 +1247,18 @@ var X_Node__commitUpdate = return elm; }; + // 4. style="display:none" の場合 + if( that._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ){ + if( elm ){ + elm.style.display = 'none'; + if( elm.style.display !== 'none' ){ // ie4 の style は currentStyle 相当らしい、、、? div 以外への display:none が効かないので remove する。 + X_Node__actualRemove( that ); + return prevElement; + }; + }; + return elm || prevElement; + }; + if( !elm ){ prevElement ? prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that, false ) ) : @@ -1370,6 +1384,7 @@ var X_Node__updateRawNode = case 'IFRAMEname' : // http://d.hatena.ne.jp/NeoCat/20080921/1221940658 // こちらに名前をsetしないとtargetが動作しない + // これってあとから name を変更できないバグでは? itozyun // if( X_UA.IE ) elm.name = elm.contentWindow.name = v || ''; }; @@ -1438,8 +1453,7 @@ var X_Node__updateRawNode = elm.removeAttribute( 'style' ); delete that._cssText; }; - }; - + } else if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ v = X_Node_CSS_objToIEFilterText( that ); if( v ){ @@ -1485,10 +1499,7 @@ var X_Node__updateRawNode = * document.createElement of ie4 is only for OPTION & IMAGE. */ var X_Node__actualCreate = - X_UA_DOM.W3C ? (function( that, isChild ){ - - }) : - X_UA_DOM.IE4 ? (function( that, isChild ){ + X_UA_DOM.IE4 && (function( that, isChild ){ var uid = that._uid, html, xnodes, n, i, l; @@ -1540,14 +1551,10 @@ var X_Node__actualCreate = }; return html.join( '' ); - }) : - (function(){}); + }); var X_Node__afterActualCreate = - X_UA_DOM.W3C ? (function( that ){ - - }) : - X_UA_DOM.IE4 ? (function( that ){ + X_UA_DOM.IE4 && (function( that ){ var xnodes, i, v; if( !that._tag ) return that; @@ -1560,8 +1567,7 @@ var X_Node__afterActualCreate = that._flags & X_Node_State.DIRTY_IE_FILTER && X_Node__updateRawNode( that, that._rawObject || X_Node__ie4getRawNode( that ) ); that._flags &= X_Node_BitMask_RESET_DIRTY; X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 - }) : - (function(){}); + }); var X_Node__actualRemove = X_UA_DOM.W3C ? @@ -1571,6 +1577,7 @@ var X_Node__actualRemove = var xnodes = that._xnodes, elm = that._rawObject, child, i, l; + if( xnodes && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ child = xnodes[ i ]; @@ -1586,8 +1593,14 @@ var X_Node__actualRemove = // ちなみに elm.filters に触ると ie8 でなぜかカラム落ちが発生、、、 if( X_Node_displayNoneFixForIE5 ){ if( elm.filters && elm.filters.length ){ + //elm.style.removeAttribute( 'filter' ); isChild = false; delete that._rawObject; + // 破棄前に value を控える TODO checked, selected も! + if( X_Node_Attr_HAS_VALUE[ that._tag ] && ( !that._newAttrs || !X_Object_inObject( 'value', that._newAttrs ) ) ){ + that._attrs.value = elm.value; + }; + elm.innerHTML = ''; }; }; diff --git a/0.6.x/js/02_dom/04_XBoxModel.js b/0.6.x/js/02_dom/04_XBoxModel.js index d89ca64..4ba6478 100644 --- a/0.6.x/js/02_dom/04_XBoxModel.js +++ b/0.6.x/js/02_dom/04_XBoxModel.js @@ -69,8 +69,8 @@ Node.prototype.width = function(){ X_Node_updateTimerID && X_Node_startUpdate(); if( X_UA_DOM.W3C ){ - // this.css( X_Node_CSS_Unit.px, 'width' ); - return this._rawObject.offsetWidth; + // TODO width : length + overflow : hidden ならそれを返す? <- block or inline + return this._rawObject ? this._rawObject.offsetWidth : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetWidth; @@ -86,7 +86,7 @@ Node.prototype.height = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'height' ); - return this._rawObject.offsetHeight; + return this._rawObject ? this._rawObject.offsetHeight : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetHeight; @@ -102,7 +102,7 @@ Node.prototype.clientWidth = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); - return this._rawObject.clientWidth; + return this._rawObject ? this._rawObject.clientWidth : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientWidth; @@ -118,7 +118,7 @@ Node.prototype.clientHeight = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'height' ); - return this._rawObject.clientHeight; + return this._rawObject ? this._rawObject.clientHeight : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientHeight; @@ -134,7 +134,7 @@ Node.prototype.scrollWidth = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); - return this._rawObject.scrollWidth; + return this._rawObject ? this._rawObject.scrollWidth : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollWidth; @@ -149,7 +149,7 @@ Node.prototype.scrollHeight = function(){ X_Node_updateTimerID && X_Node_startUpdate(); if( X_UA_DOM.W3C ){ - return this._rawObject.scrollHeight; + return this._rawObject ? this._rawObject.scrollHeight : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollHeight; @@ -165,7 +165,7 @@ Node.prototype.scrollLeft = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); - return this._rawObject.scrollLeft; + return this._rawObject ? this._rawObject.scrollLeft : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollLeft; @@ -181,7 +181,7 @@ Node.prototype.scrollTop = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); - return this._rawObject.scrollTop; + return this._rawObject ? this._rawObject.scrollTop : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollTop; @@ -206,7 +206,7 @@ Node.prototype.x = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'left' ); // this.css( X_Node_CSS_Unit.px, 'translateX' ); - return this._rawObject.offsetLeft; + return this._rawObject ? this._rawObject.offsetLeft : 0; } else if( X_UA_DOM.IE4 ){ // pixelLeft http://www.din.or.jp/~hagi3/JavaScript/JSTips/DHTML/ProbIE5.htm @@ -224,7 +224,7 @@ Node.prototype.y = function(){ if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'top' ); // this.css( X_Node_CSS_Unit.px, 'transisitonY' ); - return this._rawObject.offsetTop; + return this._rawObject ? this._rawObject.offsetTop : 0; } else if( X_UA_DOM.IE4 ){ return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetTop; @@ -244,7 +244,7 @@ Node.prototype.offset = function( /* xnodeParent */ ){ X_Node_updateTimerID && X_Node_startUpdate(); if( X_UA_DOM.W3C ){ - return X_Node_getPosition( this._rawObject ); + return this._rawObject ? X_Node_getPosition( this._rawObject ) : { x : 0, y : 0 }; } else if( X_UA_DOM.IE4 ){ return X_Node_getPosition( this._rawObject || X_Node__ie4getRawNode( this ) ); diff --git a/0.6.x/js/02_dom/10_XNodeAnime.js b/0.6.x/js/02_dom/10_XNodeAnime.js index 463080a..9a3078c 100644 --- a/0.6.x/js/02_dom/10_XNodeAnime.js +++ b/0.6.x/js/02_dom/10_XNodeAnime.js @@ -281,7 +281,7 @@ function X_Node_Anime_updateAnimation( xnode ){ X_ViewPort.unlisten( X.Event.AFTER_UPDATE, xnode, X_Node_Anime_gpuReleased ); xnode.css({ - //willChange : X_Node_Anime_transitionProps + ',opacity,width,height', + willChange : X_Node_Anime_transitionProps + ',opacity,width,height', backfaceVisibility : 'hidden', transitionTimingFunction : obj.easing.style, transitionDelay : '0s' // 0.001 にすると transitionend のタイミングが狂う、、、 @@ -300,7 +300,7 @@ function X_Node_Anime_updateAnimation( xnode ){ xnode.listenOnce( 'transitionend', X_Node_Anime_onTransitionEnd ); xnode.css({ - transitionProperty : X_Node_Anime_transitionProps + ',opacity,width,height', // X_Node_Anime_readyTransitionに移動?? + transitionProperty : X_Node_Anime_transitionProps + ',opacity,width,height', transitionDuration : obj.duration + 'ms' }); @@ -445,10 +445,10 @@ function X_Node_Anime_clearTransition( xnode ){ // 開始座標のセット(新規のみ) // アニメーション指定のセット(または解除)(対象のみ) // 目標座標のセット - //xnode.unlisten( 'transitionend', X_Node_Anime_onTransitionEnd ); + xnode.unlisten( 'transitionend', X_Node_Anime_onTransitionEnd ); xnode.css({ - //willChange : '', + willChange : '', backfaceVisibility : '', transitionTimingFunction : '', transitionDelay : '', -- 2.11.0