Ticket #2389: 2389.2.patch

File 2389.2.patch, 2.9 KB (added by shri, 16 years ago)

Revised patch

  • fckdomtools.js

     
    507507        },
    508508
    509509        /**
     510         * Copy all attributes of the element to an array.
     511         * Fix is specific to ticket #2389 but could probably be used in other scenarios.
     512         */
     513        CopyAttributesToArray : function ( element )
     514        {
     515                var elementAttributes = {} ;
     516                var oAttributes = element.attributes;
     517               
     518                for ( var i = 0 ; i < oAttributes.length ; i++ )
     519                {
     520                        // Check for "specified" attributes on the row element
     521                        if( oAttributes.item(i).specified )
     522                        {
     523                                elementAttributes[oAttributes.item(i).nodeName] = this.GetAttributeValue( element, oAttributes.item(i).nodeName ) ;
     524                        }
     525                }
     526                return elementAttributes ;
     527        },
     528
     529        /**
     530         * Generic function used to set attribute values of DOM elements.
     531         */
     532        SetAttributeValue : function( element, attributeName, attributeValue )
     533        {
     534                // Workaround for IE when setting the "style" or "class" attributes.
     535                if ( FCKBrowserInfo.IsIE && attributeName == 'style' )
     536                        element.style.cssText = attributeValue;
     537                else if ( FCKBrowserInfo.IsIE && attributeName == 'class' )
     538                        element.setAttribute( 'className', attributeValue ) ;
     539                else
     540                        element.setAttribute( attributeName, attributeValue ) ;
     541        },
     542       
     543        /**
    510544         * Remove an attribute from an element.
    511545         */
    512546        RemoveAttribute : function( element, attributeName )
  • fcktablehandler.js

     
    685685        // as the cell is not attached to a row. So we'll need an alternative attribute
    686686        // for storing the calculated rowSpan in IE.
    687687        var rowSpanAttr = FCKBrowserInfo.IsIE ? "_fckrowspan" : "rowSpan" ;
    688 
     688       
     689        // Get all row attributes
     690        var rowAttributes = [] ;
     691        var rowCount = 0 ;
     692        var skipRowAttributes = true ;
     693       
    689694        // Clear the table of all rows first.
    690695        while ( table.rows.length > 0 )
    691696        {
    692697                var row = table.rows[0] ;
     698               
     699                // Get all row attributes before deleting the row
     700                if ( FCKDomTools.HasAttributes ( row ) )
     701                {
     702                        skipRowAttributes = false ;
     703                        rowAttributes[rowCount] = FCKDomTools.CopyAttributesToArray ( row );
     704                        rowCount++ ;
     705                }
     706                               
    693707                row.parentNode.removeChild( row ) ;
    694708        }
    695709
     
    765779        for ( var i = 0 ; i < tableMap.length ; i++ )
    766780        {
    767781                var rowObj = FCKTools.GetElementDocument( table ).createElement( 'tr' ) ;
     782               
     783                if ( !skipRowAttributes )
     784                {
     785                        // Set attributes previously stored in the array
     786                        var attributeList = rowAttributes[i];
     787                        for ( var attributeName in attributeList )
     788                        {
     789                                FCKDomTools.SetAttributeValue( rowObj, attributeName , attributeList[attributeName] ) ;
     790                        }
     791                }
     792               
    768793                for ( var j = 0 ; j < tableMap[i].length ; )
    769794                {
    770795                        var cell = tableMap[i][j] ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy