OSDN Git Service

Version 0.6.22, remove throw from X.UI.*.
[pettanr/clientJs.git] / 0.6.x / js / dom / 12_XDomEvent.js
1 /**
2  * use X.Callback
3  * 
4  * http://d.hatena.ne.jp/uupaa/20100430/1272561922
5  * 
6  */
7
8 if( window.addEventListener ){
9         X.Dom.Event = function( e, xnode ){
10                 //this._event        = e;
11                 this.type          = e.type;
12                 
13                 //http://www.quirksmode.org/js/events_properties.html
14                 this.target        = Node._getXNode( e.target.nodeType === 3 ? e.target.parentNode : e.target );// defeat Safari bug // xnode
15                 
16                 this.currentTarget = xnode; // xnode
17                 this.relatedTarget = Node._getXNode( e.relatedTarget ); // xnode
18                 this.eventPhase    = e.eventPhase;
19                 
20                 this.clientX       = e.clientX;
21                 this.clientY       = e.clientY;
22                 //this.screenX       = e.screenX;
23                 //this.screenY       = e.screenY;
24                 this.pageX         = e.pageX;
25                 this.pageY         = e.pageY;
26                 this.offsetX       = e.offsetX || e.layerX;
27                 this.offsetY       = e.offsetY || e.layerY;
28                 
29                 this.keyCode       = e.keyCode;
30                 this.altKey        = e.altKey;
31                 this.ctrlKey       = e.ctrlKey;
32                 this.shiftKey      = e.shiftKey;
33                 
34                 // http://www.programming-magic.com/20090127231544/
35                 this.which         = e.which || ( e.button + 1 ); // 左:1, 中:2, 右:3
36                 
37                 // https://developer.mozilla.org/ja/docs/DOM/DOM_event_reference/mousewheel
38                 if( e.wheelDeltaY !== undefined ){
39                         this.wheelDeltaX = e.wheelDeltaX / 12;
40                         this.wheelDeltaY = e.wheelDeltaY / 12;
41                 } else
42                 if( e.wheelDelta !== undefined ){
43                         this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;
44                 } else
45                 if( e.detail !== undefined ){
46                         this.wheelDeltaX = this.wheelDeltaY = - e.detail * 3;
47                 } else {
48                         this.wheelDeltaX = this.wheelDeltaY = 0;
49                 };
50                 
51                 if( e.constructor === window.TouchEvent ){
52                         // TouchEvent
53                         this.touches        = e.touches;
54                         this.changedTouches = e.changedTouches;
55                         this.targetTouches  = e.targetTouches;
56                         this.metaKey        = e.metaKey;
57                 } else
58                 if( e.constructor === window.PointerEvent ){
59                         // PointerEvent;
60                         this.currentPoint  = e.currentPoint;
61                         this.width         = e.width;
62                         this.height        = e.height;
63                         this.timeStamp     = e.timeStamp;
64                         this.hwTimestamp   = e.hwTimestamp;
65                         this.intermediatePoints = e.intermediatePoints;
66                         this.isPrimary     = e.isPrimary;
67                         this.pointerId     = e.pointerId;
68                         this.pointerType   = e.pointerType;
69                         this.pressure      = e.pressure;
70                         this.tiltX         = e.tiltX;
71                         this.tiltY         = e.tiltY;
72                 };
73         };
74 } else {
75         X.Dom.Event = function( e, xnode, element ){
76                 var btn;
77                 
78                 //this._event        = e;
79                 this.type          = e.type;
80                 this.target        = Node._getXNode( e.srcElement ); // xnode
81                 if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか?
82                 this.currentTarget = xnode; // xnode
83                 this.relatedTarget = Node._getXNode( e.formElement ? e.formElement : e.toElement ); // xnode
84                 this.eventPhase    = e.srcElement === element ? 2: 3;
85                 
86                 this.clientX       = e.clientX;
87                 this.clientY       = e.clientY;
88                 //this.screenX       = e.screenX;
89                 //this.screenY       = e.screenY;
90                 
91                 if( X.Dom._root ){ // uuu...
92                         
93                         this.pageX         = e.clientX + X.Dom._root.scrollLeft;
94                         this.pageY         = e.clientY + X.Dom._root.scrollTop;
95                         
96                         // DOMAssistant 2.8.1
97                         //event.pageX = DOMAssistant.def(e.pageX)? e.pageX : (event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0));
98                         //event.pageY = DOMAssistant.def(e.pageY)? e.pageY : (event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0));                                     
99                 };
100                 
101
102                 
103                 if( X.UA.IE && 5 <= X.UA.IE ){
104                         this.offsetX       = e.offsetX; // イベントターゲット左上からの座標
105                         this.offsetY       = e.offsetY;                 
106                 } else {
107                         //this.offsetX       = e.x - e.srcElement.offsetLeft; // e.x はイベント発生要素の親要素を基準にした座標。
108                         //this.offsetY       = e.y - e.srcElement.offsetTop;    
109                 };
110                 
111                 this.keyCode       = e.keyCode;
112                 this.altKey        = e.altKey;
113                 this.ctrlKey       = e.ctrlKey;
114                 this.shiftKey      = e.shiftKey;
115                 
116                 // http://www.programming-magic.com/20090127231544/
117                 switch( this.type ){
118                         case 'click'    :
119                         case 'dblclick' :
120                                 this.which = 1;
121                                 break;
122                         case 'contextmenu' :
123                                 this.which = 3;
124                                 break;
125                         default :
126                                 btn = e.button;
127                                 this.which =
128                                         btn & 1 ? 1 :
129                                         btn & 4 ? 2 :
130                                         btn & 2 ? 3 : 0; // 左:1(click:0), 中:4, 右:2
131                 };
132                 this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;
133         };
134 };
135
136 X.Dom.Event.DOM_PRE_INIT        = 0;
137 X.Dom.Event.DOM_INIT            = 1;
138 X.Dom.Event.XDOM_READY          = 2;
139 X.Dom.Event.VIEW_ACTIVATE       = 3;
140 X.Dom.Event.VIEW_DEACTIVATE     = 4;
141 X.Dom.Event.VIEW_RESIZED        = 5;
142 // on_screen_keyboard_show
143 // on_screen_keyboard_hide
144 // before_commit_update
145 X.Dom.Event.COMMIT_UPDATE       = 6;
146 // hash_change
147 // before_unload
148 // X.Dom.Event.LOAD_BEFORE_STOP    = 7;
149 X.Dom.Event.LOAD_ASSET_COMPLETE = 7;
150 X.Dom.Event.LOAD_ASSET_ERROR    = 8;
151
152 X.Dom.Event.ANIME_BEFORE_START  = 9;
153 X.Dom.Event.ANIME_START         = 10;
154 X.Dom.Event.ANIME               = 11;
155 X.Dom.Event.ANIME_END           = 12;
156 X.Dom.Event.ANIME_BEFORE_STOP   = 13; // xnode.stop() のみ、指定時間による停止では呼ばれない
157 X.Dom.Event.ANIME_STOP          = 14;
158 X.Dom.Event._LAST_EVENT         = 14; // ここに書いてあるイベントの最後の値 X.Dom.Event.ANIME_STOP と同じ値
159
160
161 X.Dom.Node.prototype.listen = function( type, arg2, arg3, arg4 /* [ listener || ( context + function ) || function ][ arguments ] */ ){
162         var elm;
163         
164         if( this._xnodeType === 0 || this._xnodeType === 3 || !arg2 ) return this;
165         
166         ( !this._listeners || !this._listeners[ type ] ) && this._addEvent( type );
167         
168         return typeof arg2 === 'function' ?
169                 X.EventDispatcher.prototype.listen.call( this, type, this, arg2, arg3 ) :
170                 X.EventDispatcher.prototype.listen.apply( this, arguments );
171 };
172
173 X.Dom.Node.prototype._addEvent =
174         document.removeEventListener ?
175                 (function( type ){
176                         this._rawNode && this._rawNode.addEventListener( type, this, false );
177                 }) :
178         document.detachEvent ?
179                 (function( type ){
180                         if( !this._rawNode ) return;
181                         this._handleEvent = this._handleEvent || X.Callback.create( this );
182                         this._rawNode.attachEvent( 'on' + type, this._handleEvent );
183                 }) :
184                 (function( type ){
185                         var elm = this._ie4getRawNode();
186                         if( !elm ) return;
187                         this._handleEvent = elm[ 'on' + type ] = this._handleEvent || X.Callback.create( this );
188                 });
189
190
191 X.Dom.Node.prototype.unlisten = function( type /* , arg2, arg3, arg4 */ ){
192         var list = this._listeners,
193                 l    = !this._dispatching && list && type !== undefined && list[ type ] && list[ type ].length;
194         
195         X.EventDispatcher.prototype.unlisten.apply( this, arguments );
196         
197         l && !list[ type ] && this._removeEvent( type );
198         
199         return this;
200 };
201
202 X.Dom.Node.prototype._removeEvent =
203         document.removeEventListener ?
204                 (function( type ){
205                         var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
206                         if( !elm ) return;
207                         elm.removeEventListener( type, this, false );
208                 }) :
209         document.detachEvent ?
210                 (function( type ){
211                         var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
212                         if( !elm ) return;
213                         elm.detachEvent( 'on' + type, this._handleEvent );
214                         if( !this._listeners ){
215                                 X.Callback._correct( this._handleEvent );
216                                 delete this._handleEvent;
217                         };
218                 }) :
219                 (function( type ){
220                         var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
221                         if( !elm ) return;
222                         elm[ 'on' + type ] = X.emptyFunction;
223                         elm[ 'on' + type ] = '';
224                         if( !this._listeners ){
225                                 X.Callback._correct( this._handleEvent );
226                                 delete this._handleEvent;
227                         };
228                 });
229
230
231 X.Dom.Node.prototype.handleEvent =
232         document.removeEventListener ?
233                 (function( e ){
234                         var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) );
235
236                         if( ret & X.Callback.STOP_PROPAGATION ){
237                                 e.stopPropagation();
238                         };
239                         if( ret & X.Callback.PREVENT_DEFAULT ){
240                                 e.preventDefault();
241                                 return false;
242                         };
243                 }) :
244                 (function(){
245                         var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawNode ) );
246
247                         if( ret & X.Callback.STOP_PROPAGATION ){
248                                 event.cancelBubble = true;
249                         };
250                         if( ret & X.Callback.PREVENT_DEFAULT ){
251                                 return event.returnValue = false;
252                         };
253                 });
254
255
256 // イベントの退避、dom が画面から抜かれる場合に実施しておく
257 X.Dom.Node.prototype._migrateEvent = function(){
258         var hash = this._listeners,
259                 type;
260         if( !hash ) return;
261         for( type in hash ){
262                 this._removeEvent( type );
263         };
264 };
265
266 // 退避したイベントの復帰
267 X.Dom.Node.prototype._restoreEvent = function(){
268         var hash = this._listeners,
269                 type;
270         if( !hash ) return;
271         for( type in hash ){
272                 this._addEvent( type );
273         };
274 };
275
276
277
278 /* -----------------------------------------------
279  * Document Ready
280  *  Dean Edwards/Matthias Miller/John Resig
281  */
282 /* for ie9+/Mozilla/Opera9 */
283 if( document.addEventListener ){
284         X.Dom.Node._document.listenOnce( 'DOMContentLoaded', X.Dom._init );
285 } else
286 if( 5 <= X.UA.IE && X.inHead ){
287         // if this script in Head
288         document.write( "<script id=__ie_onload defer src=javascript:void(0)><\/script>" );
289         X.Dom._script = document.getElementById( "__ie_onload" );
290         X.Dom._script.onreadystatechange = function(){
291                 this.readyState === 'complete' && X.Dom._init();
292         };
293 } else
294 if( X.UA.WebKit ){ // sniff
295         X.Timer.add( 10, function(){
296                 if( !X.Dom._init ) return X.Callback.UN_LISTEN;
297                 if( 'loaded|complete'.indexOf( document.readyState ) !== -1 ) return X.Dom._init();
298         });
299 };
300
301 /* for other browsers */
302 X.Dom.Node._window.listenOnce( 'load', X.Dom._init );
303
304 //
305 X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){ console.log( 'X.Dom XDomReady ' + X.Dom.readyState ); } );
306
307 X.Dom.listenOnce( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ); } );
308
309
310 /* --------------------------------------
311  *  load
312  */
313 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
314         
315         Node._html = document.documentElement ?
316                         new Node( document.documentElement ) :
317                 document.getElementsByTagName ?
318                         new Node( document.getElementsByTagName( 'html' )[ 0 ] ) :
319                 document.all ?
320                         new Node( document.all.tags( 'html' )[ 0 ] ) :
321                         null;
322
323         var r    = Node.root = new Node( document.body ),
324                 body = r._rawNode,
325                 createTree, xnodes, s, i, n = 0;
326         r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
327         
328         r._root  = Node._html._root = r;
329         r.parent = Node._html;
330         //r.width  = new Function( 'return X.Dom.getSize()[ 0 ]' );
331         //r.height = new Function( 'return X.Dom.getSize()[ 1 ]' );
332         
333         // todo: cleanup tree
334         
335         body.childNodes && (function( elm, skip, head ){
336                 var me         = arguments.callee,
337                         moveToHead = 'style,bgsound,area,base,meta'.split( ',' ),
338                         remove     = 'script,noscript,noframes,comment,!,noembed,nolayer'.split( ',' ),
339                         noncleanup = 'pre,textarea,code,kbd,samp,xmp,plaintext,listing'.split( ',' ),
340                         nodes      = elm.childNodes,
341                         i          = 0,
342                         node, tag, textNode, content;
343                 for( ; i < nodes.length; ){
344                         node = nodes[ i ];
345                         switch( node.nodeType ){
346                                 case 1 :
347                                         tag = node.tagName.toLowerCase();
348                                         if( moveToHead.indexOf( tag ) !== -1 ){
349                                                 head = head || document.getElementsByTagName( 'head' )[ 0 ];
350                                                 head.appendChild( node );
351                                                 continue;
352                                         } else
353                                         if( remove.indexOf( tag ) !== -1 ){
354                                                 node.parentNode.removeChild( node );
355                                                 continue;
356                                         } else {
357                                                 // pre タグ以下はスペースの置換は行わない
358                                                 me( node, skip || noncleanup.indexOf( tag ) !== -1, head );
359                                         };
360                                         textNode = false;
361                                         ++i;                                            
362                                         break;
363                                 case 3 :
364                                         content = skip ? node.data : X.Dom.cleanupWhiteSpace( node.data );
365                                         //console.log( 'Delete space ' + node.data.length + ' => ' + content.length );
366                                         if( !textNode && content !== ' ' && content.length ){
367                                                 node.data = content;
368                                                 textNode  = node;
369                                                 ++i;
370                                                 break;
371                                         } else
372                                         if( textNode ){
373                                                 textNode.data += content; // 直前が TextNode の場合 一本化して削除
374                                         };
375                                         // ブロック要素直下のスペースだけは削除??
376                                 default :
377                                         //console.log( 'Remove type: ' + node.nodeType + ' value: ' + node.nodeValue );
378                                         elm.removeChild( node );
379                                         //++count;
380                         };
381                 };
382         })( body );
383         
384         createTree =
385                 body.childNodes ?
386                         (function( xnode, childNodes, skipCleanup ){
387                                 var i = 0,
388                                         j = 0,
389                                         child, _xnode, f, tag, text, _xtext;
390                                 childNodes = X.copyArray( childNodes );
391
392                                 for( ; i < childNodes.length; ++i ){
393                                         child = childNodes[ i ];
394                                         if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || child.tagName === '!' ){
395                                                 child.parentNode.removeChild( child );
396                                                 continue;
397                                         };
398                                         f = false;
399                                         while( xnode._xnodes && j < xnode._xnodes.length ){
400                                                 _xnode = xnode._xnodes[ j ];
401                                                 _xnode.parent   = xnode;
402                                                 
403                                                 if( _xnode._xnodeType === 1 ){
404                                                         if( child.nodeType !== 1 ){
405                                                                 if( !( text = child.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
406                                                                         child.parentNode.removeChild( child );
407                                                                         break;
408                                                                 };
409                                                                 alert( '[' +xnode._tag + '>' +_xnode._tag + '] !== ' + child.nodeType + '\n' + child.data );
410                                                                 ++j;
411                                                                 continue;
412                                                         };
413                                                         tag = child.tagName;
414                                                         if( _xnode._tag.toUpperCase() !== tag ){
415                                                                 alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );
416                                                                 ++j;
417                                                                 continue;
418                                                         } else {
419                                                                 _xnode._rawNode = child;
420                                                                 _xnode._root    = xnode._root;
421                                                                 child.UID = _xnode._uid;
422                                                                 if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){ // ie で body 内の script が2度よばれるのに対処
423                                                                         //alert( '[' +xnode._tag + '>' + _xnode._tag + '] remove ... ' );
424                                                                         _xnode.destroy();
425                                                                         ++n;
426                                                                         continue;
427                                                                 } else {
428                                                                         //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );
429                                                                         child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
430                                                                 };
431                                                                 _xtext = null;
432                                                                 f = true;
433                                                                 ++j;
434                                                                 break;
435                                                         };
436                                                 } else
437                                                 if( _xnode._xnodeType === 3 ){
438                                                         if( child.nodeType !== 3 ){
439                                                                 if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
440                                                                         console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
441                                                                         _xnode.destroy();
442                                                                         ++n;
443                                                                         continue;
444                                                                 };
445                                                                 alert(  xnode._tag + '>' + '"' + _xnode._text + '" !== ' + child.tagName + '\n' + child.outerHTML );
446                                                                 ++j;
447                                                                 continue;
448                                                         };
449                                                         
450                                                         _xnode._rawNode = child;
451                                                         _xnode._root    = xnode._root;
452                                                         if( !skipCleanup ){
453                                                                 if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
454                                                                         console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
455                                                                         _xnode.destroy();
456                                                                         ++n;
457                                                                         continue;
458                                                                 };
459                                                                 if( _xtext ){
460                                                                         _xtext.text( _xtext._text + text );
461                                                                         console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );
462                                                                         _xnode.destroy();
463                                                                         ++n;
464                                                                         continue;
465                                                                 } else {
466                                                                         //alert( xnode._tag + '>' + '"' + text + '"\n' + child.data );
467                                                                         _xnode.text( text );
468                                                                 };
469                                                         } else
470                                                         if( _xtext ){
471                                                                 _xtext.text( _xtext._text + _xnode.text );
472                                                                 console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );
473                                                                 _xnode.destroy();
474                                                                 ++n;
475                                                                 continue;
476                                                         };
477                                                         _xtext = _xtext || _xnode;
478                                                         ++j;
479                                                         break;
480                                                 } else {
481                                                         alert( 'no hit!' );
482                                                 };
483                                                 ++j;
484
485                                         };                              
486                                         //if( !f ) alert( '**** ' + child.outerHTML );
487                                 };
488                                 while( xnode._xnodes && j < xnode._xnodes.length ){
489                                         _xnode = xnode._xnodes[ j ];
490                                         _xnode.parent = xnode;
491                                         _xnode.destroy();
492                                         ++n;
493                                         continue;
494                                 };
495                         }) :
496                 body.children ? 
497                         (function( xnode, children, skipCleanup ){
498                                 var parent = xnode,
499                                         xnodes = parent._xnodes,
500                                         l      = xnodes && xnodes.length,
501                                         m      = children.length,
502                                         i = 0, j = 0, flag = 0,
503                                         elm, tag, xtext, text;
504                                 //children = X.copyArray( children );
505
506                                 for( ; i < xnodes.length; ++i ){
507                                         xnode = xnodes[ i ];
508                                         xnode.parent = parent;
509                                         
510                                         if( xnode._xnodeType === 3 ){
511                                                 //alert( X.Dom.cleanupWhiteSpace( xnode._text ) );
512                                                 if( !skipCleanup ){
513                                                         if( !( text = xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
514                                                                 xnode.destroy();
515                                                                 --i;
516                                                         } else
517                                                         if( xtext ){
518                                                                 //alert( 'xtext ' + text.charCodeAt( 0 ) + ' : ' + text.length );
519                                                                 xtext.text( xtext._text + text );
520                                                                 xnode.destroy();
521                                                                 --i;
522                                                         } else {
523                                                                 //alert( 'xnode ' + text.charCodeAt( 0 ) + ' : ' + text.length );
524                                                                 xnode.text( text );
525                                                         };
526                                                 } else
527                                                 if( xtext ){
528                                                         //alert( 'skip ' + text.charCodeAt( 0 ) + ' : ' + text.length );
529                                                         xtext.text( xtext._text + xnode._text );
530                                                         xnode.destroy();
531                                                         --i;
532                                                 };
533                                                 flag |= 4;
534                                                 xtext = xtext || xnode;
535                                                 continue;
536                                         };
537                                         
538                                         if( xnode._xnodeType !== 1 ){
539                                                 //alert( xnode._xnodeType )
540                                                 continue;
541                                         };
542                                         
543                                         for( ; j < m; ++j ){
544                                                 elm = children[ j ];
545                                                 tag = elm.tagName;
546                                                 
547                                                 if( tag === '!' ){
548                                                         continue;
549                                                 } else
550                                                 if( xnode._tag !== tag ){
551                                                         alert( xnode._tag + ' ' + xnode._xnodeType + ' !== ' + tag + '\n' + elm.outerHTML );
552                                                 } else {
553                                                         xnode._rawNode = elm;
554                                                         xnode._root    = parent._root;
555                                                         if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){
556                                                                 xnode.destroy();
557                                                                 --i;
558                                                                 break;
559                                                         } else {
560                                                                 xnode._xnodes && xnode._xnodes.length && createTree( xnode, elm.children, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
561                                                                 
562                                                                 !xnode._id && ( elm.id = 'ie4uid' + xnode._uid );
563                                                                 elm.setAttribute( 'UID', xnode._uid );
564                                                                 
565                                                                 tag === 'INPUT' && (
566                                                                         !xnode._attrs ?
567                                                                                 ( xnode._attrs = { type : 'text' } ) :
568                                                                                 ( !xnode._attrs.type ) || ( xnode._attrs.type = 'text' )
569                                                                 );
570                                                                 flag |= 3;
571                                                                 xtext = null;
572                                                                 break;
573                                                         };
574                                                 };
575                                         };
576                                         // for
577                                         if( !xnode._rawNode ){
578                                                 alert( xnode._tag + ' ' + xnode._id + ' !== none...' );
579                                                 --i;
580                                         };
581                                         ++j;
582                                         flag &= 6;
583                                 };
584                                 // textNode がある
585                                 ( flag & 6 ) && ( parent._dirty |= X.Dom.Dirty.IE4_TEXTNODE_FIX );
586                                 //( flag & 4 ) && ( parent._state |= X.Dom.Dirty.ONLY_TEXTNODE );
587                         }) : 0;
588         
589         r._xnodes = xnodes = [];
590         // body の属性値の取得
591
592         Node.skipCreate = true;
593         /*
594          * http://support.microsoft.com/kb/812417/ja
595          * PRB: outerHTML の HTML 要素のプロパティは、既定の属性は表示されません。
596          * 
597          * body.innerHTML でなく、 body.outerHTML にはできなかった、、、
598          */
599         xnodes.push.apply( xnodes, X.Dom.parse( body.innerHTML, true ) );
600         delete Node.skipCreate;
601         
602         //alert(n +  ' ' + body.innerHTML);
603         
604         createTree( r, body.childNodes || body.children );
605         //r._dirty = X.Dom.Dirty.IE4_TEXTNODE_FIX;
606         
607         i = xnodes.length;
608         Node._systemNode = s = r.create( 'div' ).className( 'hidden-sysyem-node' );
609         //alert( i + ' -> ' + xnodes.length );
610         
611         r._startUpdate();
612         
613         xnodes.splice( xnodes.indexOf( s ), 1 ); // hide from api user
614         
615         //alert(n +  ' ' + body.innerHTML);
616 } );
617
618