Ticket #3576: 3576_3.patch

File 3576_3.patch, 1.9 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/styles/plugin.js

     
    895895        function removeFromElement( style, element )
    896896        {
    897897                var def = style._.definition,
    898                         attributes = def.attributes,
     898                        attributes = CKEDITOR.tools.extend( {}, def.attributes, getOverrides( style )[ element.getName() ] ),
    899899                        styles = def.styles,
    900                         overrides = getOverrides( style );
     900                        // If the style is only about the element itself, we have to remove the element.
     901                        removeEmpty = CKEDITOR.tools.isEmpty( attributes ) && CKEDITOR.tools.isEmpty( styles );
    901902
    902                 function removeAttrs()
    903                 {
    904                         for ( var attName in attributes )
    905                         {
    906                                 // The 'class' element value must match (#1318).
    907                                 if ( attName == 'class' && element.getAttribute( attName ) != attributes[ attName ] )
    908                                         continue;
    909                                 element.removeAttribute( attName );
    910                         }
    911                 }
     903                // Remove definition attributes/style from the elemnt.
     904                for ( var attName in attributes )
     905                {
     906                        // The 'class' element value must match (#1318).
     907                        if ( attName == 'class' && element.getAttribute( attName ) != attributes[ attName ] )
     908                                continue;
     909                        removeEmpty = element.hasAttribute( attName );
     910                        element.removeAttribute( attName );
     911                }
    912912
    913                 // Remove definition attributes/style from the elemnt.
    914                 removeAttrs();
    915913                for ( var styleName in styles )
     914                {
     915                        removeEmpty = removeEmpty || !!element.getStyle( styleName );
    916916                        element.removeStyle( styleName );
     917                }
    917918
    918                 // Now remove override styles on the element.
    919                 attributes = overrides[ element.getName() ];
    920                 if ( attributes )
    921                         removeAttrs();
    922                 removeNoAttribsElement( element );
     919                removeEmpty && removeNoAttribsElement( element );
    923920        }
    924921
    925922        // Removes a style from inside an element.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy