Ticket #3758: 3758_3.patch

File 3758_3.patch, 2.2 KB (added by Martin Kou, 14 years ago)
  • _source/plugins/dialog/plugin.js

     
    9898                // Completes the definition with the default values.
    9999                definition = CKEDITOR.tools.extend( definition( editor ), defaultDialogDefinition );
    100100
     101                // Clone a functionally independent copy for this dialog.
     102                definition = CKEDITOR.tools.clone( definition );
     103
    101104                // Create a complex definition object, extending it with the API
    102105                // functions.
    103106                definition = new definitionObject( this, definition );
  • _source/core/tools.js

     
    3838
    3939                /**
    4040                 * Creates a deep copy of an object.
    41                  * Attention: there is no support for deep copy of Array properties and
    42                  * for recursive references.
     41                 * Attention: there is no support for recursive references.
    4342                 * @param {Object} object The object to be cloned.
    4443                 * @returns {Object} The object clone.
    4544                 * @example
     
    6059                 * alert( obj.cars.Porsche.color );     // red
    6160                 * alert( clone.cars.Porsche.color );   // silver
    6261                 */
    63                 clone : function( object )
     62                clone : function( obj )
    6463                {
    65                         if( object === null || typeof( object ) != 'object')
    66                                 return object;
     64                        var clone;
    6765
    68                         var clone = new object.constructor();
     66                        // Array.
     67                        if ( obj && ( obj instanceof Array ) )
     68                        {
     69                                clone = [];
     70                               
     71                                for ( var i = 0 ; i < obj.length ; i++ )
     72                                        clone[ i ] = this.clone( obj[ i ] );
     73                               
     74                                return clone;
     75                        }
    6976
    70                         for ( var propertyName in object )
     77                        // "Static" types.
     78                        if ( obj === null
     79                                || ( typeof( obj ) != 'object' )
     80                                || ( obj instanceof String )
     81                                || ( obj instanceof Number )
     82                                || ( obj instanceof Boolean )
     83                                || ( obj instanceof Date ) )
    7184                        {
    72                                 var property = object[ propertyName ];
     85                                return obj;
     86                        }
     87
     88                        // Objects.
     89                        clone = new obj.constructor();
     90
     91                        for ( var propertyName in obj )
     92                        {
     93                                var property = obj[ propertyName ];
    7394                                clone[ propertyName ] = this.clone( property );
    7495                        }
    7596
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy