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

Commit 6515558

Browse files
authored
Merge pull request #1637 from ckeditor/t/1636
Other: Swapped the order of parameters in `Schema#findAllowedParent()`. Now those parameters match to parameters in other methods of the `Schema` class. Closes #1636. BREAKING CHANGE: Swapped the order of parameters in `Schema#findAllowedParent()`.
2 parents 7bb945a + 3fa5807 commit 6515558

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/conversion/upcastdispatcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export default class UpcastDispatcher {
263263
*/
264264
_splitToAllowedParent( node, modelCursor ) {
265265
// Try to find allowed parent.
266-
const allowedParent = this.conversionApi.schema.findAllowedParent( node, modelCursor );
266+
const allowedParent = this.conversionApi.schema.findAllowedParent( modelCursor, node );
267267

268268
// When there is no parent that allows to insert node then return `null`.
269269
if ( !allowedParent ) {

src/model/schema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,11 @@ export default class Schema {
588588
* as long as {@link module:engine/model/schema~Schema#isLimit limit element},
589589
* {@link module:engine/model/schema~Schema#isObject object element} or top-most ancestor won't be reached.
590590
*
591-
* @params {module:engine/model/node~Node|String} node Node for which allowed parent should be found or its name.
592591
* @params {module:engine/model/position~Position} position Position from searching will start.
592+
* @params {module:engine/model/node~Node|String} node Node for which allowed parent should be found or its name.
593593
* @returns {module:engine/model/element~Element|null} element Allowed parent or null if nothing was found.
594594
*/
595-
findAllowedParent( node, position ) {
595+
findAllowedParent( position, node ) {
596596
let parent = position.parent;
597597

598598
while ( parent ) {

tests/model/schema.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,21 +1574,21 @@ describe( 'Schema', () => {
15741574
it( 'should return position ancestor that allows to insert given node to it', () => {
15751575
const node = new Element( 'paragraph' );
15761576

1577-
const allowedParent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
1577+
const allowedParent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );
15781578

15791579
expect( allowedParent ).to.equal( r1bQ );
15801580
} );
15811581

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

15851585
expect( allowedParent ).to.equal( r1bQ );
15861586
} );
15871587

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

1591-
const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
1591+
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );
15921592

15931593
expect( parent ).to.equal( r1bQp );
15941594
} );
@@ -1602,7 +1602,7 @@ describe( 'Schema', () => {
16021602
} );
16031603
const node = new Element( 'div' );
16041604

1605-
const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
1605+
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );
16061606

16071607
expect( parent ).to.null;
16081608
} );
@@ -1616,21 +1616,21 @@ describe( 'Schema', () => {
16161616
} );
16171617
const node = new Element( 'div' );
16181618

1619-
const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
1619+
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );
16201620

16211621
expect( parent ).to.null;
16221622
} );
16231623

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

1627-
const parent = schema.findAllowedParent( node, Position._createAt( r1bQp, 0 ) );
1627+
const parent = schema.findAllowedParent( Position._createAt( r1bQp, 0 ), node );
16281628

16291629
expect( parent ).to.null;
16301630
} );
16311631

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

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

0 commit comments

Comments
 (0)