Ticket #2797: 2797_3.patch

File 2797_3.patch, 1.1 KB (added by Frederico Caldeira Knabben, 16 years ago)
  • _source/plugins/styles/plugin.js

     
    280280                var firstNode = range.startContainer.getChild( range.startOffset ) || range.startContainer.getNextSourceNode();
    281281                var lastNode = range.endContainer.getChild( range.endOffset ) || ( range.endOffset ? range.endContainer.getNextSourceNode() : range.endContainer );
    282282
     283                if ( lastNode.equals( firstNode ) )
     284                {
     285                        // If the last node is the same as the the first one, we must move
     286                        // it to the next one, otherwise the first one will not be
     287                        // processed.
     288                        lastNode = lastNode.getNextSourceNode( true );
     289
     290                        // It may happen that there are no more nodes after it (the end of
     291                        // the document), so we must add something there to make our code
     292                        // simpler.
     293                        if ( !lastNode )
     294                        {
     295                                lastNode = document.createText( '' );
     296                                lastNode.insertAfter( firstNode );
     297                        }
     298                }
     299
    283300                var currentNode = firstNode;
    284301
    285302                var styleRange;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy