-\r
X.Dom.Dirty = {\r
CLEAN : 0,\r
- TREE : 1, // width, height, x, y\r
- CONTENT : 2, // width, height, x, y textNode の内容\r
- CLASSNAME : 4, // _getCharSize, width, height, x, y\r
- CSS : 8, // _getCharSize, width, height, x, y\r
- ATTR : 16, // _getCharSize, width, height, x, y\r
- IE4_TEXTNODE_FIX : 32\r
+ CHILD_IS_DIRTY : 1,\r
+ ID : 2, // width, height, x, y\r
+ CONTENT : 4, // width, height, x, y textNode の内容\r
+ 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 && !X.UA.MacIE ? 64 : 0,\r
+ UNKNOWN_TAG_FIX : 128,\r
+ IE4_TEXTNODE_FIX : 256\r
+};\r
+\r
+X.Dom.State = {\r
+ DESTROYED : 0,\r
+ EXIST : 1,\r
+ BELONG_TREE : 2,\r
+ DISPLAY_NONE : 4,\r
+ DISPLAY_BLOCK : 8,\r
+ DISPLAY_INLINE : 16,\r
+ POSITION_ABSOLUTE : 32,\r
+ OVERFLOW_HIDDEN : 64,\r
+ HAS_WIDTH_LENGTH : 128,\r
+ HAS_WIDTH_PERCENT : 256,\r
+ HAS_HEIGHT_LENGTH : 512,\r
+ HAS_HEIGHT_PERCENT : 1024,\r
+ IE4_ONLY_TEXT : 2048,\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.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
{\r
_uid : 0,\r
_state : 0,\r
- _destroyed : false,\r
- _dirty : 0, \r
+ _dirty : 0,\r
+ \r
+ _isNew : false,\r
\r
_rawNode : null,\r
- _root : null, \r
- parent : null,\r
+ _root : null, // xnode が文書ツリーに属しているか?はこれを見る\r
+ parent : null, // remove された枝も親子構造は維持している。\r
_xnodes : null,\r
\r
_xnodeType : 0,\r
\r
_attrs : null, // X.Dom.Attr\r
_newAttrs : null,\r
- _attrText : '',\r
+ _attrText : '', // X.Dom.Attr.objToAttrText が必要な場合は false が入っている\r
\r
_css : null, // X.Dom.Style\r
- _cssText : '',\r
+ _cssText : null,\r
+ \r
+ _fontSize : 0,\r
+ \r
+ _anime : null,\r
\r
Constructor : function( v ){\r
var css, xnodes, xnode, parent, uid = Node._chashe.length;\r
\r
if( Node._newByTag ){\r
Node._newByTag = false;\r
- this._tag = v;\r
+ this._tag = v.toUpperCase();\r
this._xnodeType = 1;\r
+ this._state = X.Dom.State.DISPLAY_INLINE; // todo\r
arguments[ 1 ] && this.attr( arguments[ 1 ] );\r
- css = arguments[ 2 ];\r
+ css = arguments[ 2 ] || arguments[ 1 ];\r
css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css );\r
} else\r
if( Node._newByText ){\r
Node._newByText = false;\r
this._text = v;\r
this._xnodeType = 3;\r
- this._charCode = '';\r
- for( v = 0; v < this._text.length; ++v ){\r
- this._charCode += this._text.charCodeAt( v ) + ',';\r
- };\r
+ this._state = X.Dom.State.DISPLAY_INLINE;\r
} else {\r
if( 1 < arguments.length ) return new X.Dom.NodeList( arguments );\r
if( X.Type.isArray( v ) && v.length ) return new X.Dom.NodeList( v );\r
case Node.IS_RAW_HTML :\r
if( xnode = Node._getXNode( v ) ) return xnode;\r
// v.parentNode || v.parentElement : dom1 || dom0\r
- this.parent = v !== document.body && ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && Node._getXNode( parent );\r
- this._state = this.parent ? Node.STATE_STAGED : Node.STATE_NO_PARENT;\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._rawNode = v;\r
this._xnodeType = 1;\r
- this._tag = v.tagName;\r
+ this._state = X.Dom.State.DISPLAY_BLOCK; // todo\r
+ this._tag = v.tagName.toUpperCase();\r
this._id = v.id;\r
this._className = v.className;\r
this.cssText( v.style.cssText );\r
- // attr\r
- \r
- if( X.UA.IE && X.UA.IE < 5 ){\r
+ // X.Dom.Dirty.CSS を落とす\r
+ this._dirty = 0;\r
+ // attr の回収は不可能、、、\r
+ if( X.Dom.DOM_IE4 ){\r
v.setAttribute( 'UID', '' + uid );\r
} else {\r
v.UID = uid;\r
case Node.IS_RAW_TEXT :\r
if( xnode = Node._getXNode( v ) ) return xnode;\r
this.parent = Node._getXNode( v.parentNode );\r
- this._state = this.parent ? Node.STATE_STAGED : Node.STATE_NO_PARENT;\r
+ this._root = this.parent ? this.parent._root : null;\r
this._rawNode = v;\r
this._xnodeType = 3;\r
+ this._state = X.Dom.State.DISPLAY_INLINE;\r
this._text = v.data;\r
v.UID = uid;\r
break;\r
if( xnodes.length ) return xnodes[ 0 ];\r
return Node.none;\r
case Node.IS_IMAGE :\r
- v.UID = uid;\r
+ if( xnode = Node._getXNode( v ) ) return xnode;\r
+ this._rawNode = v;\r
+ this._xnodeType = 4;\r
+ v.UID = uid;\r
+ this._state = X.Dom.State.EXIST;\r
+ break;\r
case Node.IS_WINDOW :\r
case Node.IS_DOCUMENT :\r
+ if( xnode = Node._getXNode( v ) ) return xnode;\r
this._rawNode = v;\r
this._xnodeType = 2;\r
- this._state = Node.STATE_STAGED;\r
+ this._state = X.Dom.State.DISPLAY_BLOCK;\r
break;\r
default :\r
if( Node.none ) return Node.none;\r
}\r
);\r
\r
-var Node = X._shortcut = X.Dom.Node;\r
+var Node = X.Dom.Node;\r
\r
Node.IS_XNODE = 1;\r
Node.IS_RAW_HTML = 2;\r
Node.IS_DOCUMENT = 9;\r
Node.IS_IMAGE = 10;\r
\r
-\r
-Node.STATE_NO_RAW = 0; // new Node されたばかり\r
-Node.STATE_NO_PARENT = 1; // exist node._rawNode\r
-//Node.STATE_DIRTY = 2;\r
-Node.STATE_STAGED = 2; // exist _rawNode.parentNode\r
-Node.STATE_DESTROYED = 3;\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
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.Safari && X.UA.Safari < 3 ){\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( v.tagName ) return Node.IS_RAW_HTML;\r
//if( v.nodeType === 11 ) return Node.IS_DOC_FRAG;\r
return 0;\r
};\r
-Node._getXNode = function( node ){\r
- var uid;\r
- switch( Node._getType( node ) ){\r
+Node._getXNode = function( v ){\r
+ var uid, i, chashe, xnode;\r
+ switch( Node._getType( v ) ){\r
case Node.IS_XNODE :\r
case Node.IS_XNODE_LIST :\r
- return node;\r
+ return v;\r
case Node.IS_RAW_HTML :\r
- case Node.IS_RAW_TEXT :\r
case Node.IS_IMAGE :\r
- if( X.UA.IE && X.UA.IE < 5 ){\r
- uid = node.getAttribute( 'UID' );\r
+ // fake TextNode too.\r
+ if( X.Dom.DOM_IE4 ){\r
+ uid = v.getAttribute( 'UID' );\r
return uid && Node._chashe[ uid ];\r
};\r
- return node.UID && Node._chashe[ node.UID ];\r
+ return v.UID && Node._chashe[ v.UID ];\r
case Node.IS_WINDOW :\r
return Node._window;\r
case Node.IS_DOCUMENT :\r
return Node._document;\r
+ case Node.IS_RAW_TEXT :\r
+ if( v.UID ) return Node._chashe[ v.UID ];\r
+ for( chashe = Node._chashe, i = chashe.length; i; ){\r
+ if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawNode === v ) ) return xnode;\r
+ };\r
};\r
};\r
\r
\r
-Node.create = function( tag, opt_attr, opt_css ){\r
- Node._newByTag = true;\r
- return new Node( tag, opt_attr, opt_css );\r
+Node.create = function( tag, opt_attrs, opt_css ){\r
+ var list, i;\r
+ switch( Node._getType( tag ) ){\r
+ case Node.IS_STRING :\r
+ Node._newByTag = true;\r
+ return new Node( tag, opt_attrs, opt_css );\r
+ case Node.IS_HTML_STRING :\r
+ list = X.Dom.parse( tag, true );\r
+ for( i = list.length; 1 < i; ){\r
+ list[ --i ].destroy();\r
+ };\r
+ return list[ 0 ];\r
+ };\r
};\r
Node.createText = function( text ){\r
Node._newByText = true;\r
\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
- X.UA.IE && X.UA.IE < 5 ?\r
+ X.Dom.DOM_IE4 ?\r
X.emptyFunction :\r
(function( root ){\r
- return root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName;\r
+ if( X.Type.isBoolean( root.isXML ) ) return root.isXML;\r
+ return root.isXML = root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName;\r
});\r
\r
Node._chashe = [];\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.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
\r
-if( !document.getElementById && document.all ){\r
+if( X.Dom.DOM_IE4 ){\r
Node.prototype._ie4getRawNode = function(){\r
- var elm, uid;\r
- if( elm = this._rawNode ) return elm;\r
- if( this._id && ( elm = this._rawNode = document.all[ this._id ] ) ){\r
- return elm;\r
- };\r
- if( elm = this._rawNode = document.all[ 'ie4uid' + this._uid ] ){\r
- if( this._id ) elm.setAttribute( 'id', this._id );\r
- return elm;\r
- };\r
+ var elm = this._rawNode;\r
+ return elm ||\r
+ ( ( elm = document.all[ 'ie4uid' + this._uid ] ) && ( this._rawNode = elm ) ) ||\r
+ ( this._id && ( elm = document.all[ this._id ] ) ) && ( this._rawNode = elm );\r
};\r
};\r
\r
if( this._xnodeType !== 1 ) return;\r
if( !this._xnodes ) this._xnodes = [];\r
\r
- Node._newByTag = true;\r
- xnode = new Node( tag, opt_attrs, opt_css );\r
- xnode.parent = this;\r
+ xnode = Node.create( tag, opt_attrs, opt_css );\r
\r
- this._reserveUpdate();\r
+ xnode.parent = this;\r
this._xnodes[ this._xnodes.length ] = xnode;\r
+ this._root && this._reserveUpdate();\r
return xnode;\r
};\r
\r
xnode = new Node( text );\r
xnode.parent = this;\r
\r
- this._reserveUpdate();\r
+ this._root && this._reserveUpdate();\r
this._xnodes[ this._xnodes.length ] = xnode;\r
return xnode;\r
};\r
switch( this._xnodeType ){\r
case 1 :\r
Node._newByTag = true;\r
- xnode = new Node( this._tag, X.cloneObject( this._attrs ), X.cloneObject( this._css ) );\r
- xnode.className( this._className );\r
+ xnode = new Node( this._tag, X.cloneObject( this._attrs ), X.cloneObject( this._css ) )\r
+ .attr( { 'id' : this._id } )\r
+ .className( this._className );\r
if( opt_clone_children && ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
for( i = 0; i < l; ++i ){\r
xnode.append( xnodes[ i ].clone( true ) );\r
break;\r
case Node.IS_HTML_STRING :\r
case Node.IS_STRING :\r
- return this.append( X.Dom.parse( v, true ) );\r
+ return this.append.apply( this, X.Dom.parse( v, true ) );\r
case Node.IS_XNODE :\r
if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
// 親の xnodes から v を消す\r
if( v.parent ){\r
- v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
- // ie4\r
- !document.getElementById && document.all && v.remove();\r
- } else\r
- if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
- if( v._destroyed ) alert( 'xnode already destroyed!' );\r
- Node._reserveRemoval.splice( i, 1 );\r
- };\r
+ //if( X.Dom.DOM_W3C ){\r
+ // v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
+ //} else\r
+ //if( X.Dom.DOM_IE4 ){\r
+ v.remove();\r
+ //} else {\r
+ \r
+ //};\r
+ };// else\r
+ //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
+ // if( !this._state ) alert( 'xnode already destroyed!' );\r
+ // Node._reserveRemoval.splice( i, 1 );\r
+ //};\r
+ break;\r
default :\r
return this;\r
};\r
\r
- this._reserveUpdate();\r
v.parent = this;\r
- v._state = Node.STATE_NO_PARENT;\r
xnodes[ xnodes.length ] = v;\r
+ this._root && this._reserveUpdate();\r
return this;\r
};\r
\r
\r
if( this._xnodeType !== 1 ) return this;\r
\r
+ l = arguments.length;\r
if( !( xnodes = this._xnodes ) ) xnodes = this._xnodes = [];\r
\r
- l = arguments.length;\r
if( xnodes.length <= start ){\r
if( l === 2 ) return this.append( v );\r
- v = [];\r
- for( ; 1 < l; ){\r
- v[ l - 2 ] = arguments[ --l ];\r
+ for( i = 1; i < l; ++i ){\r
+ this.append( arguments[ i ] );\r
};\r
- return this.append.apply( this, v );\r
+ return this;\r
};\r
if( start < 0 ) start = 0;\r
if( 2 < l ){\r
if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
// 親の xnodes から v を消す\r
if( v.parent ){\r
- v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
- // ie4\r
- !document.getElementById && document.all && v.remove();\r
- } else\r
- if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
- if( v._destroyed ) alert( 'xnode already destroyed!' );\r
- Node._reserveRemoval.splice( i, 1 );\r
- };\r
+ //if( X.Dom.DOM_W3C ){\r
+ // v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
+ //} else\r
+ //if( X.Dom.DOM_IE4 ){\r
+ v.remove();\r
+ //} else {\r
+ \r
+ //};\r
+ };// else\r
+ //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
+ // if( !this._state ) alert( 'xnode already destroyed!' );\r
+ // Node._reserveRemoval.splice( i, 1 );\r
+ //};\r
break;\r
default :\r
return this;\r
};\r
\r
- this._reserveUpdate();\r
v.parent = this;\r
- v._state = Node.STATE_NO_PARENT;\r
this._xnodes.splice( start, 0, v );\r
+ this._root && this._reserveUpdate();\r
return this;\r
};\r
\r
Node.prototype.appendTo = function( parent, opt_index ){\r
- if( parent.constructor === Node ){\r
- opt_index === undefined ? parent.append( this ) : parent.appendAt( opt_index, this );\r
- } else {\r
- opt_index === undefined ? new Node( parent ).append( this ) : new Node( parent ).appendAt( opt_index, this );\r
+ switch( Node._getType( parent ) ){\r
+ case Node.IS_RAW_HTML :\r
+ parent = new Node( parent );\r
+ break;\r
+ case Node.IS_HTML_STRING :\r
+ parent = X.Dom.parse( parent, true );\r
+ parent = parent[ 0 ] || parent;\r
+ case Node.IS_XNODE :\r
+ break;\r
+ default :\r
+ return this;\r
};\r
+ opt_index === undefined ? parent.append( this ) : parent.appendAt( opt_index, this );\r
return this;\r
};\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
* Before , After, Replace\r
*/\r
Node.prototype.before = function( v ){\r
- var parent, l;\r
- if( this._xnodeType !== 1 || !( parent = this.parent ) ) return this;\r
+ var parent, l, start;\r
+ if( !( parent = this.parent ) ) return this;\r
+ \r
l = arguments.length;\r
+ start = this.getOrder();\r
if( 1 < l ){\r
- v = [ this.getOrder() ];\r
for( ; l; ){\r
- v[ l ] = arguments[ --l ];\r
+ parent.appendAt( start, arguments[ --l ] );\r
};\r
- parent.appendAt.apply( parent, v );\r
return this;\r
};\r
- parent.appendAt( this.getOrder(), v );\r
+ parent.appendAt( start, v );\r
return this;\r
};\r
\r
Node.prototype.after = function( v ){\r
- var parent, l;\r
- if( this._xnodeType !== 1 || !( parent = this.parent ) ) return this;\r
+ var parent, l, i, start;\r
+ if( !( parent = this.parent ) ) return this;\r
+ \r
l = arguments.length;\r
+ start = this.getOrder() + 1;\r
+ if( parent._xnodes.length <= start ){\r
+ if( 1 < l ){\r
+ for( i = 0; i < l; ++i ){\r
+ parent.append( arguments[ i ] );\r
+ };\r
+ return this;\r
+ };\r
+ parent.append( v );\r
+ return this;\r
+ };\r
if( 1 < l ){\r
- v = [ this.getOrder() + 1 ];\r
for( ; l; ){\r
- v[ l ] = arguments[ --l ];\r
+ parent.appendAt( start, arguments[ --l ] );\r
};\r
- parent.appendAt.apply( parent, v );\r
return this;\r
};\r
- parent.appendAt( this.getOrder() + 1, v );\r
+ parent.appendAt( start, v );\r
return this;\r
};\r
\r
*/\r
Node.prototype.remove = function(){\r
var parent = this.parent;\r
- \r
+ \r
if( !parent ) return this;\r
\r
- this._state = Node.STATE_NO_PARENT;\r
parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 );\r
- Node._reserveRemoval[ Node._reserveRemoval.length ] = this;\r
- parent._reserveUpdate();\r
+ if( this._root ){\r
+ Node._reserveRemoval[ Node._reserveRemoval.length ] = this;\r
+ this._reserveUpdate();\r
+ };\r
delete this.parent;\r
+ delete this._root;\r
return this;\r
};\r
\r
Node.prototype.empty = function(){\r
- var xnodes = this._xnodes, child, i, l;\r
- if( xnodes && ( l = xnodes.length ) ){\r
- for( i = 0; i < l; ++i ){\r
- xnodes[ i ].destroy();\r
+ var xnodes = this._xnodes, i;\r
+ if( xnodes && ( i = xnodes.length ) ){\r
+ for( ; i; ){\r
+ xnodes[ --i ].destroy();\r
};\r
xnodes.length = 0;\r
};\r
* destory\r
*/\r
Node.prototype.destroy = function( isChild ){\r
- var xnodes = this._xnodes, i;\r
+ var xnodes = this._xnodes, i, elm;\r
\r
- if( this._destroyed ) return;\r
+ if( !this._state ) return;\r
+ \r
+ elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode();\r
\r
if( xnodes && ( i = xnodes.length ) ){\r
- for( ; i; ){\r
- xnodes[ --i ].destroy( true );\r
- };\r
- xnodes.length = 0;\r
+ //for( ; i; ){\r
+ // xnodes[ --i ].destroy( true );\r
+ //};\r
};\r
- this.unlisten(); // イベントの退避\r
+ elm && this._listeners && this.unlisten(); // イベントの退避\r
\r
delete Node._chashe[ this._uid ];\r
+ delete this._state;\r
\r
- if( this._rawNode && this._rawNode.parentNode && this._rawNode.parentNode.tagName ){\r
- this.remove();\r
- this._state = Node.STATE_DESTROYED;\r
- this._destroyed = true; // state \r
+ if( this._root ){\r
+ !isChild && this.remove();\r
} else {\r
- this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 );\r
- !isChild && this._actualRemove();\r
+ this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 );\r
+ elm && !isChild && this._actualRemove();\r
this.kill();\r
};\r
};\r
* contains\r
*/\r
Node.prototype.contains = function( v ){\r
- var node, xnodes, i;\r
- if( !v || !this.parent || this._xnodeType !== -1 ) return false;\r
+ var elm, type, xnodes, i;\r
+ if( !v || this._xnodeType !== 1 ) return false;\r
// contains ie4+\r
- if( document.contains ){\r
- node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;\r
- switch( Node._getType( v ) ){\r
- case Node.IS_RAW_HTML :\r
- case Node.IS_RAW_TEXT :\r
- return node.contains( v );\r
- case Node.IS_XNODE :\r
- if( v.parent === this ) return true;\r
- v = v._ie4getRawNode ? v._ie4getRawNode() : v._rawNode;\r
- if( node && v ) return node.contains( v );\r
- break;\r
- default :\r
- return false;\r
- }; \r
+ if( ( elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = Node._getType( v ) ) && ( type === Node.IS_RAW_HTML || type === Node.IS_RAW_TEXT ) ){\r
+ return elm.contains( v ); \r
};\r
//if( document.compareDocumentPosition ){\r
// \r
//};\r
xnodes = this._xnodes;\r
if( xnodes.indexOf( v ) !== -1 ) return true;\r
- if( ( node = this._rawNode ) && node === v.parentNode ) return false;\r
+ if( elm === v.parentNode ) return false;\r
for( i = xnodes.length; i; ){\r
if( xnodes[ --i ].contains( v ) ) return true;\r
};\r
/* --------------------------------------\r
* getChild\r
*/\r
-Node.prototype.getChildAt = function( index ){\r
- var xnodes = this._xnodes;\r
- if( this._xnodeType !== 1 || index < 0 || !xnodes || xnodes.length <= index ) return; //?\r
- return xnodes[ index ];\r
+Node.prototype.getChildAt = function( i ){\r
+ var xnodes = this._xnodeType === 1 && this._xnodes;\r
+ return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ];\r
};\r
\r
\r
* className, addClass, removeClass, hasClass\r
*/\r
Node.prototype.className = function( v ){\r
- var node;\r
+ var node, _, __;\r
// getter\r
if( v === undefined ) return this._className;\r
+ \r
// setter\r
if( this._className === v ) return this;\r
if( !v || typeof v !== 'string' ){\r
delete this._className;\r
} else {\r
- this._className = v; \r
+ // cleanup\r
+ _ = ' ';\r
+ __ = ' ';\r
+ while( v.indexOf( __ ) !== -1 ){ v = v.split( __ ).join( _ ); };\r
+ v.charAt( 0 ) === _ && ( v = v.substr( 1 ) );\r
+ v.lastIndexOf( _ ) === 0 && ( v = v.substr( 0, v.length - 1 ) );\r
+ \r
+ if( this._className === v ) return this;\r
+ v ? ( this._className = v ) : delete this._className;\r
};\r
this._dirty |= X.Dom.Dirty.CLASSNAME;\r
+ this._root && this._reserveUpdate();\r
return this;\r
};\r
Node.prototype.addClass = function( v ){\r
if( !name ) continue;\r
!this.hasClass( name ) && ( v += ( v ? ' ' : '' ) + name );\r
};\r
- return v ? his.className( this._className + ( this._className ? ' ' : '' ) + v ) : this;\r
+ return v ? this.className( this._className + ( this._className ? ' ' : '' ) + v ) : this;\r
};\r
Node.prototype.removeClass = function( v ){\r
var _ = ' ',\r
className = this._className,\r
names = v.split( ' ' ),\r
- classNames, i, f;\r
+ classNames, i, f, j;\r
if( !className ) return this;\r
for( classNames = className.split( _ ), i = classNames.length; i; ){\r
className = classNames[ --i ];\r
/* --------------------------------------\r
* html, text\r
*/\r
-Node.prototype.html = function( html, opt_wrap ){\r
- var xnodes, n, i, l;\r
+\r
+Node._outerFlag = null;\r
+\r
+Node.prototype.html = function( html ){\r
+ var _ = '', q = '"', xnodes, n, i, l;\r
// setter\r
- if( html ){\r
- if( this._xnodeType === 3 ){\r
- if( this._text !== html ){\r
- this._text = html;\r
- this.parent && this._reserveUpdate();\r
- this._dirty |= X.Dom.Dirty.CONTENT;\r
- };\r
- return this;\r
- };\r
- return this.empty().append.apply( this, X.Dom.parse( html, true ) );\r
+ if( X.Type.isString( html ) ){\r
+ if( this._xnodeType === 3 ) return this.text( html );\r
+ return html ? this.empty().append.apply( this, X.Dom.parse( html, true ) ) : this.empty();\r
};\r
+ \r
// getter\r
if( this._xnodeType === 3 ){\r
return this._text;\r
if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
delete this._cssText;\r
};\r
- html = !opt_wrap ? [] : [\r
+ html = !Node._outerFlag ? [] : [\r
'<', this._tag,\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._cssText ? ' style="' + this._cssText + '"' : '',\r
+ this._id ? ' id="' + this._id + q : _,\r
+ this._className ? ' class="' + this._className + q : _,\r
+ this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText,\r
+ this._cssText ? ' style="' + this._cssText + q : _,\r
'>' ];\r
\r
n = html.length;\r
if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
+ if( !Node._outerFlag ) Node._outerFlag = this;\r
for( i = 0; i < l; ++i ){\r
- html[ n ] = xnodes[ i ].html( undefined, true );\r
+ html[ n ] = xnodes[ i ].html();\r
++n;\r
};\r
+ if( Node._outerFlag === this ) Node._outerFlag = null;\r
};\r
- !opt_wrap || X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
-\r
- return html.join( '' );\r
+ !Node._outerFlag || X.Dom.DTD.EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
+ return html.join( _ );\r
};\r
\r
Node.prototype.text = function( text ){\r
- var xnodes, n, i;\r
+ var xnodes, texts, i, l;\r
// setter\r
- if( text ){\r
+ if( X.Type.isString( text ) ){\r
if( this._xnodeType === 3 ){\r
if( this._text !== text ){\r
- this._text = text;\r
- this.parent && this._reserveUpdate();\r
+ text ? ( this._text = text ) : delete this.text;\r
+ this._root && this._reserveUpdate();\r
this._dirty |= X.Dom.Dirty.CONTENT;\r
};\r
return this;\r
};\r
+ if( !text ) return this.empty();\r
this.empty().createText( text );\r
- return this; \r
+ return this;\r
};\r
// getter\r
if( this._xnodeType === 1 ){\r
- if( ( xnodes = this._xnodes ) && ( i = xnodes.length ) ){\r
- for( text = [], n = -1; i; ){\r
- text[ ++n ] = xnodes[ --i ].text();\r
+ if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
+ for( texts = [], i = 0; i < l; ++i ){\r
+ texts[ i ] = xnodes[ i ].text();\r
};\r
- return text.join( '' );\r
+ return texts.join( '' );\r
};\r
return '';\r
};\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
* root._reserveRemoval にいたら消す, new_parent._xnodes に挿入 steta は not_added にして commitUpdate を待つ\r
*/\r
\r
-Node.prototype._reserveUpdate = function( child ){\r
- var root = Node.root;\r
- //if( !root ) return;\r
- //child && ( child._dirty = true );\r
- if( root && !root._updateReserved ) root._updateReserved = X.Timer.requestFrame( root, root._startUpdate );\r
+Node.prototype._reserveUpdate = function(){\r
+ var root = Node._body;\r
+ if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( root, root._startUpdate );\r
};\r
\r
Node.prototype._startUpdate = function(){\r
var removal, i, xnode, tmp;\r
- \r
- if( this._updateReserved ){\r
- //X.Timer.cancelFrame( this._updateReserved );\r
- delete this._updateReserved;\r
+ if( X.Dom.readyState < X.Dom.Event.DOM_INIT ){\r
+ return;\r
+ };\r
+ if( this._updateTimerID ){\r
+ //X.Timer.cancelFrame( this._updateTimerID ); // fire 中の cancel が動かない、、、\r
+ this._updateTimerID = 0;\r
} else {\r
return;\r
};\r
+ // このイベントでサイズを取ると無限ループに\r
+ // X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.BEFORE_UPDATE ] && X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UPDATE } );\r
\r
removal = Node._reserveRemoval;\r
- i = removal.length;\r
\r
tmp = this._rawNode.style.visibility;\r
//this._rawNode.style.visibility = 'hidden';\r
- \r
- for( ; i; ){\r
- xnode = removal[ --i ];\r
- xnode._actualRemove();\r
- xnode._destroyed && xnode.kill();\r
+\r
+ //console.log( '_actualRemove().' );\r
+\r
+ if( i = removal.length ){\r
+ for( ; i; ){\r
+ xnode = removal[ --i ];\r
+ xnode._actualRemove();\r
+ !this._state && xnode.kill();\r
+ };\r
+ removal.length = 0;\r
};\r
- this._commitUpdate();\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
\r
Node.prototype._commitUpdate =\r
- document.getElementById ?\r
+ X.Dom.DOM_W3C ?\r
( function( parentElement, nextElement ){\r
var elm = this._rawNode,\r
- xnodes, l, i, next, k, v;\r
+ xnodes, l, i, frg, next, k, v;\r
\r
- if( !elm ){\r
+ if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
+ //alert( this._tag + ' ' + !!elm );\r
+ elm && elm.parentNode && this._actualRemove();\r
+ return nextElement;\r
+ };\r
+\r
+ if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){\r
nextElement ?\r
parentElement.insertBefore( this._actualCreate(), nextElement ) :\r
parentElement.appendChild( this._actualCreate() );\r
this._afterActualCreate();\r
- return this._rawNode;\r
- } else \r
- if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
- for( ; l; ){\r
- next = xnodes[ --l ]._commitUpdate( elm, next );\r
- };\r
- };\r
\r
- // textNode\r
- if( this._dirty & X.Dom.Dirty.CONTENT ) elm.data = X.Dom.chrReferanceTo( this._text );\r
- // className\r
- if( this._dirty & X.Dom.Dirty.CLASSNAME ) elm.className = this._className;\r
- // style\r
- if( this._dirty & X.Dom.Dirty.CSS ){\r
- if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
- elm.style.cssText = this._cssText;\r
- } else {\r
- elm.removeAttribute( 'style' );\r
- delete this._cssText;\r
- };\r
+ return elm || this._rawNode;\r
+ } else\r
+ if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) {\r
+ \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
+ elm.appendChild( frg );\r
+ for( i = 0; i < l; ++i ){\r
+ xnodes[ i ]._afterActualCreate( true );\r
+ };\r
+ } else {*/\r
+ for( ; l; ){\r
+ next = xnodes[ --l ]._commitUpdate( elm, next );\r
+ };\r
+ //};\r
};\r
- // attr\r
- if( this._newAttrs ){\r
- for( k in this._newAttrs ){\r
- ( v = this._newAttrs[ k ] ) === undefined ?\r
- elm.removeAttribute( k ) :\r
- ( elm[ k ] = v );\r
- };\r
- delete this._newAttrs;\r
+\r
+ delete this._fontSize;\r
+ this._dirty && this._updateRawNode( elm );\r
+ if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
+ return nextElement;\r
};\r
- \r
- delete this._dirty;\r
- \r
return elm;\r
}) :\r
- document.all ? \r
+ X.Dom.DOM_IE4 ? \r
( function( parentElement, prevElement ){\r
var elm = this._rawNode || this._ie4getRawNode(),\r
- xnodes = this._xnodes,\r
- l = xnodes && xnodes.length,\r
- i, html, elm, child, prev, k, v;\r
+ xnodes, l, i, html, text, prev;\r
\r
if( !elm ){\r
prevElement ?\r
- prevElement.insertAdjacentText( 'AfterEnd', this._actualCreate() ) :\r
- parentElement.insertAdjacentText( 'BeforeEnd', this._actualCreate() );\r
+ prevElement.insertAdjacentHTML( 'AfterEnd', this._actualCreate() ) :\r
+ parentElement.insertAdjacentHTML( 'AfterBegin', this._actualCreate() );\r
this._afterActualCreate();\r
return this._rawNode || this._ie4getRawNode();\r
- } else\r
- if( this._dirty | X.Dom.Dirty.IE4_TEXTNODE_FIX ){\r
+ };\r
+ \r
+ xnodes = this._xnodes;\r
+ l = xnodes ? xnodes.length : 0;\r
+ \r
+ if( this._dirty & X.Dom.Dirty.IE4_TEXTNODE_FIX || ( this._state & X.Dom.State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0\r
html = [];\r
for( i = 0; i < l; ++i ){\r
html[ i ] = xnodes[ i ]._actualCreate();\r
for( i = 0; i < l; ++i ){\r
xnodes[ i ]._afterActualCreate();\r
};\r
- } else \r
+ this._state &= ~X.Dom.State.IE4_ONLY_TEXT;\r
+ } else\r
+ if( this._state & X.Dom.State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う\r
+ text = xnodes[ 0 ];\r
+ if( text._dirty || !text._root ){\r
+ elm.innerHTML = text._text;\r
+ delete text._dirty;\r
+ text._root = this._root; \r
+ };\r
+ } else\r
if( l ){\r
for( i = 0; i < l; ++i ){\r
prev = xnodes[ i ]._commitUpdate( elm, prev );\r
};\r
};\r
+ \r
+ delete this._fontSize;\r
+ this._dirty && this._updateRawNode( elm );\r
+ return elm;\r
+ }) :\r
+ (function(){});\r
+\r
+Node.prototype._updateRawNode =\r
+ X.Dom.DOM_W3C ?\r
+ ( function( elm ){\r
+ var attrs, rename, k, v;\r
+\r
+ // textNode\r
+ if( this._dirty & X.Dom.Dirty.CONTENT ){\r
+ elm.data = X.Dom.chrReferanceTo( this._text );\r
+ delete this._dirty;\r
+ return;\r
+ };\r
+ // id\r
+ if( this._dirty & X.Dom.Dirty.ID ){\r
+ this._id ? ( elm.id = this._id ) : ( elm.id && elm.removeAttribute( 'id' ) ); \r
+ };\r
+ // className\r
+ if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
+ this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( X.UA.IE ? 'className' : '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
+ };\r
+ // style\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
+ elm.setAttribute( 'style', this._cssText ) : // opera8用\r
+ ( elm.style.cssText = this._cssText );\r
+ } else {\r
+ elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要\r
+ elm.removeAttribute( 'style' );\r
+ delete this._cssText;\r
+ };\r
+ };\r
+ \r
+ if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
+ elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
+ };\r
+ \r
+ // attr\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( !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
+ elm.appendChild( document.createTextNode( attrs[ k ] ) );\r
+ continue;\r
+ };\r
+ };\r
+ k = \r
+ ( v = attrs[ k ] ) === undefined ?\r
+ elm.removeAttribute( rename[ k ] || k ) :\r
+ ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v ); \r
+\r
+ };\r
+ delete this._newAttrs;\r
+ };\r
+ \r
+ delete this._dirty;\r
+ }) :\r
+ X.Dom.DOM_IE4 ? \r
+ ( function( elm ){\r
+ var attrs, rename, k, v;\r
\r
// fake textNode\r
- if( this._dirty & X.Dom.Dirty.CONTENT ) elm.innerHTML = this._text;\r
+ if( this._dirty & X.Dom.Dirty.CONTENT ){\r
+ elm.innerText = this._text;\r
+ delete this._dirty;\r
+ return;\r
+ };\r
+ \r
+ /*\r
+ * http://www.tohoho-web.com/js/element.htm\r
+ * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる\r
+ */ \r
+ // id\r
+ if( this._dirty & X.Dom.Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) );\r
+\r
// className\r
- if( this._dirty & X.Dom.Dirty.CLASSNAME ) elm.className = this._className;\r
+ if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
+ this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' );\r
+ };\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
elm.removeAttribute( 'style' );\r
delete this._cssText;\r
};\r
};\r
+ \r
+ if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
+ this._rawNode.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
+ };\r
+ \r
// attr\r
- if( this._newAttrs ){\r
- for( k in this._newAttrs ){\r
- ( v = this._newAttrs[ k ] ) === undefined ?\r
- elm.removeAttribute( k ) :\r
- elm.setAttribute( k, v );\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
+ ( v = attrs[ k ] ) === undefined ?\r
+ elm.removeAttribute( rename[ k ] || k ) :\r
+ elm.setAttribute( rename[ k ] || k, v ); // TODO X.Dom.Attr.noValue\r
};\r
delete this._newAttrs;\r
};\r
\r
delete this._dirty;\r
- \r
- return elm;\r
}) :\r
(function(){});\r
\r
* return document.createRange().createContextualFragment("<div><select><option></option></select></div>");\r
* insertAdjacentHTML\r
* \r
- * ie7 以下では iframe の frameborder や、input name は、createElement 後に aetAttribute しても無視される\r
+ * 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
* document.createElement of ie4 is only for OPTION & IMAGE.\r
*/\r
Node.prototype._actualCreate =\r
- document.getElementById ? (function( isChild ){\r
+ X.Dom.DOM_W3C ? (function( isChild ){\r
var elm = this._rawNode,\r
xnodes, frg, i, l;\r
\r
if( this._xnodeType === 3 ){\r
- return elm || ( this._rawNode = document.createTextNode( X.Dom.chrReferanceTo( this._text ) ) );\r
+ if( elm ) return elm;\r
+ delete this._dirty;\r
+ return this._rawNode = document.createTextNode( X.Dom.chrReferanceTo( this._text ) );\r
};\r
\r
if( !elm ){\r
};\r
this._isNew = true;\r
this._rawNode = elm =\r
- X.UA.IE ?\r
+ X.Dom._strictElmCreation ?\r
document.createElement( [\r
'<', this._tag,\r
' 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
+ '>' ].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
\r
return elm;\r
}) :\r
- document.all ? (function(){\r
+ X.Dom.DOM_IE4 ? (function( isChild ){\r
var uid = this._uid,\r
html, xnodes, n, i, l;\r
\r
if( this._xnodeType === 3 ){\r
- html = [ '<font id=ie4uid', uid, ' UID=', uid, '>', this._text, '</font>' ];// fake textNode\r
+ html = [ '<FONT id=ie4uid', uid, ' UID="', uid, '">', this._text, '</FONT>' ];// fake textNode\r
+ delete this._rawNode;\r
} else {\r
+ if( this._rawNode && !isChild ) this._actualRemove( true );\r
+ \r
if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
delete this._cssText;\r
};\r
+ \r
html = [\r
- '<', this._tag, ' id=', ( this._id || ( 'ie4uid' + uid ) ), ' UID=', uid,\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
n = html.length;\r
if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
- for( i = 0; i < l; ++i ){\r
- html[ n ] = xnodes[ i ]._actualCreate();\r
+ if( l === 1 && xnodes[ 0 ]._xnodeType === 3 ){\r
+ // only textnode\r
+ html[ n ] = xnodes[ 0 ]._text;\r
++n;\r
+ this._state |= X.Dom.State.IE4_ONLY_TEXT;\r
+ } else {\r
+ for( i = 0; i < l; ++i ){\r
+ html[ n ] = xnodes[ i ]._actualCreate( true );\r
+ ++n;\r
+ }; \r
};\r
};\r
- X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
+ X.Dom.DTD.EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
\r
delete this._newAttrs;\r
};\r
- delete this._dirty;\r
- delete this._rawNode;\r
\r
return html.join( '' );\r
}) :\r
(function(){});\r
\r
Node.prototype._afterActualCreate =\r
- document.getElementById ? (function(){\r
- var xnodes, l, elm, attrs, k, i;\r
+ X.Dom.DOM_W3C ? (function(){\r
+ var elm = this._rawNode, xnodes, l, attrs, k, i;\r
+\r
+ this._root = this.parent._root;\r
\r
- this.state = Node.STATE_STAGED;\r
- delete this._dirty;\r
if( this._xnodeType === 3 ){\r
- //elm.UID = this._uid;\r
+ this._dirty && this._updateRawNode( elm );\r
return this;\r
};\r
- delete this._newAttrs;\r
\r
xnodes = this._xnodes;\r
l = xnodes && xnodes.length;\r
- elm = this._rawNode;\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 ){\r
+ if( !X.Dom._strictElmCreation ){\r
elm.UID = this._uid;\r
- if( this._id ) elm.id = this._id;\r
- if( this._className ) elm.className = this._className;\r
- if( attrs = this._attrs ){\r
- for( k in attrs ){\r
- elm[ k ] = attrs[ k ];\r
- };\r
- };\r
- elm.style.cssText = this._cssText;\r
+ this._newAttrs = this._attrs;\r
+ this._dirty = X.Dom.Dirty.ID | X.Dom.Dirty.CLASSNAME | X.Dom.Dirty.CSS | X.Dom.Dirty.ATTR | X.Dom.Dirty.IE_FILTER;\r
+ this._updateRawNode( elm );\r
+ } else\r
+ if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
+ elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
+ delete this._dirty;\r
};\r
- this._restoreEvent();// イベントの復帰\r
+ \r
delete this._isNew;\r
+ } else {\r
+ this._dirty && this._updateRawNode( elm );\r
};\r
+ \r
if( l ){\r
for( i = 0; i < l; ++i ){\r
xnodes[ i ]._afterActualCreate();\r
};\r
};\r
- return this;\r
+ // src の onload があるので先ではないか?\r
+ // ie の str から要素を作る場合、srcだけ イベント設定後ではないか?\r
+ this._restoreEvent();// イベントの復帰\r
}) :\r
- document.all ? (function(){\r
+ X.Dom.DOM_IE4 ? (function(){\r
var xnodes, i;\r
- this.state = Node.STATE_STAGED;\r
+ this._root = this.parent._root;\r
\r
if( this._xnodeType !== 1 ) return this;\r
\r
xnodes[ --i ]._afterActualCreate();\r
};\r
};\r
- return this._restoreEvent();// イベントの復帰\r
+ // textarea への value の適用はここで\r
+ if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
+ this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
+ };\r
+ delete this._dirty;\r
+ this._restoreEvent();// イベントの復帰\r
}) :\r
(function(){});\r
- \r
+\r
Node.prototype._actualRemove =\r
- document.getElementById ?\r
+ X.Dom.DOM_W3C ?\r
( function( isChild ){\r
var xnodes = this._xnodes,\r
elm = this._rawNode,\r
child._xnodeType === 1 && child._actualRemove( true );\r
};\r
};\r
+\r
if( !elm ) return;\r
this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
- // elm.parentNode.tagName check tagName is for ie7\r
- !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
+ // elm.parentNode.tagName for ie7\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
- document.all ? \r
+ X.Dom.DOM_IE4 ?\r
( function( isChild ){\r
var xnodes = this._xnodes,\r
elm = this._rawNode || this._ie4getRawNode(),\r
xnodes[ i ]._actualRemove( true );\r
};\r
};\r
+\r
if( !elm ) return;\r
this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
- delete this._rawNode;\r
- elm.removeAttribute( 'id', '' );\r
- document.all[ 'ie4uid' + this._uid ] = null;\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
if( !isChild ) elm.outerHTML = '';\r
+ delete this._rawNode;\r
}) :\r
(function(){});\r
- \r
- \r
-//})( window, document );\r
\r
+console.log( 'X.Dom.Node' );\r
\r