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

T/1009: Element#getNodeByPath() should expect offsets not indexes #1043

Merged
merged 6 commits into from
Jul 28, 2017

Conversation

pomek
Copy link
Member

@pomek pomek commented Jul 25, 2017

Suggested merge commit message (convention)

Fix: model.Element#getNodeByPath() and model.DocumentFragment#getNodeByPath() work with offsets instead of indexes. Closes ckeditor/ckeditor5#4108.

@pomek pomek requested a review from Reinmar July 25, 2017 08:30

// <paragraph>foo<bold>bar</bold>bom</paragraph>

expect( frag.getNodeByPath( [ 0, 0 ] ) ).to.equal( foo );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not good when all tests start with 0 offset. E.g. if we'd implement this method recursively this would pass while there still might be a bug in DF itself.

@Reinmar
Copy link
Member

Reinmar commented Jul 25, 2017

Minor R- for incomplete tests.

Besides that, have you checked how and why existing getNodeByPath() usage worked?

@Reinmar
Copy link
Member

Reinmar commented Jul 26, 2017

The tests are fine now. But this question remains:

Besides that, have you checked how and why existing getNodeByPath() usage worked?

@pomek
Copy link
Member Author

pomek commented Jul 26, 2017

I found only one place in the whole project where the method is used:

const commonParent = root.getNodeByPath( commonPath );
.

@Reinmar
Copy link
Member

Reinmar commented Jul 26, 2017

So could we have a test (which would fail before this fix) for that method?

@pomek
Copy link
Member Author

pomek commented Jul 28, 2017

Finally, I did it! :D

@Reinmar
Copy link
Member

Reinmar commented Jul 28, 2017

Great. That's a really good test.

@Reinmar Reinmar merged commit 331d2f4 into master Jul 28, 2017
@Reinmar Reinmar deleted the t/1009 branch July 28, 2017 10:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Element#getNodeByPath() should expect offsets not indexes
2 participants