Ticket #4824: 4824.patch

File 4824.patch, 1.3 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/selection/plugin.js

     
    459459                                                                testRange = range.duplicate();
    460460
    461461                                                                testRange.moveToElementText( child );
    462                                                                 testRange.collapse();
    463462
    464                                                                 var comparison = testRange.compareEndPoints( 'StartToStart', range );
     463                                                                var comparisonStart = testRange.compareEndPoints( 'StartToStart', range ),
     464                                                                                comparisonEnd = testRange.compareEndPoints( 'EndToStart', range );
    465465
    466                                                                 if ( comparison > 0 )
     466                                                                testRange.collapse();
     467
     468                                                                if ( comparisonStart > 0 )
    467469                                                                        break;
    468                                                                 else if ( comparison === 0 )
    469                                                                         return {
    470                                                                                 container : parent,
    471                                                                                 offset : i
    472                                                                         };
     470                                                                // When selection stay at the side of certain self-closing elements, e.g. BR,
     471                                                                // our comparison will never shows an equality. (#4824)
     472                                                                else if ( comparisonStart === 0 || comparisonEnd == 1 && comparisonStart == -1 )
     473                                                                        return { container : parent, offset : i };
     474                                                                else if( comparisonEnd === 0 )
     475                                                                        return { container : parent, offset : i + 1 };
    473476
    474477                                                                testRange = null;
    475478                                                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy