diff --git a/src/y-union.js b/src/y-union.js index 78a876213b7ccf115bada755e2a2f2a7c60f04c7..aabe816396061e64ec907505ecd051d8206dd6ae 100644 --- a/src/y-union.js +++ b/src/y-union.js @@ -6,7 +6,7 @@ export const Union = { create: function(id) { return { id: id, - union: -1, + union: null, struct: "Union", } }, @@ -15,7 +15,7 @@ export const Union = { struct: "Union", type: op.type, id: op.id, - union: -1, + union: null, } if (op.requires != null) { e.requires = op.requires @@ -39,7 +39,7 @@ export default function extendYUnion(Y) { this._parent = null this._deepEventHandler = new Y.utils.EventListenerHandler() this.os = os - this.union = Y.utils.copyObject(model.union) + this.union = model.union ? Y.utils.copyObject(model.union) : null this.contents = contents this.eventHandler = new Y.utils.EventHandler((op) => { // compute op event @@ -96,7 +96,7 @@ export default function extendYUnion(Y) { const insert = { id: this.os.getNextOpId(1), left: null, - right: null, + right: this.union, origin: null, parent: this._model, content: [mergedContents], @@ -139,7 +139,7 @@ export default function extendYUnion(Y) { initType: function* YUnionInitializer(os, model) { const union = model.union const contents = - union != -1 ? yield* this.getOperation(union).content[0] : "[]" + union !== null ? yield* this.getOperation(union).content[0] : "[]" return new YUnion(os, model, contents) }, createType: function YUnionCreator(os, model) {