Skip to content

Do not invert automatically in Doc.prototype._rollback #442

Open
@antoinelyset

Description

@antoinelyset

Hey ShareDB's team!

While using https://github.com/ottypes/json1 with ShareDB, I found a small problem in Doc.prototype._rollback. It automatically uses JSON1.type.invert but since we don't use invertible operations (our remove ops do not contain the removed data), it does not work.

sharedb/lib/client/doc.js

Lines 950 to 957 in fa9179d

if ('op' in op && op.type.invert) {
op.op = op.type.invert(op.op);
// Transform the undo operation by any pending ops.
for (var i = 0; i < this.pendingOps.length; i++) {
var transformErr = transformX(this.pendingOps[i], op);
if (transformErr) return this._hardRollback(transformErr);
}

Moreover JSON1 support for invertible operations and composition is known to not be without flaws.

Do you think we could introduce a configuration option to deactivate this functionality?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions