Skip to content
Permalink
Browse files

Merge branch 't/13400' into major

  • Loading branch information...
Reinmar committed Jun 15, 2015
2 parents 4870adb + 6ec2bbe commit 5c2bd9ce63b1cd006efc5d7848a771c3655647cb
Showing with 15 additions and 48 deletions.
  1. +2 −5 core/dom/node.js
  2. +12 −22 plugins/widget/plugin.js
  3. +1 −6 tests/core/dom/node.html
  4. +0 −15 tests/core/dom/node.js
@@ -515,19 +515,16 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, {
* alert( parents[ 0 ].getName() + ',' + parents[ 2 ].getName() ); // 'html,p'
*
* @param {Boolean} [closerFirst=false] Determines the order of returned nodes.
* @param {CKEDITOR.dom.node} [lastParent=null] Guard node. Nodes that are parents of `lastParent` will be ommited.
* If `parent` is `null` or `parent` is not an ancestor of this node all parents will be returned.
* @returns {Array} Returns an array of {@link CKEDITOR.dom.node}.
*/

getParents: function( closerFirst, lastParent ) {
getParents: function( closerFirst ) {
var node = this;
var parents = [];

do {
parents[ closerFirst ? 'push' : 'unshift' ]( node );
}
while ( !node.equals( lastParent ) && ( node = node.getParent() ) );
while ( ( node = node.getParent() ) );

return parents;
},
@@ -1,4 +1,4 @@
/**
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
@@ -1253,36 +1253,26 @@
* @since 4.5
* @private
* @param {String} selector Selector to match.
* @returns {CKEDITOR.dom.node} Matched node or null if a node has not been found.
* @returns {CKEDITOR.dom.element} Matched element or `null` if a node has not been found.
*/
_findOneNotNested: function( selector ) {
var match = null,
parents;

var matchedElements = this.wrapper.find( selector );
var matchedElements = this.wrapper.find( selector ),
match,
closestWrapper;

for ( var i = 0; i < matchedElements.count(); i++ ) {
match = matchedElements.getItem( i );
closestWrapper = match.getAscendant( Widget.isDomWidgetWrapper );

parents = match.getParents( true, this.wrapper );
// Don't include wrapper element.
parents.pop();

for ( var j = 0; j < parents.length; j++ ) {
// One of parents is a widget wrapper, so this match is already a part of other widget.
if ( Widget.isDomWidgetWrapper( parents[ j ] ) ) {
match = null;
break;
}
// The closest ascendant-wrapper of this match defines to which widget
// this match belongs. If the ascendant is this widget's wrapper
// it means that the match is not nested in other widget.
if ( this.wrapper.equals( closestWrapper ) ) {
return match;
}

// The first match is a good match.
// Other matches are probably parts of other widgets instances.
if ( match != null )
break;
}

return match;
return null;
},

/**
@@ -31,9 +31,4 @@ <h1>Title</h1>

text

</p>
<div id="guardParent">
<div>
<span id="getParentsWithGuard"></span>
</div>
</div>
</p>
@@ -673,21 +673,6 @@

assert.areSame( 3, node.getParents().length );
assert.areSame( node.getParents()[ 0 ], node.getParents( true )[ 2 ] );

},

test_getParents_guard: function() {
var guard = newNode( document.getElementById( 'guardParent' ) ),
node = newNode( document.getElementById( 'getParentsWithGuard' ) ),
wrongParent = newNode( document.getElementById( 'remove' ) );

assert.areSame( 3, node.getParents( false, guard ).length );
// guard element is not a parent of node - all nodes up to root are returned (+ body, html)
assert.areSame( 5, node.getParents( false, wrongParent ).length );
assert.areSame( node.getParents( false, guard )[ 0 ], guard );
assert.areSame( node.getParents( false, guard )[ 0 ], node.getParents( true, guard )[ 2 ] );
// guard and base node are the same elements - we should get only that node
assert.isTrue( node.getParents( false, node )[ 0 ].equals( node ) );
},

test_getCommonAncestor: function() {

0 comments on commit 5c2bd9c

Please sign in to comment.
You can’t perform that action at this time.