Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Minor docs and code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jul 11, 2017
1 parent f6e287c commit 42f0b8e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/model/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,12 @@ export default class Position {

/**
* Returns an {@link module:engine/model/element~Element} or {@link module:engine/model/documentfragment~DocumentFragment}
* which is a common ancestor for both positions. The {@link #root roots} of these two positions must be identical.
* which is a common ancestor of both positions. The {@link #root roots} of these two positions must be identical.
*
* @param {module:engine/model/position~Position} position The second position.
* @returns {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment|null}
*/
getCommonAncestor( position ) {
if ( this.root !== position.root ) {
return null;
}

const ancestorsA = this.getAncestors();
const ancestorsB = position.getAncestors();

Expand Down
2 changes: 1 addition & 1 deletion src/model/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export default class Range {

/**
* Returns an {@link module:engine/model/element~Element} or {@link module:engine/model/documentfragment~DocumentFragment}
* which is a common ancestor for both positions.
* which is a common ancestor of the range's both ends (in which the entire range is contained).
*
* @returns {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment|null}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/view/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default class Position {

/**
* Returns a {@link module:engine/view/node~Node} or {@link module:engine/view/documentfragment~DocumentFragment}
* which is a common ancestor for both positions.
* which is a common ancestor of both positions.
*
* @param {module:engine/view/position~Position} position
* @returns {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment|null}
Expand Down
2 changes: 1 addition & 1 deletion src/view/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default class Range {

/**
* Returns a {@link module:engine/view/node~Node} or {@link module:engine/view/documentfragment~DocumentFragment}
* which is a common ancestor for both positions.
* which is a common ancestor of range's both ends (in which the entire range is contained).
*
* @returns {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment|null}
*/
Expand Down
11 changes: 6 additions & 5 deletions tests/model/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,9 @@ describe( 'Position', () => {
} );

describe( 'getCommonAncestor()', () => {
it( 'returns null when roots of the position are not the same', () => {
it( 'returns null when roots of both positions are not the same', () => {
const pos1 = new Position( root, [ 0 ] );
const pos2 = new Position( otherRoot, [ 1, 1 ] );
const pos2 = new Position( otherRoot, [ 0 ] );

test( pos1, pos2, null );
} );
Expand Down Expand Up @@ -887,11 +887,12 @@ describe( 'Position', () => {
test( liPosition, zPosition, ul );
} );

it( 'works if position is hooked before an empty element', () => {
// Checks if by mistake someone didn't use getCommonPath() + getNodeByPath().
it( 'works if position is located before an element', () => {
const doc = new Document();
const root = doc.createRoot();

const p = new Element( 'p', null, new Element( 'a', null, [] ) );
const p = new Element( 'p', null, new Element( 'a' ) );

root.appendChildren( p );

Expand All @@ -900,7 +901,7 @@ describe( 'Position', () => {
test( postion, postion, p );
} );

it( 'works fine with positions hooked in `DocumentFragment`', () => {
it( 'works fine with positions located in DocumentFragment', () => {
const docFrag = new DocumentFragment( [ p, ul ] );
const zPosition = new Position( docFrag, [ 1, 0, 2 ] );
const afterLiPosition = new Position( docFrag, [ 1, 2 ] );
Expand Down

0 comments on commit 42f0b8e

Please sign in to comment.