OSDN Git Service

Version 0.6.171, fix X.KB & fix X.Node for SVG & VML.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 20_XNode.js
index 49ae640..aad360f 100644 (file)
@@ -503,17 +503,26 @@ function X_Node_createTextAt( index, text ){
  */
 function X_Node_clone( opt_clone_children ){
        var xnode, xnodes, i, l;
+       
        if( this[ '_tag' ] ){
                X_Node_newByTag = true;
                xnode = Node( this[ '_tag' ], X_Object_copy( this[ '_attrs' ] ), X_Object_copy( this[ '_css' ] ) )
                        [ 'attr' ]( { 'id' : this[ '_id' ] } )
                        [ 'className' ]( this[ '_className' ] );
+               
+               if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
+                       xnode[ '_flags' ] |= X_NodeFlags_IS_SVG;
+               };
+               if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
+                       xnode[ '_flags' ] |= X_NodeFlags_IS_VML;
+               };
+               
                if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
                        for( i = 0; i < l; ++i ){
                                xnode[ 'append' ]( xnodes[ i ][ 'clone' ]( true ) );
                        };
                };
-               return xnode;           
+               return xnode;
        };
        X_Node_newByText = true;
        return Node( this[ '_text' ] );
@@ -566,6 +575,12 @@ function X_Node_append( v ){
                v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
                X_Node_reserveUpdate();
        };
+       if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
+               v[ '_flags' ] |= X_NodeFlags_IS_SVG;
+       };
+       if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
+               v[ '_flags' ] |= X_NodeFlags_IS_VML;
+       };
        return this;
 };
 
@@ -636,6 +651,12 @@ function X_Node_appendAt( start, v ){
                v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true );
                X_Node_reserveUpdate();
        };
+       if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){
+               v[ '_flags' ] |= X_NodeFlags_IS_SVG;
+       };
+       if( this[ '_flags' ] & X_NodeFlags_IS_VML ){
+               v[ '_flags' ] |= X_NodeFlags_IS_VML;
+       };
        return this;
 };
 
@@ -1145,8 +1166,12 @@ function X_Node_text( text ){
        return this[ '_text' ];
 };
 
-/*
+/**
  * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。
+ * @alias Node.prototype.call
+ * @param {string} [name] 要素の関数名
+ * @return {*} 
+ * @example node.call( 'focus' );
  */
 function X_Node_call( name /*, opt_args... */ ){
        var l = arguments.length - 1,
@@ -1386,7 +1411,11 @@ var X_Node__commitUpdate =
                                                                that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
                                                        '>' ].join( '' ) );
                                } else {
-                                       that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] );
+                                       if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){
+                                               that[ '_rawObject' ] = elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ] );
+                                       } else {
+                                               that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] );
+                                       };
                                };
                                
                                // IE には要素追加のタイミングで起こるメモリリークがありここで追加