OSDN Git Service

Version 0.6.26, bugfix & BASE_FONT_RESIZED event added.
[pettanr/clientJs.git] / 0.6.x / js / dom / 11_XDomNode.js
1 \r
2 X.Dom.Dirty = {\r
3         CLEAN            :  0,\r
4         ID               :  1, // width, height, x, y\r
5         CONTENT          :  2,  // width, height, x, y textNode の内容\r
6         CLASSNAME        :  4, // _getCharSize, width, height, x, y\r
7         CSS              :  8, // _getCharSize, width, height, x, y\r
8         ATTR             : 16,  // _getCharSize, width, height, x, y\r
9         IE_FILTER        : X.UA.IE && X.UA.IE < 9 ? 32 : 0,\r
10         IE4_TEXTNODE_FIX : 64\r
11 };\r
12 \r
13 /*\r
14  * \r
15  *\r
16  * destroyed\r
17  * display:none\r
18  * display:block\r
19  * display:inline\r
20  * \r
21  */\r
22 \r
23 X.Dom.State = {\r
24         DESTROYED          : 0,\r
25         DISPLAY_NONE       : 1,\r
26         DISPLAY_BLOCK      : 2,\r
27         DISPLAY_INLINE     : 4,\r
28         POSITION_ABSOLUTE  : 2,\r
29         OVERFLOW_HIDDEN    : 4,\r
30         HAS_WIDTH_LENGTH   : 8,\r
31         HAS_WIDTH_PERCENT  : 16,\r
32         HAS_HEIGHT_LENGTH  : 16,\r
33         HAS_HEIGHT_PERCENT : 32,\r
34         IE4_ONLY_TEXT      : 64\r
35 };\r
36 \r
37 /*\r
38  * Node( rawElement | rawTextnode | htmlString | textString )\r
39  */\r
40 //;(function( window, document, undeifned ){\r
41 X.Dom.Node = X.EventDispatcher.inherits(\r
42         'XDomNode',\r
43         X.Class.POOL_OBJECT,\r
44         {\r
45                 _uid       : 0,\r
46                 _state     : 0,\r
47                 _dirty     : 0,\r
48                 \r
49                 _rawNode   : null,\r
50                 _root      : null, // xnode が文書ツリーに属しているか?はこれを見る\r
51                 parent     : null, // remove された枝も親子構造は維持している。\r
52                 _xnodes    : null,\r
53         \r
54                 _xnodeType : 0,\r
55                 _tag       : null,\r
56                 _text      : null,\r
57                 _id        : null,\r
58                 _className : '',\r
59 \r
60                 _attrs     : null, // X.Dom.Attr\r
61                 _newAttrs  : null,\r
62                 _attrText  : '',\r
63                 \r
64                 _css       : null, // X.Dom.Style\r
65                 _cssText   : null,\r
66                 \r
67                 _anime     : null,\r
68                 \r
69                 Constructor : function( v ){\r
70                         var css, xnodes, xnode, parent, uid = Node._chashe.length;\r
71                         \r
72                         if( Node._newByTag ){\r
73                                 Node._newByTag  = false;\r
74                                 this._tag       = v;\r
75                                 this._xnodeType = 1;\r
76                                 this._state     = X.Dom.State.DISPLAY_INLINE; // todo\r
77                                 arguments[ 1 ] && this.attr( arguments[ 1 ] );\r
78                                 css = arguments[ 2 ];\r
79                                 css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css );\r
80                         } else\r
81                         if( Node._newByText ){\r
82                                 Node._newByText = false;\r
83                                 this._text      = v;\r
84                                 this._xnodeType = 3;\r
85                                 this._state     = X.Dom.State.DISPLAY_INLINE;\r
86                         } else {\r
87                                 if( 1 < arguments.length ) return new X.Dom.NodeList( arguments );\r
88                                 if( X.Type.isArray( v ) && v.length ) return new X.Dom.NodeList( v );\r
89                                 if( !this || this.append !== Node.prototype.append ) return new Node( v );\r
90                 \r
91                                 switch( Node._getType( v ) ){\r
92                                         case Node.IS_XNODE :\r
93                                         case Node.IS_XNODE_LIST :\r
94                                                 return v;\r
95                                         case Node.IS_RAW_HTML :\r
96                                                 if( xnode = Node._getXNode( v ) ) return xnode;\r
97                                                 // v.parentNode || v.parentElement : dom1 || dom0\r
98                                                 this.parent     = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && Node._getXNode( parent );\r
99                                                 this._root      = this.parent ? this.parent._root : null;\r
100                                                 this._rawNode   = v;\r
101                                                 this._xnodeType = 1;\r
102                                                 this._state     = X.Dom.State.DISPLAY_BLOCK; // todo\r
103                                                 this._tag       = v.tagName;\r
104                                                 this._id        = v.id;\r
105                                                 this._className = v.className;\r
106                                                 this.cssText( v.style.cssText );\r
107                                                 // X.Dom.Dirty.CSS を落とす\r
108                                                 this._dirty = 0;\r
109                                                 // attr の回収は不可能、、、\r
110                                                 if( X.UA.IE && X.UA.IE < 5 ){\r
111                                                         v.setAttribute( 'UID', '' + uid );\r
112                                                 } else {\r
113                                                         v.UID = uid;\r
114                                                 };\r
115                                                 // childNodes...\r
116                                                 break;\r
117                                         case Node.IS_RAW_TEXT :\r
118                                                 if( xnode = Node._getXNode( v ) ) return xnode;\r
119                                                 this.parent     = Node._getXNode( v.parentNode );\r
120                                                 this._root      = this.parent ? this.parent._root : null;\r
121                                                 this._rawNode   = v;\r
122                                                 this._xnodeType = 3;\r
123                                                 this._state     = X.Dom.State.DISPLAY_INLINE;\r
124                                                 this._text      = v.data;\r
125                                                 v.UID = uid;\r
126                                                 break;\r
127                                         case Node.IS_HTML_STRING :\r
128                                         case Node.IS_STRING :\r
129                                                 if( xnodes = X.Dom.parse( v, true ) && 1 < xnodes.length ) return new X.Dom.NodeList( xnodes );\r
130                                                 if( xnodes.length ) return xnodes[ 0 ];\r
131                                                 return Node.none;\r
132                                         case Node.IS_IMAGE :\r
133                                                 v.UID = uid;\r
134                                         case Node.IS_WINDOW :\r
135                                         case Node.IS_DOCUMENT :\r
136                                                 this._rawNode   = v;\r
137                                                 this._xnodeType = 2;\r
138                                                 this._state     = X.Dom.State.DISPLAY_BLOCK;\r
139                                                 break;\r
140                                         default :\r
141                                                 if( Node.none ) return Node.none;\r
142                                                 return;\r
143                                 };\r
144                         };\r
145                         \r
146                         Node._chashe[ this._uid = uid ] = this;\r
147                 }\r
148         }\r
149 );\r
150 \r
151 var Node = X.Dom.Node;\r
152 \r
153 Node.IS_XNODE       = 1;\r
154 Node.IS_RAW_HTML    = 2;\r
155 Node.IS_RAW_TEXT    = 3;\r
156 Node.IS_HTML_STRING = 4;\r
157 Node.IS_STRING      = 5;\r
158 //Node.IS_DOC_FRAG    = 6;\r
159 Node.IS_XNODE_LIST  = 7;\r
160 Node.IS_WINDOW      = 8;\r
161 Node.IS_DOCUMENT    = 9;\r
162 Node.IS_IMAGE       = 10;\r
163 \r
164 Node._useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 6 <= X.UA.IE ) && document.createDocumentFragment();\r
165 \r
166 Node._getType = function( v ){\r
167         if( v === '' ) return Node.IS_STRING;\r
168         if( !v ) return 0;\r
169         if( v === window ) return Node.IS_WINDOW;\r
170         if( v === document ) return Node.IS_DOCUMENT;\r
171         if( v.constructor === window.Image ) return Node.IS_IMAGE;\r
172         if( v.constructor === Node ) return Node.IS_XNODE;\r
173         if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST;\r
174         if( v.tagName ) return Node.IS_RAW_HTML;\r
175         if( v.nodeType === 3 ) return Node.IS_RAW_TEXT;\r
176         if( typeof v === 'string' ){\r
177                 return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING;\r
178         };\r
179         //if( v.nodeType === 11 ) return Node.IS_DOC_FRAG;\r
180         return 0;\r
181 };\r
182 Node._getXNode = function( v ){\r
183         var uid, i, chashe, xnode;\r
184         switch( Node._getType( v ) ){\r
185                 case Node.IS_XNODE :\r
186                 case Node.IS_XNODE_LIST :\r
187                         return v;\r
188                 case Node.IS_RAW_HTML :\r
189                 case Node.IS_IMAGE :\r
190                         // fake TextNode too.\r
191                         if( X.UA.IE && X.UA.IE < 5 ){\r
192                                 uid = v.getAttribute( 'UID' );\r
193                                 return uid && Node._chashe[ uid ];\r
194                         };\r
195                         return v.UID && Node._chashe[ v.UID ];\r
196                 case Node.IS_WINDOW :\r
197                         return Node._window;\r
198                 case Node.IS_DOCUMENT :\r
199                         return Node._document;\r
200                 case Node.IS_RAW_TEXT :\r
201                         for( chashe = Node._chashe, i = chashe.length; i; ){\r
202                                 if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawNode === v ) ) return xnode;\r
203                         };\r
204         };\r
205 };\r
206 \r
207 \r
208 Node.create = function( tag, opt_attrs, opt_css ){\r
209         switch( Node._getType( tag ) ){\r
210                 case Node.IS_STRING :\r
211                         Node._newByTag = true;\r
212                         return new Node( tag, opt_attrs, opt_css );\r
213                 case Node.IS_HTML_STRING :\r
214                         return X.Dom.parse( tag, true )[ 0 ];\r
215         };\r
216 };\r
217 Node.createText = function( text ){\r
218         Node._newByText = true;\r
219         return new Node( text );\r
220 };\r
221 \r
222 \r
223 Node.getRoot = function( xnode ){\r
224         return Node._document;\r
225         //return xnode.root._rawNode.documentElement ? node : node.ownerDocument || node.document;\r
226 };\r
227         // XMLかどうかを判別する\r
228 Node.isXmlDocument =\r
229         X.UA.IE && X.UA.IE < 5 ?\r
230                 X.emptyFunction :\r
231                 (function( root ){\r
232                         return root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName;\r
233                 });\r
234 \r
235 Node._chashe     = [];\r
236 Node.none        = Node._chashe[ 0 ] = new Node();\r
237 Node._window     = new Node( window ); // Node._chashe[ 1 ]\r
238 Node._document   = new Node( document ); // Node._chashe[ 2 ]\r
239 Node._html       = null; // Node._chashe[ 3 ]\r
240 Node.root        = null;// = Node._chashe[ 4 ] body\r
241 Node._systemNode = null;// = Node._chashe[ ? ]\r
242 \r
243 Node._reserveRemoval = [];\r
244 \r
245 if( !document.getElementById && document.all ){\r
246         Node.prototype._ie4getRawNode = function(){\r
247                 var elm = this._rawNode;\r
248                 return elm ||\r
249                         ( ( elm = document.all[ 'ie4uid' + this._uid ] ) && ( this._rawNode = elm ) ) ||\r
250                         ( this._id && ( elm = document.all[ this._id ] ) ) && ( this._rawNode = elm );\r
251         };\r
252 };\r
253 \r
254 \r
255 /* --------------------------------------\r
256  *  Create\r
257  */\r
258 Node.prototype.create = function( tag, opt_attrs, opt_css ){\r
259         var xnode;\r
260         if( this._xnodeType !== 1 ) return;\r
261         if( !this._xnodes ) this._xnodes = [];\r
262         \r
263         xnode = Node.create( tag, opt_attrs, opt_css );\r
264         \r
265         xnode.parent = this;\r
266         this._xnodes[ this._xnodes.length ] = xnode;\r
267         this._root && this._reserveUpdate();\r
268         return xnode;\r
269 };\r
270 \r
271 /* --------------------------------------\r
272  *  CreateText\r
273  */\r
274 Node.prototype.createText = function( text ){\r
275         var xnode;\r
276         if( this._xnodeType !== 1 ) return;\r
277         if( !this._xnodes ) this._xnodes = [];\r
278         \r
279         Node._newByText = true;\r
280         xnode = new Node( text );\r
281         xnode.parent = this;\r
282         \r
283         this._root && this._reserveUpdate();\r
284         this._xnodes[ this._xnodes.length ] = xnode;\r
285         return xnode;\r
286 };\r
287 \r
288 /* --------------------------------------\r
289  *  Clone\r
290  * http://d.hatena.ne.jp/think49/20110724/1311472811\r
291  * http://d.hatena.ne.jp/uupaa/20100508/1273299874\r
292  */\r
293 Node.prototype.clone = function( opt_clone_children ){\r
294         var xnode, xnodes, i, l;\r
295         switch( this._xnodeType ){\r
296                 case 1 :\r
297                         Node._newByTag = true;\r
298                         xnode = new Node( this._tag, X.cloneObject( this._attrs ), X.cloneObject( this._css ) )\r
299                                 .attr( { 'id' : this._id } )\r
300                                 .className( this._className );\r
301                         if( opt_clone_children && ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
302                                 for( i = 0; i < l; ++i ){\r
303                                         xnode.append( xnodes[ i ].clone( true ) );\r
304                                 };\r
305                         };\r
306                         return xnode;\r
307                 case 3 :\r
308                         Node._newByText = true;\r
309                         xnode = new Node( this._text );\r
310                         return xnode;\r
311                 \r
312                 //case 0 :\r
313                 //case 2 :\r
314         };\r
315         return this;\r
316 };\r
317 \r
318 /* --------------------------------------\r
319  *  Add\r
320  * Node\r
321  * HtmlElement の場合は内部使用専用 そのため event の破棄等しない\r
322  */\r
323 Node.prototype.append = function( v ){\r
324         var i, l, xnodes, frg;\r
325         if( this._xnodeType !== 1 ) return;\r
326         \r
327         if( 1 < ( l = arguments.length ) ){\r
328                 for( i = 0; i < l; ++i ){\r
329                         this.append( arguments[ i ] );\r
330                 };\r
331                 return this;\r
332         };\r
333         \r
334         if( !( xnodes = this._xnodes ) ) this._xnodes = xnodes = [];\r
335         \r
336         switch( Node._getType( v ) ){\r
337                 case Node.IS_RAW_HTML :\r
338                 case Node.IS_RAW_TEXT :\r
339                         v = new Node( v );\r
340                         break;\r
341                 case Node.IS_HTML_STRING :\r
342                 case Node.IS_STRING :\r
343                         return this.append.apply( this, X.Dom.parse( v, true ) );\r
344                 case Node.IS_XNODE :\r
345                         if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
346                         // 親の xnodes から v を消す\r
347                         if( v.parent ){\r
348                                 //if( document.getElementById ){\r
349                                 //      v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
350                                 //} else\r
351                                 //if( document.all ){\r
352                                         v.remove();\r
353                                 //} else {\r
354                                         \r
355                                 //};\r
356                         } else\r
357                         if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
358                                 if( !this._state ) alert( 'xnode already destroyed!' );\r
359                                 Node._reserveRemoval.splice( i, 1 );\r
360                         };\r
361                         break;\r
362                 default :\r
363                         return this;\r
364         };\r
365 \r
366         v.parent = this;\r
367         xnodes[ xnodes.length ] = v;\r
368         this._root && this._reserveUpdate();\r
369         return this;\r
370 };\r
371 \r
372 \r
373 Node.prototype.appendAt = function( start, v ){\r
374         var xnodes, l, i;\r
375         \r
376         if( this._xnodeType !== 1 ) return this;\r
377         \r
378         l = arguments.length;\r
379         if( !( xnodes = this._xnodes ) ) xnodes = this._xnodes = [];\r
380         \r
381         if( xnodes.length <= start ){\r
382                 if( l === 2 ) return this.append( v );\r
383                 for( i = 1; i < l; ++i ){\r
384                         this.append( arguments[ i ] );\r
385                 };\r
386                 return this;\r
387         };\r
388         if( start < 0 ) start = 0;\r
389         if( 2 < l ){\r
390                 for( ; l; ){\r
391                         this.appendAt( start, arguments[ --l ] );\r
392                 };\r
393                 return this;\r
394         };\r
395 \r
396         switch( Node._getType( v ) ){\r
397                 case Node.IS_RAW_HTML :\r
398                 case Node.IS_RAW_TEXT :\r
399                         v = new Node( v );\r
400                         break;\r
401                 case Node.IS_HTML_STRING :\r
402                 case Node.IS_STRING :\r
403                         v = X.Dom.parse( v, true );\r
404                         for( i = v.length; i; ){\r
405                                 this.appendAt( start, v[ --i ] );\r
406                         };\r
407                         return this;\r
408                 case Node.IS_XNODE :\r
409                         if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;\r
410                         // 親の xnodes から v を消す\r
411                         if( v.parent ){\r
412                                 //if( document.getElementById ){\r
413                                 //      v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );\r
414                                 //} else\r
415                                 //if( document.all ){\r
416                                         v.remove();\r
417                                 //} else {\r
418                                         \r
419                                 //};\r
420                         } else\r
421                         if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){\r
422                                 if( !this._state ) alert( 'xnode already destroyed!' );\r
423                                 Node._reserveRemoval.splice( i, 1 );\r
424                         };\r
425                         break;\r
426                 default :\r
427                         return this;\r
428         };\r
429 \r
430         v.parent = this;\r
431         this._xnodes.splice( start, 0, v );\r
432         this._root && this._reserveUpdate();\r
433         return this;\r
434 };\r
435 \r
436 Node.prototype.appendTo = function( parent, opt_index ){\r
437         switch( Node._getType( parent ) ){\r
438                 case Node.IS_RAW_HTML :\r
439                         parent = new Node( parent );\r
440                         break;\r
441                 case Node.IS_HTML_STRING :\r
442                         parent = X.Dom.parse( parent, true );\r
443                         parent = parent[ 0 ] || parent;\r
444                 case Node.IS_XNODE :\r
445                         break;\r
446                 default :\r
447                         return this;\r
448         };\r
449         opt_index === undefined ? parent.append( this ) : parent.appendAt( opt_index, this );\r
450         return this;\r
451 };\r
452 \r
453 Node.prototype.appendToRoot = function( opt_index ){\r
454         opt_index === undefined ? Node.root.append( this ) : Node.root.appendAt( opt_index, this );\r
455         return this;\r
456 };\r
457 \r
458 /* --------------------------------------\r
459  *  Before , After, Replace\r
460  */\r
461 Node.prototype.before = function( v ){\r
462         var parent, l, start;\r
463         if( !( parent = this.parent ) ) return this;\r
464         \r
465         l = arguments.length;\r
466         start = this.getOrder();\r
467         if( 1 < l ){\r
468                 for( ; l; ){\r
469                         parent.appendAt( start, arguments[ --l ] );\r
470                 };\r
471                 return this;\r
472         };\r
473         parent.appendAt( start, v );\r
474         return this;\r
475 };\r
476 \r
477 Node.prototype.after = function( v ){\r
478         var parent, l, i, start;\r
479         if( !( parent = this.parent ) ) return this;\r
480         \r
481         l = arguments.length;\r
482         start = this.getOrder() + 1;\r
483         if( parent._xnodes.length <= start ){\r
484                 if( 1 < l ){\r
485                         for( i = 0; i < l; ++i ){\r
486                                 parent.append( arguments[ i ] );\r
487                         };\r
488                         return this;\r
489                 };\r
490                 parent.append( v );\r
491                 return this;\r
492         };\r
493         if( 1 < l ){\r
494                 for( ; l; ){\r
495                         parent.appendAt( start, arguments[ --l ] );\r
496                 };\r
497                 return this;\r
498         };\r
499         parent.appendAt( start, v );\r
500         return this;\r
501 };\r
502 \r
503 Node.prototype.replace = function( v ){\r
504         if( !this.parent ) return this;\r
505         return arguments.length === 1 ? this.before( v ).remove() : this.before.apply( this, arguments ).remove();\r
506 };\r
507 \r
508 /* --------------------------------------\r
509  *  Remove\r
510  */\r
511 Node.prototype.remove = function(){\r
512         var parent = this.parent;\r
513         \r
514         if( !parent ) return this;\r
515 \r
516         parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 );\r
517         if( this._root ){\r
518                 Node._reserveRemoval[ Node._reserveRemoval.length ] = this;\r
519                 this._reserveUpdate();\r
520         };\r
521         delete this.parent;\r
522         delete this._root;\r
523         return this;\r
524 };\r
525 \r
526 Node.prototype.empty = function(){\r
527         var xnodes = this._xnodes, child, i, l;\r
528         if( xnodes && ( l = xnodes.length ) ){\r
529                 for( i = 0; i < l; ++i ){\r
530                         xnodes[ i ].destroy();\r
531                 };\r
532                 xnodes.length = 0;\r
533         };\r
534         return this;\r
535 };\r
536 \r
537 /* --------------------------------------\r
538  *  destory\r
539  */\r
540 Node.prototype.destroy = function( isChild ){\r
541         var xnodes = this._xnodes, i, elm;\r
542         \r
543         if( !this._state ) return;\r
544         \r
545         elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode();\r
546         \r
547         if( xnodes && ( i = xnodes.length ) ){\r
548                 //for( ; i; ){\r
549                 //      xnodes[ --i ].destroy( true );\r
550                 //};\r
551                 //xnodes.length = 0;\r
552         };\r
553         elm && this.unlisten(); // イベントの退避\r
554 \r
555         delete Node._chashe[ this._uid ];\r
556         delete this._state;\r
557         \r
558         if( this._root ){\r
559                 this.remove( isChild );\r
560         } else {\r
561                 this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 );\r
562                 elm && !isChild && this._actualRemove();\r
563                 this.kill();\r
564         };\r
565 };\r
566 \r
567 \r
568 \r
569 /* --------------------------------------\r
570  *  contains\r
571  */\r
572 Node.prototype.contains = function( v ){\r
573         var elm, type, xnodes, i;\r
574         if( !v || this._xnodeType !== 1 ) return false;\r
575         // contains ie4+\r
576         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
577                 return elm.contains( v );       \r
578         };\r
579         //if( document.compareDocumentPosition ){\r
580         //      \r
581         //};\r
582         xnodes = this._xnodes;\r
583         if( xnodes.indexOf( v ) !== -1 ) return true;\r
584         if( elm === v.parentNode ) return false;\r
585         for( i = xnodes.length; i; ){\r
586                 if( xnodes[ --i ].contains( v ) ) return true;\r
587         };\r
588         return false;\r
589 };\r
590 \r
591 /* --------------------------------------\r
592  *  getChild\r
593  */\r
594 Node.prototype.getChildAt = function( i ){\r
595         var xnodes = this._xnodeType === 1 && this._xnodes;\r
596         return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ];\r
597 };\r
598 \r
599 \r
600 /* --------------------------------------\r
601  *  prevNode, nextNode, firstChild, lastChild\r
602  */\r
603 \r
604 Node.prototype.prevNode = function(){\r
605         var parent = this.parent, xnodes, index;\r
606         if( !parent ) return;\r
607         xnodes = parent._xnodes;\r
608         index = xnodes.indexOf( this );\r
609         if( 0 < index ) return xnodes[ index - 1 ];\r
610 };\r
611 Node.prototype.nextNode = function(){\r
612         var parent = this.parent, xnodes, index;\r
613         if( !parent ) return;\r
614         xnodes = parent._xnodes;\r
615         index  = xnodes.indexOf( this );\r
616         if( index + 1 < xnodes.length ) return xnodes[ index + 1 ];\r
617 };\r
618 Node.prototype.firstChild = function(){\r
619         return this.getChildAt( 0 );\r
620 };\r
621 Node.prototype.lastChild = function(){\r
622         return this.getChildAt( this._xnodes.length - 1 );\r
623 };\r
624 \r
625 /* --------------------------------------\r
626  *  getOrder\r
627  */\r
628 Node.prototype.getOrder = function(){\r
629         var parent = this.parent;\r
630         if( !parent ) return -1;\r
631         return parent._xnodes.indexOf( this );\r
632 };\r
633 \r
634 /* --------------------------------------\r
635  *  className, addClass, removeClass, hasClass\r
636  */\r
637 Node.prototype.className = function( v ){\r
638         var node;\r
639         // getter\r
640         if( v === undefined ) return this._className;\r
641         // setter\r
642         if( this._className === v ) return this;\r
643         if( !v || typeof v !== 'string' ){\r
644                 delete this._className;\r
645         } else {\r
646                 this._className = v;    \r
647         };\r
648         this._dirty |= X.Dom.Dirty.CLASSNAME;\r
649         this._root && this._reserveUpdate();\r
650         return this;\r
651 };\r
652 Node.prototype.addClass = function( v ){\r
653         var names = v.split( ' ' ),\r
654                 i     = names.length,\r
655                 name;\r
656         v = '';\r
657         for( ; i; ){\r
658                 name = names[ --i ];\r
659                 if( !name ) continue;\r
660                 !this.hasClass( name ) && ( v += ( v ? ' ' : '' ) + name );\r
661         };\r
662         return v ? his.className( this._className + ( this._className ? ' ' : '' ) + v ) : this;\r
663 };\r
664 Node.prototype.removeClass = function( v ){\r
665         var _          = ' ',\r
666                 className  = this._className,\r
667                 names      = v.split( ' ' ),\r
668                 classNames, i, f, j;\r
669         if( !className ) return this;\r
670         for( classNames = className.split( _ ), i = classNames.length; i; ){\r
671                 className = classNames[ --i ];\r
672                 for( j = names.length; j; ){\r
673                         if( className === names[ --j ] ){\r
674                                 classNames.splice( i, 1 );\r
675                                 names.splice( j, 1 );\r
676                                 f = true;\r
677                                 break;\r
678                         };\r
679                 };\r
680         };\r
681         return f ? this.className( classNames.join( ' ' ) ) : this;\r
682 };\r
683 Node.prototype.toggleClass = function( v ){\r
684 \r
685 };\r
686 Node.prototype.hasClass = function( v ){\r
687         var _ = ' ',\r
688                 className = this._className,\r
689                 i, name;\r
690         if( className === v ) return true;\r
691         if( !className ) return false;\r
692         \r
693         className = _ + className + _;\r
694         if( className.indexOf( _ + v + _ ) !== -1 ) return true; // lucky hit\r
695         \r
696         for( v = v.split( _ ), i = v.length; i; ){\r
697                 name = v[ --i ];\r
698                 if( name === '' ) continue;\r
699                 if( className.indexOf( _ + name + _ ) === -1 ) return false;\r
700         };\r
701         return true;\r
702 };\r
703 \r
704 /* --------------------------------------\r
705  *  html, text\r
706  */\r
707 Node.prototype.html = function( html, opt_outer ){\r
708         var _ = '', xnodes, n, i, l;\r
709         // setter\r
710         if( html ){\r
711                 if( this._xnodeType === 3 ){\r
712                         if( this._text !== html ){\r
713                                 this._text = html;\r
714                                 this._root && this._reserveUpdate();\r
715                                 this._dirty |= X.Dom.Dirty.CONTENT;\r
716                         };\r
717                         return this;\r
718                 };\r
719                 return this.empty().append.apply( this, X.Dom.parse( html, true ) );\r
720         };\r
721         // getter\r
722         if( this._xnodeType === 3 ){\r
723                 return this._text;\r
724         };\r
725         \r
726         if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
727                 delete this._cssText;\r
728         };\r
729         html = !opt_outer ? [] : [\r
730                 '<', this._tag,\r
731                 this._id ? ' id=' + this._id : _,\r
732                 this._className ? ' class="' + this._className + '"' : _,\r
733                 this._attrText === _ ? _ : this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
734                 this._cssText ? ' style="' + this._cssText + '"' : _,\r
735         '>' ];\r
736         \r
737         n = html.length;\r
738         if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
739                 for( i = 0; i < l; ++i ){\r
740                         html[ n ] = xnodes[ i ].html( undefined, true );\r
741                         ++n;\r
742                 };\r
743         };\r
744         !opt_outer || X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
745 \r
746         return html.join( _ );\r
747 };\r
748 \r
749 Node.prototype.text = function( text ){\r
750         var xnodes, n, i;\r
751         // setter\r
752         if( text ){\r
753                 if( this._xnodeType === 3 ){\r
754                         if( this._text !== text ){\r
755                                 this._text = text;\r
756                                 this._root && this._reserveUpdate();\r
757                                 this._dirty |= X.Dom.Dirty.CONTENT;\r
758                         };\r
759                         return this;\r
760                 };\r
761                 this.empty().createText( text );\r
762                 return this;    \r
763         };\r
764         // getter\r
765         if( this._xnodeType === 1 ){\r
766                 if( ( xnodes = this._xnodes ) && ( i = xnodes.length ) ){\r
767                         for( text = [], n = -1; i; ){\r
768                                 text[ ++n ] = xnodes[ --i ].text();\r
769                         };\r
770                         return text.join( '' );\r
771                 };\r
772                 return '';\r
773         };\r
774         return this._text;\r
775 };\r
776 \r
777 Node.prototype.each = function( func ){\r
778         func.call( this, 0 );\r
779         return this;\r
780 };\r
781 \r
782 \r
783 /* --------------------------------------\r
784  *  Async commit update\r
785  * \r
786  * state:\r
787  *  0 : no_rawnode\r
788  *  1 : not_added\r
789  *  3 : dirty\r
790  *  4 : clean\r
791  * \r
792  * remove :\r
793  * root._reserveRemoval = [] に追加。commitUpdate で remove して state は not_added\r
794  * add :\r
795  * root._reserveRemoval にいたら消す, new_parent._xnodes に挿入 steta は not_added にして commitUpdate を待つ\r
796  */\r
797         \r
798 Node.prototype._reserveUpdate = function(){\r
799         var root = Node.root;\r
800         if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( root, root._startUpdate );\r
801 };\r
802 \r
803 Node.prototype._startUpdate = function(){\r
804         var removal, i, xnode, tmp;\r
805         \r
806         if( this._updateTimerID ){\r
807                 //X.Timer.cancelFrame( this._updateTimerID ); // fire 空の cancel が動かない、、、\r
808                 this._updateTimerID = 0;\r
809         } else {\r
810                 return;\r
811         };\r
812 \r
813         removal = Node._reserveRemoval;\r
814         \r
815         tmp = this._rawNode.style.visibility;\r
816         //this._rawNode.style.visibility = 'hidden';\r
817         \r
818         if( i = removal.length ){\r
819                 for( ; i; ){\r
820                         xnode = removal[ --i ];\r
821                         xnode._actualRemove();\r
822                         !this._state && xnode.kill();\r
823                 };\r
824                 removal.length = 0;             \r
825         };\r
826         \r
827         this._commitUpdate();\r
828         \r
829         //this._rawNode.style.visibility = tmp;\r
830 };\r
831 \r
832 Node.prototype._commitUpdate =\r
833         document.getElementById ?\r
834                 ( function( parentElement, nextElement ){\r
835                         var elm = this._rawNode,\r
836                                 xnodes, l, i, frg, next, k, v;\r
837 \r
838                         if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){\r
839                                 nextElement ?\r
840                                         parentElement.insertBefore( this._actualCreate(), nextElement ) :\r
841                                         parentElement.appendChild( this._actualCreate() );\r
842                                 this._afterActualCreate();\r
843                                 \r
844                                 \r
845                                 return elm || this._rawNode;\r
846                         } else\r
847                         if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) {\r
848                                 \r
849                                 /*if( elm.childNodes.length !== l && ( frg = Node._useDocumentFragment ) ){\r
850                                         for( i = 0; i < l; ++i ){\r
851                                                 frg.appendChild( xnodes[ i ]._actualCreate( true ) );\r
852                                         };\r
853                                         elm.appendChild( frg );\r
854                                         for( i = 0; i < l; ++i ){\r
855                                                 xnodes[ i ]._afterActualCreate( true );\r
856                                         };\r
857                                 } else {*/\r
858                                         for( ; l; ){\r
859                                                 next = xnodes[ --l ]._commitUpdate( elm, next );\r
860                                         };\r
861                                 //};\r
862                         };\r
863 \r
864                         this._dirty && this._updateRawNode( elm );\r
865                         return elm;\r
866                 }) :\r
867         document.all ? \r
868                 ( function( parentElement, prevElement ){\r
869                         var elm    = this._rawNode || this._ie4getRawNode(),\r
870                                 xnodes, l, i, html, text, prev;\r
871 \r
872                         if( !elm ){\r
873                                 prevElement ?\r
874                                         prevElement.insertAdjacentHTML( 'AfterEnd', this._actualCreate() ) :\r
875                                         parentElement.insertAdjacentHTML( 'AfterBegin', this._actualCreate() );\r
876                                 this._afterActualCreate();\r
877                                 return this._rawNode || this._ie4getRawNode();\r
878                         };\r
879                         \r
880                         xnodes = this._xnodes;\r
881                         l      = xnodes ? xnodes.length : 0;\r
882                         \r
883                         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
884                                 html = [];\r
885                                 for( i = 0; i < l; ++i ){\r
886                                         html[ i ] = xnodes[ i ]._actualCreate();\r
887                                 };\r
888                                 elm.innerHTML = html.join( '' );\r
889                                 for( i = 0; i < l; ++i ){\r
890                                         xnodes[ i ]._afterActualCreate();\r
891                                 };\r
892                                 this._state &= ~X.Dom.State.IE4_ONLY_TEXT;\r
893                         } else\r
894                         if( this._state & X.Dom.State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う\r
895                                 text = xnodes[ 0 ];\r
896                                 if( text._dirty || !text._root ){\r
897                                         elm.innerHTML = text._text;\r
898                                         delete text._dirty;\r
899                                         text._root = this._root;                                        \r
900                                 };\r
901                         } else\r
902                         if( l ){\r
903                                 for( i = 0; i < l; ++i ){\r
904                                         prev = xnodes[ i ]._commitUpdate( elm, prev );\r
905                                 };\r
906                         };\r
907                         this._dirty && this._updateRawNode( elm );\r
908                         return elm;\r
909                 }) :\r
910                 (function(){});\r
911 \r
912 Node.prototype._updateRawNode =\r
913         document.getElementById ?\r
914                 ( function( elm ){\r
915                         var attrs, rename, k, v;\r
916 \r
917                         // textNode\r
918                         if( this._dirty & X.Dom.Dirty.CONTENT ){\r
919                                 elm.data = X.Dom.chrReferanceTo( this._text );\r
920                                 delete this._dirty;\r
921                                 return;\r
922                         };\r
923                         // id\r
924                         if( this._dirty & X.Dom.Dirty.ID ){\r
925                                 if( X.UA.IE && X.UA.IE < 7 ){\r
926                                         elm.id = this._id;\r
927                                 } else {\r
928                                         this._id ? ( elm.id = this._id ) : elm.removeAttribute( 'id' );                                 \r
929                                 };\r
930                         };\r
931                         // className\r
932                         if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
933                                 if( X.UA.IE && X.UA.IE < 7 ){\r
934                                         elm.className = this._className;\r
935                                 } else {\r
936                                         this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' );                                 \r
937                                 };\r
938                         };\r
939                         // style\r
940                         if( this._dirty & X.Dom.Dirty.CSS ){\r
941                                 if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
942                                         elm.style.cssText = this._cssText;\r
943                                 } else {\r
944                                         elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要\r
945                                         elm.removeAttribute( 'style' );\r
946                                         delete this._cssText;\r
947                                 };\r
948                         };\r
949                         \r
950                         if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
951                                 this._rawNode.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
952                         };\r
953                         \r
954                         // attr\r
955                         if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){\r
956                                 rename = X.Dom.Attr.renameForDOM;\r
957                                 for( k in attrs ){\r
958                                         if( 5 <= X.UA.IE && X.UA.IE < 5.5 ){\r
959                                                 if( this._tag === 'TEXTAREA' && k === 'value' ){\r
960                                                         elm.firstChild ?\r
961                                                                 ( elm.firstChild.data = attrs[ k ] ) :\r
962                                                                 elm.appendChild( document.createTextNode( attrs[ k ] ) );\r
963                                                         continue;\r
964                                                 };\r
965                                         };\r
966                                         ( v = attrs[ k ] ) === undefined ?\r
967                                                 elm.removeAttribute( rename[ k ] || k ) :\r
968                                                 ( elm[ rename[ k ] || k ] = v );\r
969                                 };\r
970                                 delete this._newAttrs;\r
971                         };\r
972                         \r
973                         delete this._dirty;\r
974                 }) :\r
975         document.all ? \r
976                 ( function( elm ){\r
977                         var attrs, rename, k, v;\r
978 \r
979                         // fake textNode\r
980                         if( this._dirty & X.Dom.Dirty.CONTENT ){\r
981                                 elm.innerText = this._text;\r
982                                 delete this._dirty;\r
983                                 return;\r
984                         };\r
985                         \r
986                 /*\r
987                  * http://www.tohoho-web.com/js/element.htm\r
988                  * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる\r
989                  */     \r
990                         // id\r
991                         if( this._dirty & X.Dom.Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) );\r
992 \r
993                         // className\r
994                         if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
995                                 this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' );\r
996                         };\r
997                         // style\r
998                         if( this._dirty & X.Dom.Dirty.CSS ){\r
999                                 if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
1000                                         elm.style.cssText = this._cssText;\r
1001                                 } else {\r
1002                                         elm.style.cssText = '';\r
1003                                         elm.removeAttribute( 'style' );\r
1004                                         delete this._cssText;\r
1005                                 };\r
1006                         };\r
1007                         \r
1008                         if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
1009                                 this._rawNode.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
1010                         };\r
1011                         \r
1012                         // attr\r
1013                         if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){\r
1014                                 rename = X.Dom.Attr.renameForDOM;\r
1015                                 for( k in attrs ){\r
1016                                         ( v = attrs[ k ] ) === undefined ?\r
1017                                                 elm.removeAttribute( rename[ k ] || k ) :\r
1018                                                 elm.setAttribute( rename[ k ] || k, v );\r
1019                                 };\r
1020                                 delete this._newAttrs;\r
1021                         };\r
1022                         \r
1023                         delete this._dirty;\r
1024                 }) :\r
1025                 (function(){});\r
1026 \r
1027 /* --------------------------------------\r
1028  *  Create\r
1029  * \r
1030  * http://d.hatena.ne.jp/uupaa/20080718/1216362040\r
1031  * DOM Rangeが使える環境(Firefox2+,Opera9+,Safari3+)なら、innerHTMLいらずで、ガーって書けます。\r
1032  * return document.createRange().createContextualFragment("<div><select><option></option></select></div>");\r
1033  * insertAdjacentHTML\r
1034  * \r
1035  * ie7 以下では iframe の frameborder や、input name は、createElement 後に setAttribute しても無視される\r
1036  * \r
1037  * fragument がある場合 children も足して\r
1038  * Mozilla: 1.0+, IE: 6.0+, Netscape: 2.0+, Safari: 1.0+, Opera: 7.0+\r
1039  * ie6 大丈夫?fragment の場合リークしないか?チェックが必要\r
1040  * http://msdn.microsoft.com/ja-jp/library/bb250448%28v=vs.85%29.aspx\r
1041  * \r
1042  * document.createElement of ie4 is only for OPTION & IMAGE.\r
1043  */\r
1044 Node.prototype._actualCreate =\r
1045         document.getElementById ? (function( isChild ){\r
1046                 var elm = this._rawNode,\r
1047                         xnodes, frg, i, l;\r
1048                 \r
1049                 if( this._xnodeType === 3 ){\r
1050                         if( elm ) return elm;\r
1051                         delete this._dirty;\r
1052                         return this._rawNode = document.createTextNode( X.Dom.chrReferanceTo( this._text ) );\r
1053                 };\r
1054                 \r
1055                 if( !elm ){\r
1056                         if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
1057                                 delete this._cssText;\r
1058                         };\r
1059                         this._isNew = true;\r
1060                         this._rawNode = elm =\r
1061                                 X.UA.IE && X.UA.IE < 9 ?\r
1062                                         document.createElement( [\r
1063                                                 '<', this._tag,\r
1064                                                         ' UID="', this._uid, '"',\r
1065                                                         this._id ? ' id="' + this._id + '"' : '',\r
1066                                                         this._className ? ' class="' + this._className + '"' : '',\r
1067                                                         this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
1068                                                         this._cssText ? ' style="' + this._cssText + '"' : '',\r
1069                                                 '>' ].join( '' ) ):\r
1070                                         document.createElement( this._tag );\r
1071                 };\r
1072                 if( Node._useDocumentFragment ){\r
1073                         if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
1074                                 !isChild && ( frg = Node._useDocumentFragment ).appendChild( elm );\r
1075                                 for( i = 0; i < l; ++i ){\r
1076                                         elm.appendChild( xnodes[ i ]._actualCreate( true ) );\r
1077                                 };\r
1078                                 return frg || elm;\r
1079                         };\r
1080                 };\r
1081                 \r
1082                 return elm;\r
1083         }) :\r
1084         document.all ? (function( isChild ){\r
1085                 var uid = this._uid,\r
1086                         html, xnodes, n, i, l;\r
1087                 \r
1088                 if( this._xnodeType === 3 ){\r
1089                         //html = [];\r
1090                         //for( i = 0, l = this._text.length; i < l; ++i ){\r
1091                         //      html.push( this._text.charCodeAt( i ) );\r
1092                         //};\r
1093                         //html = html.join( ',' );\r
1094                         html = [ '<FONT id=ie4uid', uid, ' UID="', uid, '">', this._text, '</FONT>' ];// fake textNode\r
1095                         delete this._rawNode;\r
1096                 } else {\r
1097                         if( this._rawNode && !isChild ) this._actualRemove( true );\r
1098                         \r
1099                         if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
1100                                 delete this._cssText;\r
1101                         };\r
1102                         \r
1103                         html = [\r
1104                                 '<', this._tag, ' id=', ( this._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',\r
1105                                 this._className ? ' class="' + this._className + '"' : '',\r
1106                                 this._attrText || ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ),\r
1107                                 this._cssText ? ' style="' + this._cssText + '"' : '',\r
1108                         '>' ];\r
1109                         \r
1110                         n = html.length;\r
1111                         if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){\r
1112                                 if( l === 1 && xnodes[ 0 ]._xnodeType === 3 ){\r
1113                                         // only textnode\r
1114                                         html[ n ] = xnodes[ 0 ]._text;\r
1115                                         ++n;\r
1116                                         this._state |= X.Dom.State.IE4_ONLY_TEXT;\r
1117                                 } else {\r
1118                                         for( i = 0; i < l; ++i ){\r
1119                                                 html[ n ] = xnodes[ i ]._actualCreate( true );\r
1120                                                 ++n;\r
1121                                         };                                      \r
1122                                 };\r
1123                         };\r
1124                         X.Dom.DTD.EMPTY[ this._tag.toLowerCase() ] || ( html[ n ] = '<\/' + this._tag + '>' );\r
1125                         \r
1126                         delete this._newAttrs;\r
1127                 };\r
1128                 \r
1129                 return html.join( '' );\r
1130         }) :\r
1131         (function(){});\r
1132 \r
1133 Node.prototype._afterActualCreate =\r
1134         document.getElementById ? (function(){\r
1135                 var elm = this._rawNode, xnodes, l, attrs, k, i;\r
1136                 \r
1137                 this._root  = this.parent._root;\r
1138                 \r
1139                 if( this._xnodeType === 3 ){\r
1140                         this._dirty && this._updateRawNode( elm );\r
1141                         return this;\r
1142                 };\r
1143                         \r
1144                 xnodes = this._xnodes;\r
1145                 l      = xnodes && xnodes.length;\r
1146                 \r
1147                 if( this._isNew ){\r
1148                         if( !Node._useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加\r
1149                                 for( i = 0; i < l; ++i ){\r
1150                                         elm.appendChild( xnodes[ i ]._actualCreate( true ) );\r
1151                                 };\r
1152                         };\r
1153                         if( !X.UA.IE || 8 < X.UA.IE ){\r
1154                                 elm.UID = this._uid;\r
1155                                 this._newAttrs = this._attrs;\r
1156                                 this._dirty = X.Dom.Dirty.ID | X.Dom.Dirty.CLASSNAME | X.Dom.Dirty.CSS | X.Dom.Dirty.ATTR | X.Dom.Dirty.IE_FILTER;\r
1157                                 this._updateRawNode( elm );\r
1158                         } else\r
1159                         if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
1160                                 elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
1161                                 delete this._dirty;\r
1162                         };\r
1163                         this._restoreEvent();// イベントの復帰\r
1164                         delete this._isNew;\r
1165                 } else {\r
1166                         this._dirty && this._updateRawNode( elm );\r
1167                 };\r
1168                 \r
1169                 if( l ){\r
1170                         for( i = 0; i < l; ++i ){\r
1171                                 xnodes[ i ]._afterActualCreate();\r
1172                         };\r
1173                 };\r
1174                 \r
1175                 return this;\r
1176         }) :\r
1177         document.all ? (function(){\r
1178                 var xnodes, i;\r
1179                 this._root = this.parent._root;\r
1180                 \r
1181                 if( this._xnodeType !== 1 ) return this;\r
1182                 \r
1183                 if( ( xnodes = this._xnodes ) && ( i = xnodes.length ) ){\r
1184                         for( ; i; ){\r
1185                                 xnodes[ --i ]._afterActualCreate();\r
1186                         };\r
1187                 };\r
1188                 if( this._dirty & X.Dom.Dirty.IE_FILTER ){\r
1189                         this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
1190                 };\r
1191                 delete this._dirty;\r
1192                 return this._restoreEvent();// イベントの復帰\r
1193         }) :\r
1194         (function(){});\r
1195 \r
1196 Node.prototype._actualRemove =\r
1197         document.getElementById ?\r
1198                 ( function( isChild ){\r
1199                         var xnodes = this._xnodes,\r
1200                                 elm    = this._rawNode,\r
1201                                 child, i, l;\r
1202                         if( xnodes && ( l = xnodes.length ) ){\r
1203                                 for( i = 0; i < l; ++i ){\r
1204                                         child = xnodes[ i ];\r
1205                                         child._xnodeType === 1 && child._actualRemove( true );\r
1206                                 };\r
1207                         };\r
1208 \r
1209                         if( !elm ) return;\r
1210                         this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
1211                         // elm.parentNode.tagName check tagName is for ie7\r
1212                         !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
1213                 }) :\r
1214         document.all ?\r
1215                 ( function( isChild ){\r
1216                         var xnodes = this._xnodes,\r
1217                                 elm    = this._rawNode || this._ie4getRawNode(),\r
1218                                 i, l, xnode;\r
1219                         if( xnodes && ( l = xnodes.length ) ){\r
1220                                 for( i = 0; i < l; ++i ){\r
1221                                         xnodes[ i ]._actualRemove( true );\r
1222                                 };\r
1223                         };\r
1224 \r
1225                         if( !elm ) return;\r
1226                         this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
1227                         \r
1228                         elm.removeAttribute( 'id' ); // ?\r
1229                         document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // ?\r
1230                         if( !isChild ) elm.outerHTML = '';\r
1231                         delete this._rawNode;\r
1232                 }) :\r
1233                 (function(){});\r
1234         \r
1235         \r
1236 //})( window, document );\r
1237 \r
1238 \r
1239 \r
1240 \r