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

Internal: Changed the way of data serialization. #1493

Merged
merged 3 commits into from
Aug 14, 2018
Merged

Internal: Changed the way of data serialization. #1493

merged 3 commits into from
Aug 14, 2018

Conversation

oskarwrobel
Copy link
Contributor

@oskarwrobel oskarwrobel commented Aug 6, 2018

Suggested merge commit message (convention)

Internal: Changed the way of data serialization. Closes ckeditor/ckeditor5#4392.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@coveralls
Copy link

coveralls commented Aug 6, 2018

Coverage Status

Coverage increased (+0.006%) to 98.639% when pulling f2863d5 on t/1477 into e334195 on master.

@@ -915,7 +926,7 @@ export default class Position {
*/
static fromJSON( json, doc ) {
if ( json.root === '$graveyard' ) {
const pos = new Position( doc.graveyard, json.path );
const pos = new Position( doc.graveyard, Array.from( json.path ) );
Copy link

Choose a reason for hiding this comment

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

Why do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be removed.

result[ attr[ 0 ] ] = attr[ 1 ];

return result;
}, {} );
Copy link

Choose a reason for hiding this comment

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

A comment is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@pjasiun pjasiun merged commit a140350 into master Aug 14, 2018
@pjasiun pjasiun deleted the t/1477 branch August 14, 2018 13:36
pjasiun pushed a commit that referenced this pull request Aug 14, 2018
Other: Make `toJSON()` to serialize nested objects. Closes #1477.
/**
* @inheritDoc
*/
toJSON() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder here... Theoretically, values could be arrays or objects. Will those be cloned?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW... maybe we should just give up that and allow only for string, numeral and boolean values for attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔I'm afraid in a case of objects we pass a reference to the value instead of cloning.

return new AttributeOperation( this.range, this.key, this.oldValue, this.newValue, this.baseVersion );

We can think about dropping other formats than primitives but we don't know if someone has already used it with objects or arrays.


json.position = this.position.toJSON();

if ( json.graveyardPosition ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap operation can have graveyard position or element. Shouldn't we do json.element = this.element.toJSON() ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants