Ticket #3453: 3453.patch

File 3453.patch, 1.6 KB (added by Garry Yao, 15 years ago)
  • _source/core/dom/range.js

     
    473473                                }
    474474
    475475                                // Process the end only if not normalized.
    476                                 if ( !this.isCollapsed )
     476                                if ( !this.collapsed )
    477477                                {
    478478                                        // Find out if the start is pointing to a text node that
    479479                                        // will be normalized.
     
    501501                                        }
    502502                                }
    503503                        }
     504                        // Never place the carot inside empty node, which will be removed
     505                        // during 'innerHTML' retrieving, make the bookmark positon incorrect. (#3453)
     506                        while ( startContainer.type == CKEDITOR.NODE_TEXT
     507                                && !CKEDITOR.tools.trim( startContainer.getText() ) )
     508                        {
     509                                var parent = startContainer.getParent();
     510                                startOffset = CKEDITOR.tools.indexOf(
     511                                        Array.prototype.slice.call( parent.$.childNodes ), startContainer.$ );
     512                                startContainer = parent;
     513                        }
     514                        if( !this.collapsed )
     515                        {
     516                                while ( endContainer.type == CKEDITOR.NODE_TEXT
     517                                        && !CKEDITOR.tools.trim( endContainer.getText() ) )
     518                                {
     519                                        parent = endContainer.getParent();
     520                                        endOffset = CKEDITOR.tools.indexOf(
     521                                                Array.prototype.slice.call( parent.$.childNodes ), endContainer.$ );
     522                                        endContainer = parent;
     523                                }
     524                        }
    504525
    505526                        return {
    506527                                start           : startContainer.getAddress( normalized ),
    507                                 end                     : this.isCollapsed ? null : endContainer.getAddress( normalized ),
     528                                end                     : this.collapsed ? null : endContainer.getAddress( normalized ),
    508529                                startOffset     : startOffset,
    509530                                endOffset       : endOffset,
    510531                                normalized      : normalized,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy