Ticket #3450: 3450_2.patch

File 3450_2.patch, 3.3 KB (added by Garry Yao, 15 years ago)
  • _source/core/dom/element.js

     
    430430
    431431                                                case 'style':
    432432                                                        // IE does not return inline styles via getAttribute(). See #2947.
    433                                                         return this.$.style.cssText;
     433                                                        var styleText = this.$.style.cssText;
     434                                                        styleText.toLowerCase();
     435                                                        styleText.replace( /\s+/g, '' );
     436                                                        styleText.replace( /\s*(?:;\s*|$)/, ';');
     437                                                        styleText.replace( /([^;])$/, '$1;');
     438                                                        return styleText;
    434439                                        }
    435440
    436441                                        return standard.call( this, name );
  • _source/plugins/styles/plugin.js

     
    197213                                        {
    198214                                                if ( attName == '_length' )
    199215                                                        continue;
    200 
    201                                                 if ( compareAttributeValues(attName, attribs[attName], element.getAttribute( attName ) ) )
     216                                                if ( attribs[attName] == element.getAttribute( attName ) )
    202217                                                {
    203218                                                        if ( !fullMatch )
    204219                                                                return true;
     
    269284                // Browsers make some changes to the style when applying them. So, here
    270285                // we normalize it to the browser format.
    271286                if ( stylesText.length )
    272                 {
    273287                        stylesText = normalizeCssText( stylesText );
    274 
    275                         if ( stylesText.length )
    276                                 stylesText = stylesText.replace( semicolonFixRegex, ';' );
    277                 }
    278 
     288               
    279289                // Return it, saving it to the next request.
    280290                return ( styleDefinition._ST = stylesText );
    281291        };
     
    889893                }
    890894        }
    891895
    892         var spacesRegex = /\s+/g;
    893 
    894896        // Returns an object that can be used for style matching comparison.
    895897        // Attributes names and values are all lowercased, and the styles get
    896898        // merged with the style attribute.
     
    918920
    919921                // Includes the style definitions.
    920922                var styleText = CKEDITOR.style.getStyleText( styleDefinition );
    921                 if ( styleText.length > 0 )
     923                if ( styleText )
    922924                {
    923925                        if ( !attribs[ 'style' ] )
    924926                                length++;
    925 
    926                         attribs['style'] = styleText.replace( spacesRegex, '' ).toLowerCase();
     927                        attribs[ 'style' ] = styleText;
    927928                }
    928929
    929930                // Appends the "length" information to the object.
     
    10011002        {
    10021003                // Injects the style in a temporary span object, so the browser parses it,
    10031004                // retrieving its final format.
    1004                 var tempSpan = document.createElement( 'span' );
    1005                 tempSpan.style.cssText = unparsedCssText;
    1006                 return tempSpan.style.cssText;
    1007         }
    1008 
    1009         // valueA is our internal "for comparison" value.
    1010         // valueB is the value retrieved from the element.
    1011         function compareAttributeValues( attName, valueA, valueB )
    1012         {
    1013                 if ( valueA == valueB || ( !valueA && !valueB ) )
    1014                         return true;
    1015                 else if ( !valueA || !valueB )
    1016                         return false;
    1017 
    1018                 valueB = valueB.toLowerCase();
    1019 
    1020                 if ( attName == 'style' )
    1021                 {
    1022                         valueB = valueB.replace( spacesRegex, '' );
    1023                         if ( valueB.charAt( valueB.length - 1 ) != ';' )
    1024                                 valueB += ';';
    1025                 }
    1026 
    1027                 // Return true if they match or if valueA is null and valueB is an empty string
    1028                 return ( valueA == valueB );
     1005                var temp = new CKEDITOR.dom.element( 'span' );
     1006                temp.setAttribute( 'style', unparsedCssText );
     1007                return temp.getAttribute( 'style' );
    10291008        }
    10301009
    10311010        function applyStyle( document, remove )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy