Ticket #3529: 3529.patch

File 3529.patch, 2.4 KB (added by Garry Yao, 15 years ago)
  • _source/core/dom/text.js

     
    7777                 * @param {Number} The position at which to split, starting from zero.
    7878                 * @returns {CKEDITOR.dom.text} The new text node.
    7979                 */
    80                 split : function( offset )
     80                split : ( function()
    8181                {
    82                         // If the offset is after the last char, IE creates the text node
    83                         // on split, but don't include it into the DOM. So, we have to do
    84                         // that manually here.
    85                         if ( CKEDITOR.env.ie && offset == this.getLength() )
    86                         {
    87                                 var next = this.getDocument().createText( '' );
    88                                 next.insertAfter( this );
    89                                 return next;
    90                         }
     82                        function standard( offset ) {
     83
     84                                // If the offset is after the last char, IE creates the text node
     85                                // on split, but don't include it into the DOM. So, we have to do
     86                                // that manually here.
     87                                if (CKEDITOR.env.ie && offset == this.getLength())
     88                                {
     89                                        var next = this.getDocument().createText('');
     90                                        next.insertAfter(this);
     91                                        return next;
     92                                }
    9193
    92                         var doc = this.getDocument();
    93                         var retval = new CKEDITOR.dom.text( this.$.splitText( offset ), doc );
     94                                var doc = this.getDocument();
     95                                return new CKEDITOR.dom.text(this.$.splitText(offset), doc);
     96                        }
    9497
    95                         // IE BUG: IE8 does not update the childNodes array in DOM after splitText(),
    96                         // we need to make some DOM changes to make it update. (#3436)
    97                         if ( CKEDITOR.env.ie && CKEDITOR.env.version >= 8 )
    98                         {
    99                                 var workaround = new CKEDITOR.dom.text( '', doc );
    100                                 workaround.insertAfter( retval );
    101                                 workaround.remove();
    102                         }
    103 
    104                         return retval;
    105                 },
     98                        // IE8 is buggy with splitText.
     99                        function supportSplitText()
     100                        {
     101                                return Object.prototype.toString.call( self.JSON )  !=  "[object JSON]";
     102                        }
     103
     104                        if ( supportSplitText() )
     105                                return standard;
     106                        else
     107                                return function( offset )
     108                                {
     109                                        var retval = standard.call( this, offset );
     110                                        // IE BUG: IE8 does not update the childNodes array in DOM after splitText(),
     111                                        // we need to make some DOM changes to make it update. (#3436)
     112                                        var workaround = this.getDocument().createText( '' );
     113                                        workaround.insertAfter( retval );
     114                                        workaround.remove();
     115                                        return retval;
     116                                };
     117                } )(),
    106118
    107119                /**
    108120                 * Extracts characters from indexA up to but not including indexB.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy