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

Commit

Permalink
Swapped the order of parameters in "Schema#findAllowedParent()".
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Jan 16, 2019
1 parent 1f213f9 commit 3fa5807
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/conversion/upcastdispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default class UpcastDispatcher {
*/
_splitToAllowedParent( node, modelCursor ) {
// Try to find allowed parent.
const allowedParent = this.conversionApi.schema.findAllowedParent( node, modelCursor );
const allowedParent = this.conversionApi.schema.findAllowedParent( modelCursor, node );

// When there is no parent that allows to insert node then return `null`.
if ( !allowedParent ) {
Expand Down
4 changes: 2 additions & 2 deletions src/model/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ export default class Schema {
* as long as {@link module:engine/model/schema~Schema#isLimit limit element},
* {@link module:engine/model/schema~Schema#isObject object element} or top-most ancestor won't be reached.
*
* @params {module:engine/model/node~Node|String} node Node for which allowed parent should be found or its name.
* @params {module:engine/model/position~Position} position Position from searching will start.
* @params {module:engine/model/node~Node|String} node Node for which allowed parent should be found or its name.
* @returns {module:engine/model/element~Element|null} element Allowed parent or null if nothing was found.
*/
findAllowedParent( node, position ) {
findAllowedParent( position, node ) {
let parent = position.parent;

while ( parent ) {
Expand Down
14 changes: 7 additions & 7 deletions tests/model/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1574,21 +1574,21 @@ describe( 'Schema', () => {
it( 'should return position ancestor that allows to insert given node to it', () => {
const node = new Element( 'paragraph' );

const allowedParent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
const allowedParent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );

expect( allowedParent ).to.equal( r1bQ );
} );

it( 'should return position ancestor that allows to insert given node to it - works with a string too', () => {
const allowedParent = schema.findAllowedParent( 'paragraph', Position._createAt( r1bQp, 0 ) );
const allowedParent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), 'paragraph' );

expect( allowedParent ).to.equal( r1bQ );
} );

it( 'should return position ancestor that allows to insert given node to it when position is already i such an element', () => {
const node = new Text( 'text' );

const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );

expect( parent ).to.equal( r1bQp );
} );
Expand All @@ -1602,7 +1602,7 @@ describe( 'Schema', () => {
} );
const node = new Element( 'div' );

const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );

expect( parent ).to.null;
} );
Expand All @@ -1616,21 +1616,21 @@ describe( 'Schema', () => {
} );
const node = new Element( 'div' );

const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );

expect( parent ).to.null;
} );

it( 'should return null when there is no allowed ancestor for given position', () => {
const node = new Element( 'section' );

const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );

expect( parent ).to.null;
} );

it( 'should return null when there is no allowed ancestor for given position – works with a string too', () => {
const parent = schema.findAllowedParent( 'section', Position._createAt( r1bQp, 0 ) );
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), 'section' );

expect( parent ).to.null;
} );
Expand Down

0 comments on commit 3fa5807

Please sign in to comment.