Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.swp
node_modules
coverage
.idea
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function StringBinding(element, doc, path) {
this._opListener = null;
this._inputListener = null;
}

StringBinding.prototype = Object.create(TextDiffBinding.prototype);
StringBinding.prototype.constructor = StringBinding;

Expand All @@ -28,6 +29,7 @@ StringBinding.prototype.attachElement = function() {
this._inputListener = function() {
binding.onInput();
};

this.element.addEventListener('input', this._inputListener, false);
};

Expand All @@ -40,6 +42,7 @@ StringBinding.prototype.attachDoc = function() {
this._opListener = function(op, source) {
binding._onOp(op, source);
};

this.doc.on('op', this._opListener);
};

Expand All @@ -53,6 +56,7 @@ StringBinding.prototype._onOp = function(op, source) {
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);
Expand Down Expand Up @@ -86,6 +90,7 @@ StringBinding.prototype._get = function() {
var segment = this.path[i];
value = value[segment];
}

return value;
};

Expand All @@ -105,5 +110,6 @@ function isSubpath(path, testPath) {
for (var i = 0; i < path.length; i++) {
if (testPath[i] !== path[i]) return false;
}

return true;
}
Loading