Skip to content

Commit

Permalink
fixes bug with two-way bindings trying to set input empty string valu…
Browse files Browse the repository at this point in the history
…e to an observable that doesn't exist yet
  • Loading branch information
justinbmeyer committed Mar 15, 2018
1 parent 474171b commit 27fbfc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions can-stache-key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,9 @@ testHelpers.dev.devOnlyTest("a warning is given for `callMethodsOnObservables: t
QUnit.equal(teardown(), 1, "warning displayed");
});

QUnit.test("writing to a null observable is ignored", function(){
observeReader.write({},"foo.bar", "value");
observeReader.write(null,"bar", "value");
observeReader.write(null,"foo.bar", "value");
QUnit.ok(true, "all passed without error");
});
4 changes: 3 additions & 1 deletion can-stache-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,16 @@ observeReader = {
var last;

options = options || {};

if(keys.length > 1) {
last = keys.pop();
parent = observeReader.read(parent, keys, options).value;
keys.push(last);
} else {
last = keys[0];
}
if(!parent) {
return;
}
var keyValue = peek(parent, last.key);
// here's where we need to figure out the best way to write

Expand Down

0 comments on commit 27fbfc5

Please sign in to comment.