From 549da9ccbefec863a9ecbb2484318dcfad6cf42a Mon Sep 17 00:00:00 2001 From: Benjamin Oertel Date: Tue, 26 Mar 2019 16:55:00 -0700 Subject: [PATCH] Update index.js --- index.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index c9c8434..9914234 100644 --- a/index.js +++ b/index.js @@ -47,19 +47,18 @@ StringBinding.prototype.detachDoc = function() { this.doc.removeListener('op', this._opListener); }; -StringBinding.prototype._onOp = function(op, source) { +StringBinding.prototype._onOp = function(ops, source) { if (source === this) return; - if (op.length === 0) return; - if (op.length > 1) { - throw new Error('Op with multiple components emitted'); - } - var component = op[0]; - if (isSubpath(this.path, component.p)) { - this._parseInsertOp(component); - this._parseRemoveOp(component); - } else if (isSubpath(component.p, this.path)) { - this._parseParentOp(); - } + if (ops.length === 0) return; + + ops.forEach(function (component) { + if (isSubpath(this.path, component.p)) { + this._parseInsertOp(component); + this._parseRemoveOp(component); + } else if (isSubpath(component.p, this.path)) { + this._parseParentOp(); + } + }); }; StringBinding.prototype._parseInsertOp = function(component) {