OSDN Git Service

Version 0.6.24, bugfix.
authoritozyun <itozyun@user.sourceforge.jp>
Sat, 1 Mar 2014 06:43:21 +0000 (15:43 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Sat, 1 Mar 2014 06:43:21 +0000 (15:43 +0900)
0.6.x/js/dom/11_XDomDTD.js
0.6.x/js/dom/11_XDomNode.js
0.6.x/js/dom/12_XDomEvent.js
0.6.x/js/dom/13_XDomBoxModel.js
0.6.x/js/dom/14_XDomAttr.js
0.6.x/js/dom/15_XDomStyle.js
0.6.x/js/dom/20_XDomImage.js

index bdb2854..41a9f05 100644 (file)
@@ -1,4 +1,5 @@
 \r
 X.Dom.DTD = {\r
-       EMPTY : {area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1}\r
+       EMPTY : {area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1 }//,\r
+       //      video:1,audio:1}\r
 };\r
index 775796d..63d178c 100644 (file)
@@ -539,7 +539,7 @@ Node.prototype.destroy = function( isChild ){
        elm && this.unlisten(); // イベントの退避\r
 \r
        delete Node._chashe[ this._uid ];\r
-       delete this._state;     \r
+       delete this._state;\r
        \r
        if( this._root ){\r
                this.remove();\r
@@ -760,6 +760,12 @@ Node.prototype.text = function( text ){
        return this._text;\r
 };\r
 \r
+Node.prototype.each = function( func ){\r
+       func.call( this, 0 );\r
+       return this;\r
+};\r
+\r
+\r
 /* --------------------------------------\r
  *  Async commit update\r
  * \r
@@ -907,6 +913,7 @@ Node.prototype._updateRawNode =
                                if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                                        elm.style.cssText = this._cssText;\r
                                } else {\r
+                                       elm.style.cssText = '';\r
                                        elm.removeAttribute( 'style' );\r
                                        delete this._cssText;\r
                                };\r
@@ -920,6 +927,14 @@ 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 < 5.5 ){\r
+                                               if( this._tag === 'TEXTAREA' && k === 'value' ){\r
+                                                       elm.firstChild ?\r
+                                                               ( elm.firstChild.data = attrs[ k ] ) :\r
+                                                               elm.appendChild( document.createTextNode( attrs[ k ] ) );\r
+                                                       continue;\r
+                                               };\r
+                                       };\r
                                        ( v = attrs[ k ] ) === undefined ?\r
                                                elm.removeAttribute( rename[ k ] || k ) :\r
                                                ( elm[ rename[ k ] || k ] = v );\r
@@ -954,6 +969,7 @@ Node.prototype._updateRawNode =
                                if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                                        elm.style.cssText = this._cssText;\r
                                } else {\r
+                                       elm.style.cssText = '';\r
                                        elm.removeAttribute( 'style' );\r
                                        delete this._cssText;\r
                                };\r
index 222d6fc..85a39e3 100644 (file)
@@ -54,7 +54,7 @@ if( window.addEventListener ){
                        this.changedTouches = e.changedTouches;
                        this.targetTouches  = e.targetTouches;
                        this.metaKey        = e.metaKey;
-                       this.force          = e.force || e.webkitForce;
+                       this.force          = e.force || e.webkitForce || 0;
                } else
                if( e.constructor === window.PointerEvent ){
                        // PointerEvent;
@@ -329,20 +329,25 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
        
        r._root  = Node._html._root = r;
        r.parent = Node._html;
+       Node._html._xnodes = [ r ];
        //r.width  = new Function( 'return X.Dom.getSize()[ 0 ]' );
        //r.height = new Function( 'return X.Dom.getSize()[ 1 ]' );
        
        // todo: cleanup tree
        
+       
+       
+       
        body.childNodes && (function( elm, skip, head ){
                var me         = arguments.callee,
                        moveToHead = 'style,bgsound,area,base,meta'.split( ',' ),
                        remove     = 'script,noscript,noframes,comment,!,noembed,nolayer'.split( ',' ),
                        noncleanup = 'pre,textarea,code,kbd,samp,xmp,plaintext,listing'.split( ',' ),
-                       nodes      = elm.childNodes,
+                       nodes      = X.copyArray( elm.childNodes ),
                        i          = 0,
+                       l          = nodes.length,
                        node, tag, textNode, content;
-               for( ; i < nodes.length; ){
+               for( ; i < l; ++i ){
                        node = nodes[ i ];
                        switch( node.nodeType ){
                                case 1 :
@@ -353,14 +358,13 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                                continue;
                                        } else
                                        if( remove.indexOf( tag ) !== -1 ){
-                                               node.parentNode.removeChild( node );
+                                               elm.removeChild( node );
                                                continue;
                                        } else {
                                                // pre タグ以下はスペースの置換は行わない
-                                               me( node, skip || noncleanup.indexOf( tag ) !== -1, head );
+                                               node.childNodes && node.childNodes.length &&  me( node, skip || noncleanup.indexOf( tag ) !== -1, head );
                                        };
-                                       textNode = false;
-                                       ++i;                                            
+                                       textNode = false;                       
                                        break;
                                case 3 :
                                        content = skip ? node.data : X.Dom.cleanupWhiteSpace( node.data );
@@ -368,7 +372,6 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                        if( !textNode && content !== ' ' && content.length ){
                                                node.data = content;
                                                textNode  = node;
-                                               ++i;
                                                break;
                                        } else
                                        if( textNode ){
@@ -383,17 +386,23 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                };
        })( body );
        
+       
+       
+       
+       
        createTree =
                body.childNodes ?
                        (function( xnode, childNodes, skipCleanup ){
                                var i = 0,
                                        j = 0,
+                                       l = childNodes.length,
                                        child, _xnode, f, tag, text, _xtext, doc;
                                childNodes = X.copyArray( childNodes );
 
-                               for( ; i < childNodes.length; ++i ){
+                               for( ; i < l; ++i ){
                                        child = childNodes[ i ];
-                                       if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || child.tagName === '!' ){
+                                       tag   = child.tagName;
+                                       if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || tag === '!' || tag && tag.charAt( 0 ) === '/' ){
                                                child.parentNode.removeChild( child );
                                                continue;
                                        };
@@ -412,9 +421,8 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                                                ++j;
                                                                continue;
                                                        };
-                                                       tag = child.tagName;
                                                        if( _xnode._tag.toUpperCase() !== tag ){
-                                                               alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );
+                                                               alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );
                                                                ++j;
                                                                continue;
                                                        } else {
@@ -430,8 +438,8 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                                                        ++n;
                                                                        continue;
                                                                } else {
-                                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );
-                                                                       child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
+                                                                       //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );
+                                                                       child.childNodes && child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
                                                                };
                                                                _xtext = null;
                                                                f = true;
@@ -447,7 +455,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                                                        ++n;
                                                                        continue;
                                                                };
-                                                               alert(  xnode._tag + '>' + '"' + _xnode._text + '" !== ' + child.tagName + '\n' + child.outerHTML );
+                                                               alert(  xnode._tag + '>' + '"' + _xnode._text + '" !== ' + tag + '\n' + child.outerHTML );
                                                                ++j;
                                                                continue;
                                                        };
@@ -548,8 +556,10 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                                        for( ; j < m; ++j ){
                                                elm = children[ j ];
                                                tag = elm.tagName;
-                                               
-                                               if( tag === '!' ){
+                                               /*
+                                                * 未知のタグについては、閉じタグも含めてタグ名扱いになる
+                                                */
+                                               if( tag === '!' || tag.charAt( 0 ) === '/' ){
                                                        continue;
                                                } else
                                                if( xnode._tag !== tag ){
@@ -615,7 +625,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
        
        r._startUpdate();
        
-       xnodes.splice( xnodes.indexOf( s ), 1 ); // hide from api user
+       //xnodes.splice( xnodes.indexOf( s ), 1 ); // hide from api user
        
        //alert(n +  ' ' + body.innerHTML);
 } );
index 0d1a054..94336e9 100644 (file)
@@ -22,8 +22,6 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                
                X.Dom.BoxModel.boxSizingEnabled = elm.offsetWidth === 10;
        };
-       
-
        // padding
        // border
        // margin
index 720155c..fb53d4b 100644 (file)
@@ -175,12 +175,14 @@ X.Dom.Attr = {
        // http://nanto.asablo.jp/blog/2005/10/29/123294\r
        // checked -> defaultChecked\r
        // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される\r
+       // 先頭にスペース\r
        objToAttrText : function( obj ){\r
-               var noValue = X.Dom.Attr.noValue, attrs = [], n = -1, p;\r
+               var noValue = X.Dom.Attr.noValue,\r
+                       attrs = [ '' ], n = 0, p;\r
                for( p in obj ){\r
                        attrs[ ++n ] = noValue[ p ] ? p : [ p, '="', obj[ p ], '"' ].join( '' );\r
                };\r
-               return attrs.join( ' ' );\r
+               return 0 < n ? attrs.join( ' ' ) : '';\r
        }\r
 };\r
 \r
index 9901d91..f7155de 100644 (file)
@@ -147,12 +147,12 @@ _GRNERAL
        },
        
        IE_FILTER_FIX :
-               X.UA.IE && X.UA.IE < 8 ?
+               X.UA.IE && X.UA.IE < 9 ?
                        {
                                opacity : 1,
                                textShadow : 1
                        } :
-               X.UA.IE === 9 ?
+               9 <= X.UA.IE && X.UA.IE < 10 ? // == 9
                        {} :
                        {},
        
@@ -1010,9 +1010,9 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */
 X.Dom.Node.prototype.cssText = function( v ){
        var obj, i, l, attr, name;
        if( X.Type.isString( v ) ){
+               delete this._css;
                obj = {};
                v   = v.split( ';' );
-               delete this._css;
                for( i = 0, l = v.length; i < l; ++i ){
                        attr = v[ i ].split( ':' );
                        ( name = attr[ 0 ] ) && ( obj[ name ] = attr[ 1 ] || true );
@@ -1034,35 +1034,45 @@ X.Dom.Node.prototype._getCharSize =
                (function(){
                        return parseInt( document.defaultView.getComputedStyle( this._rawNode, null ).fontSize );
                }) :
-       X.UA.IE && 5 <= X.UA.IE ?
+       X.UA.IE && 5.5 <= X.UA.IE ?
                (function(){
                        var font = this._rawNode.currentStyle.fontSize,
                                vu   = X.Dom.Style._Util._splitValueAndUnit( font ),
                                v    = vu[ 0 ],
-                               u    = vu[ 1 ];
+                               u    = vu[ 1 ],
+                               elm;    
+                       if( v === 0 ){
+                               if( v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return v;
+                       } else {
+                               if( u = X.Dom.Style._UNIT_RATIO[ u ] ) return v / u;
+                       };
                        switch( u ){
                                case 'px' :
                                        return v;
                                case 'em' :
                                // body まで辿ってしまった場合は?
-                                       return this.parent._getCharSize() * v;
+                                       if( this.parent ) return this.parent._getCharSize() * v;
+                                       break;
                                case '%' :
                                // body まで辿ってしまった場合は?
-                                       return this.parent._getCharSize() * v / 100;
+                                       if( this.parent ) return this.parent._getCharSize() * v / 100;
+                                       break;
                        };
-                       return v === 0 ?
-                                       ( X.Dom.Style._FONT_SIZE_RATIO[ font ] || 0 ) :
-                                       v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
-                       // appendChild
-                       // removeChild
+                       elm = document.createElement( 'div' );
+                       Node._systemNode._rawNode.appendChild( elm );
+                       elm.style.cssText = 'position:absolute;top:0;left:0;overflow:hidden;line-height:1;height:1em;';
+                       elm.innerText = 'X';
+                       v = elm.offsetHeight;
+                       Node._systemNode._rawNode.removeChild( elm );
+                       return v;
                }) :
        document.getElementById ?
                (function(){
                        var elm = document.createElement( 'span' ),
                                v;
-                       elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
-                       elm.innerHTML = 'X';
                        this._rawNode.appendChild( elm );
+                       elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
+                       elm.innerHTML = 'X';                    
                        v = elm.offsetHeight;
                        this._rawNode.removeChild( elm );
                        return v;
@@ -1074,7 +1084,7 @@ X.Dom.Node.prototype._getCharSize =
                        elm = elm.children[ elm.children.length - 1 ];
                        v   = elm.offsetHeight;
                        elm.outerHTML = '';
-                       return v;
+                       return v * 0.75;
                }) :
                (function(){
                });
@@ -1155,13 +1165,13 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
 
        output = X.Dom.Style._FONT_SIZE_RATIO = {},
        list   = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' );
-       base   = xnode.css( 'lineHeight', 1 ).text( 'X' ).height();
+       xnode.css( { lineHeight : '100%', height : '1em' } ).text( 'X' );
        
        for( i = list.length; i; ){
                size = list[ --i ];
-               output[ size ] = xnode.css( 'fontSize', size ).height() / base;
+               output[ size ] = xnode.css( 'fontSize', size ).height();// / base;
        };
        
-       xnode.empty().cssText( '' );
+       xnode.cssText( '' ).empty();
 } );
 
index 4634101..46870d4 100644 (file)
@@ -22,6 +22,7 @@ X.Dom.Image = {
                                        position   : 'absolute'\r
                                }\r
                        );\r
+                       Node.root._startUpdate();\r
                        img    = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode;\r
                        remove = true;\r
                } else {\r
@@ -98,8 +99,8 @@ X.Dom.Image = {
                                var img;\r
                                \r
                                this.abspath = abspath;\r
-                               this.delay   = delay;\r
-                               this.timeout = timeout;\r
+                               this.delay   = delay || 100;\r
+                               this.timeout = timeout || 10000;\r
                                this.xnode =\r
                                        (\r
                                                window.Image ?\r