Ticket #2389: 2389.patch

File 2389.patch, 3.1 KB (added by shri, 16 years ago)
  • fckdomtools.js

     
    1 /*
     1/*
    22 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    33 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
    44 *
     
    525525                for ( var i = 0 ; i < aAttributes.length ; i++ )
    526526                        this.RemoveAttribute( element, aAttributes[i] );
    527527        },
     528       
     529        /**
     530         * Copy all attributes of the element to an array.
     531         * Fix is specific to ticket #2389 but could probably be used in other scenarios.
     532         */
     533        CopyAttributesToArray : function ( element )
     534        {
     535                var elementAttributes = [] ;
     536                var j = 0 ;
    528537
     538                for ( var i = 0 ; i < element.attributes.length ; i++ )
     539                {
     540                        // Check for "specified" attributes on the row element
     541                        if( element.attributes[i].specified )
     542                        {
     543                                elementAttributes[j] = element.attributes.item(i).nodeName ;
     544                                elementAttributes[j + 1] = this.GetAttributeValue( element, element.attributes.item(i).nodeName ) ;
     545                                j = j + 2 ;
     546                        }
     547                }
     548                return elementAttributes ;
     549        },
     550
     551        /**
     552         * Generic function used to set attribute values of DOM elements.
     553         */
     554        SetAttributeValue : function( element, attributeName, attributeValue )
     555        {
     556                // Workaround for IE when setting the "style" or "class" attributes.
     557                if ( FCKBrowserInfo.IsIE && attributeName == 'style' )
     558                        element.style.cssText = attributeValue;
     559                else if ( FCKBrowserInfo.IsIE && attributeName == 'class' )
     560                        element.setAttribute( 'className', attributeValue ) ;
     561                else
     562                        element.setAttribute( attributeName, attributeValue ) ;
     563        },     
     564
    529565        GetAttributeValue : function( element, att )
    530566        {
    531567                var attName = att ;
  • fcktablehandler.js

     
    1 /*
     1/*
    22 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    33 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
    44 *
     
    686686        // for storing the calculated rowSpan in IE.
    687687        var rowSpanAttr = FCKBrowserInfo.IsIE ? "_fckrowspan" : "rowSpan" ;
    688688
     689        // Get all row attributes
     690        var rowAttributes = [] ;
     691        var rowCount = 0 ;
     692
    689693        // Clear the table of all rows first.
    690694        while ( table.rows.length > 0 )
    691695        {
    692696                var row = table.rows[0] ;
     697               
     698                // Get all row attributes before deleting the row
     699                rowAttributes[rowCount] = FCKDomTools.CopyAttributesToArray ( row );
     700                rowCount++ ;
     701               
    693702                row.parentNode.removeChild( row ) ;
    694703        }
    695704
     
    765774        for ( var i = 0 ; i < tableMap.length ; i++ )
    766775        {
    767776                var rowObj = FCKTools.GetElementDocument( table ).createElement( 'tr' ) ;
     777
     778                // Set attributes previously stored in the array
     779                var rowAttributePairs = [] ;
     780                rowAttributePairs = rowAttributes[i].toString().split(",");
     781               
     782                for ( var k = 0 ; k < rowAttributePairs.length ; k = k + 2 )
     783                        FCKDomTools.SetAttributeValue( rowObj, rowAttributePairs[k] , rowAttributePairs[k + 1] ) ;
     784               
    768785                for ( var j = 0 ; j < tableMap[i].length ; )
    769786                {
    770787                        var cell = tableMap[i][j] ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy