\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
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
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
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
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
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
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;
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 :
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 );
if( !textNode && content !== ' ' && content.length ){
node.data = content;
textNode = node;
- ++i;
break;
} else
if( textNode ){
};
})( 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;
};
++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 {
++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;
++n;
continue;
};
- alert( xnode._tag + '>' + '"' + _xnode._text + '" !== ' + child.tagName + '\n' + child.outerHTML );
+ alert( xnode._tag + '>' + '"' + _xnode._text + '" !== ' + tag + '\n' + child.outerHTML );
++j;
continue;
};
for( ; j < m; ++j ){
elm = children[ j ];
tag = elm.tagName;
-
- if( tag === '!' ){
+ /*
+ * 未知のタグについては、閉じタグも含めてタグ名扱いになる
+ */
+ if( tag === '!' || tag.charAt( 0 ) === '/' ){
continue;
} else
if( xnode._tag !== tag ){
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);
} );
X.Dom.BoxModel.boxSizingEnabled = elm.offsetWidth === 10;
};
-
-
// padding
// border
// margin
// 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
},
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
{} :
{},
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 );
(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;
elm = elm.children[ elm.children.length - 1 ];
v = elm.offsetHeight;
elm.outerHTML = '';
- return v;
+ return v * 0.75;
}) :
(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();
} );
position : 'absolute'\r
}\r
);\r
+ Node.root._startUpdate();\r
img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode;\r
remove = true;\r
} else {\r
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