Ticket #2156: 2156_3.patch

File 2156_3.patch, 5.8 KB (added by Alfonso Martínez de Lizarrondo, 11 years ago)

reviewed and merged patch

  • _whatsnew.html

     
    5050                        About plugin shows misleading user language</li>
    5151                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2821">#2821</a>] Configuration
    5252                        items that used floating point numbers were parsed as integers.</li>
     53                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2156">#2156</a>]
     54                        After calling GetData() the style removal operations didn't work in IE.</li>
    5355                <li>Language file updates for the following languages:
    5456                        <ul>
    5557                                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2849">#2849</a>] Lithuanian</li>
  • editor/_source/internals/fckdomtools.js

     
    488488
    489489                for ( var i = 0 ; i < attributes.length ; i++ )
    490490                {
    491                         if ( FCKBrowserInfo.IsIE && attributes[i].nodeName == 'class' )
     491                        if ( FCKBrowserInfo.IsIE )
    492492                        {
    493                                 // IE has a strange bug. If calling removeAttribute('className'),
    494                                 // the attributes collection will still contain the "class"
    495                                 // attribute, which will be marked as "specified", even if the
    496                                 // outerHTML of the element is not displaying the class attribute.
    497                                 // Note : I was not able to reproduce it outside the editor,
    498                                 // but I've faced it while working on the TC of #1391.
    499                                 if ( element.className.length > 0 )
    500                                         return true ;
     493                                var attributeNodeName = attributes[i].nodeName ;
     494
     495                                if ( attributeNodeName.StartsWith( '_fck' ) )
     496                                {
     497                                        /**
     498                                         * There are places in the FCKeditor code where HTML element objects
     499                                         * get values stored as properties (e.g. _fckxhtmljob).  In Internet
     500                                         * Explorer, these are interpreted as attempts to set attributes on
     501                                         * the element. 
     502                                         *
     503                                         * http://msdn.microsoft.com/en-us/library/ms533026(VS.85).aspx#Accessing_Element_Pr
     504                                         *
     505                                         * Counting these as HTML attributes cripples
     506                                         * FCK.Style.RemoveFromRange() once FCK.GetData() has been called.
     507                                         *
     508                                         * The above conditional prevents these internal properties being
     509                                         * counted as attributes.
     510                                         *
     511                                         * refs #2156 and #2834
     512                                         */
     513
     514                                        continue ;
     515                                }
     516
     517                                if ( attributeNodeName == 'class' )
     518                                {
     519                                        // IE has a strange bug. If calling removeAttribute('className'),
     520                                        // the attributes collection will still contain the "class"
     521                                        // attribute, which will be marked as "specified", even if the
     522                                        // outerHTML of the element is not displaying the class attribute.
     523                                        // Note : I was not able to reproduce it outside the editor,
     524                                        // but I've faced it while working on the TC of #1391.
     525                                        if ( element.className.length > 0 )
     526                                                return true ;
     527                                        continue ;
     528                                }
    501529                        }
    502                         else if ( attributes[i].specified )
     530                        if ( attributes[i].specified )
    503531                                return true ;
    504532                }
    505533
  • editor/_source/internals/fckxhtml.js

     
    5656        else
    5757                this._AppendChildNodes( this.MainNode, node, false ) ;
    5858
     59        /**
     60         * FCKXHtml._AppendNode() marks DOM element objects it has
     61         * processed by adding a property called _fckxhtmljob,
     62         * setting it equal to the value of FCKXHtml.CurrentJobNum. 
     63         * On Internet Explorer, if an element object has such a
     64         * property,  it will show up in the object's attributes
     65         * NamedNodeMap, and the corresponding Attr object in
     66         * that collection  will have is specified property set
     67         * to true.  This trips up code elsewhere that checks to
     68         * see if an element is free of attributes before proceeding
     69         * with an edit operation (c.f. FCK.Style.RemoveFromRange())
     70         *     
     71         * refs #2156 and #2834
     72         */
     73        if ( FCKBrowserInfo.IsIE )
     74                FCKXHtml._RemoveXHtmlJobProperties( node ) ;
     75
    5976        // Get the resulting XHTML as a string.
    6077        var sXHTML = this._GetMainXmlString() ;
    6178
  • editor/_source/internals/fckxhtml_ie.js

     
    9292        }
    9393}
    9494
     95/**
     96 * Used to clean up HTML that has been processed FCKXHtml._AppendNode().
     97 *
     98 * For objects corresponding to HTML elements, Internet Explorer will
     99 * treat a property as if it were an attribute set on that element.
     100 *
     101 * http://msdn.microsoft.com/en-us/library/ms533026(VS.85).aspx#Accessing_Element_Pr
     102 *
     103 * FCKXHtml._AppendNode() sets the property _fckxhtmljob on node objects
     104 * corresponding HTML elements to mark them as having been processed.
     105 * Counting these properties as attributes will cripple style removal
     106 * because FCK.Styles.RemoveFromSelection() will not remove an element
     107 * as long as it still has attributes.
     108 *
     109 * refs #2156 and #2834
     110 */
     111
     112FCKXHtml._RemoveXHtmlJobProperties = function ( node )
     113{
     114        // Select only nodes of type ELEMENT_NODE
     115        if (!node || !node.nodeType || node.nodeType != 1)
     116                return ;
     117
     118        // Clear the _fckhtmljob attribute.
     119        if ( typeof node._fckxhtmljob !== 'undefined' )
     120                node.removeAttribute('_fckxhtmljob') ;
     121
     122        // Recurse upon child nodes.
     123        if ( node.hasChildNodes() )
     124        {
     125                var childNodes = node.childNodes ;
     126                for ( var i = childNodes.length - 1 ; i >= 0 ; i-- )
     127                        FCKXHtml._RemoveXHtmlJobProperties( childNodes.item(i) ) ;
     128        }
     129}
     130
    95131// On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
    96132FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
    97133{
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy