Ticket #7260: 7260.patch

File 7260.patch, 1.5 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/node.js

     
    210210                                {
    211211                                        // Get the node index. For performance, call getIndex
    212212                                        // directly, instead of creating a new node object.
    213                                         address.unshift( this.getIndex.call( { $ : node }, normalized ) );
     213                                        address.push( this.getIndex.call( { $ : node }, normalized ) );
    214214                                }
    215215
    216216                                node = parentNode;
    217217                        }
    218218
    219                         return address;
     219                        // Reverse the array instead of doing 'unshift' as for it's poor performance. (#7260)
     220                        return address.reverse();
    220221                },
    221222
    222223                /**
     
    393394                        return ( parent && parent.nodeType == 1 ) ? new CKEDITOR.dom.node( parent ) : null;
    394395                },
    395396
     397                /**
     398                 *  Retrieve all ancestors from this element up till the document element.
     399                 * @param {Boolean} [closerFirst=false] Whether closer ancestors stay in front of the result list.
     400                 */
    396401                getParents : function( closerFirst )
    397402                {
    398403                        var node = this;
     
    400405
    401406                        do
    402407                        {
    403                                 parents[  closerFirst ? 'push' : 'unshift' ]( node );
     408                                parents.push( node );
    404409                        }
    405                         while ( ( node = node.getParent() ) )
     410                        while ( ( node = node.getParent() ) );
    406411
    407                         return parents;
     412                        // Reverse the array instead of doing 'unshift' as for it's poor performance. (#7260)
     413                        return closerFirst ? parents : parents.reverse();
    408414                },
    409415
    410416                getCommonAncestor : function( node )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy